surma / rollup-plugin-off-main-thread

Use Rollup with workers and ES6 modules today.
Apache License 2.0
308 stars 32 forks source link

Default setup not working if bundle is not in web root #26

Closed panda-madness closed 3 years ago

panda-madness commented 4 years ago

If I modify the demo gist to serve the project root instead of the dist folder loading worker modules fails because it assumes all emitted files are directly under the document root.

Here's a repo with reproduction.

Screen Shot 2020-06-15 at 16 18 48

Note the actual comlink file is under http://127.0.0.1:8080/dist/ in the screenshot above.

Edit: I've also tried to load the bundle with SystemJS, the bundle path resolves correctly but is missing the js file extension for some reason. Same repo, systemjs branch.

Screen Shot 2020-06-15 at 16 25 03
gkjohnson commented 3 years ago

Webpack now supports the following syntax for address this, which is the right way to load a Worker with a relative path in a module in a browser, as well:

const worker = new Worker( new URL( './worker.js', import.meta.url ) );

It would be nice if the plugin supported this notation, as well.

cortopy commented 3 years ago

that's also the recommended way of dealing with web workers in snowpack https://github.com/snowpackjs/snowpack/issues/1280

surma commented 3 years ago

This plugin now supports the new URL() pattern as well. Can you check if this is still an issue?

surma commented 3 years ago

Closing this. But please re-open if it’s still broken