Open sangeltandem opened 2 years ago
Have you tried setting external: []
in the webWorkerLoader options?
webWorkerLoader({ external: [] )
The README describes the option as follows:
EXPERIMENTAL override rollup resolution of external module IDs useful to inline external dependencies in a worker blob. Default: undefined
It seems by default all external modules are expected to be provided in scope separately unless you tell it to bundle the externals that way.
I would also like to understand how to resolve this
@theosanderson Did you try the above solution? It should resolve this.
Hi @mattrossman,
Yes I did. I wasn't clear if the suggestion was to add external: []
or external:['imported_package_name']
but in neither case was I able to get things to work. I get Uncaught ReferenceError: pako is not defined
within the worker. I don't have the nodeResolve()
plugin, if that could be the issue.
Ed: nodeResolve seems to help, now debugging hopefully a different issue
Right, it should be exactly external: []
(empty array, i.e. nothing will be provided externally, everything should be bundled internally).
Yes, IIRC I used @rollup/plugin-node-resolve
and @rollup/plugin-commonjs
in combination with this plugin.
Hey @mattrossman .
I have externals: []
in my config. This is making all the dependencies to be bundled along the worker code which is what i want.
But the bundled dependencies code is es6 code and i want it to resolve to es5 build of dependency so that i don't have to transpile it. Can you further help with this.
@mattrossman @sangeltandem @theosanderson
The Web Worker is failing to load external dependencies.
The web worker works fine for standalone functions that are written inside the Worker.ts file but when I moved actual code that had external dependencies I saw this in the console:
Saw this when running the
rollup -c
:This is my rollup.config.js
Should you be able to load external dependencies into the web worker? I am able to import relative files just fine but it breaks anytime I try to use an npm package. Is there some configuration I need to change to make this work?