Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: support fixed filename #19

Closed
rottmann opened this issue Feb 12, 2019 · 8 comments
Closed

Feature request: support fixed filename #19

rottmann opened this issue Feb 12, 2019 · 8 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@rottmann
Copy link

compilerOptions.output.chunkFilename is [name].[hash].js and i need to provide the generated name.hash.worker.js to sw-precache-webpack-plugin

I 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:

      new WorkerPlugin({
        filename: 'worker.js'
      }),
@developit
Copy link
Collaborator

@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.

@developit developit added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Feb 19, 2019
@thijstriemstra
Copy link

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()]

@filipesilva
Copy link

Also saw the name ping pong between 0 and 1 in angular/angular-cli#13700 (comment). Was very problematic for our tests.

@FTWinston
Copy link

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.

@jackdbd
Copy link

jackdbd commented Mar 7, 2020

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?

@developit
Copy link
Collaborator

developit commented Mar 9, 2020

@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.

gluck added a commit to gluck/worker-plugin that referenced this issue Mar 11, 2020
- chunkFilename is preserved from compilerOptions
- use chunkName = worker name (or ID) + '.worker'
- allow to override chunkFilename is needed (GoogleChromeLabs#19)
@developit
Copy link
Collaborator

I just implemented { filename, chunkFilename } options in #82.

@developit
Copy link
Collaborator

The filename option is now released in 5.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants