Closed rottmann closed 4 years ago
@rottmann perhaps just an option to override chunkFilename
as used by WorkerPlugin? It could be a template, but in your case you'd just not use any fields.
I have no idea why I keep getting this error but it seems related to this ticket..
Uncaught DOMException: Failed to construct 'Worker': Script at 'localhost:8080/dist/0.worker.js' cannot be accessed from origin 'http://localhost:8080'.
That worker filename sometimes changes to 1.worker.js
, sometimes 0.worker.js
, meh.
The webpack config :
entry: {
wavesurfer: path.join(rootDir, 'src', 'wavesurfer.js')
},
output: {
path: path.join(rootDir, 'dist'),
filename: '[name].js',
library: 'WaveSurfer'
},
plugins: [new WorkerPlugin()]
Also saw the name ping pong between 0 and 1 in https://github.com/angular/angular-cli/pull/13700#discussion_r269972055. Was very problematic for our tests.
Related to this, I'd like to be able to stop the generated file names when I do an import() statement in my worker having .worker.js appended at the end.
(The import statement is in a function I serialsed and passed to the worker, so the actual generated file doesn't end in .chunk.worker.js, but just in .chunk.js.)
Using templates for generated filenames as suggested would work for me as long as it also applied to dynamic imports. I'd raised another issue relating to htis on #43, but have since worked around it.
With no fixed filename for the web worker bundle, is there a workaround to inject a <link>
with modulepreload in the template <head>
?
If I had a single web worker I guess I could get the filename from the manifest.json
generated by webpack-manifest-plugin. But what if I had more than one worker?
@jackdbd No browsers support preloading Web Workers. There are some options for preloading Module Workers that are only supported in Chrome, you can read about them here.
I just implemented { filename, chunkFilename }
options in #82.
compilerOptions.output.chunkFilename
is[name].[hash].js
and i need to provide the generatedname.hash.worker.js
to sw-precache-webpack-pluginI cant use the generated .worker.js filename, the [name] could not be used from /sw-precache-webpack-plugin (ok thats their problem) and the hash seems not to match the generated file.
An option to set a fixed target filename in webpack config would be perfect: