Giter VIP home page Giter VIP logo

Comments (6)

rhashimoto avatar rhashimoto commented on May 24, 2024 3

Worker modules are now in the Firefox nightly build, targeted for stable channel release in mid-February. It feels buggy at the moment, but that's just how nightlies are.

Update 1/5/23: Regressions forced reverting the worker module commit 🙁. Looks like release could slip.

from wa-sqlite.

AntonOfTheWoods avatar AntonOfTheWoods commented on May 24, 2024 2

If anyone comes here trying to put wa-sqlite in a service worker (which as of this posting still has terrible support for modules...) and is using vite-plugin-pwa, then you can put something like this in your VitePWAOptions config:

import replace from "@rollup/plugin-replace";
...
  injectManifest: {
    ...
    // @ts-ignore - this is a valid option somehow... and is required for wa-sqlite to work
    plugins: [replace({ "import.meta.url": mode === "development" ? "import.meta.url" : "undefined" })],
  },

And at the very least, it seems to work for me. As mentioned above, an empty string probably also works.

from wa-sqlite.

jimmywarting avatar jimmywarting commented on May 24, 2024

To create a Web Worker and being able to use ESM add a 2nd argument with { type: 'module' }

new Worker(url, { type: 'module '})

from wa-sqlite.

rhashimoto avatar rhashimoto commented on May 24, 2024

You can load an ES module directly in a Worker if browser compatibility is not an issue for you, but the point of this FAQ item is that currently bundling is required to work across all WASM-capable browsers (i.e. including Firefox) and this shows a workaround for a bundling problem.

from wa-sqlite.

jimmywarting avatar jimmywarting commented on May 24, 2024

I know, i just wanted to help out with some faq q/a stuff for others who also wonder how to load esm stuff in workers ;)

from wa-sqlite.

pauleveritt avatar pauleveritt commented on May 24, 2024

As an FYI, it appears there is some activity in Firefox for module workers.

from wa-sqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.