GoogleChromeLabs / worker-plugin

👩‍🏭 Adds native Web Worker bundling support to Webpack.
https://npm.im/worker-plugin
Apache License 2.0
1.91k stars 79 forks source link

Handle import.meta.url #67

Open developit opened 4 years ago

developit commented 4 years ago

It should be possible to apply a pre/pitching loader to all files that transforms import.meta.url to __filename. This would allow correct Worker URL creation (solving #31) using URL:

const url = new URL('./my-worker.js', import.meta.url);
const worker = new Worker(url, { type: 'module' });

I believe Webpack's simple partial evaluation should be enough to consider this a "static" URL under the current logic.