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

[suggestion] webpack: add unique hashes to output filenames #226

Open
tjosepo opened this issue Jan 9, 2025 · 1 comment
Open

[suggestion] webpack: add unique hashes to output filenames #226

tjosepo opened this issue Jan 9, 2025 · 1 comment

Comments

@tjosepo
Copy link
Member

tjosepo commented Jan 9, 2025

Currently, our production Webpack configuration uses these options:

output: {
    filename: "[name].js",
    assetModuleFilename: "[name][ext][query]"
}

The names of our entryfile and assets are static across builds. chunkFilename is not set, which means chunks have default filename [id].js which will also remain static most of the time.

These options can cause issues with caching heuristics used by different platforms, notably Cloudflare which adds a 4-hour browser cache directive on all .js files by default (see Cloudflare - Default cache behavior.)

These options forces us to disable caching in all our infrastructure to prevent a user from using a file from their cache when it has been updated on the server.

Ideally, we'd use hashes to ensure users can safely cache our files without the risk of loading a file from cache while a new version exists.

By default, Rollup and Vite use the pattern [name]-[hash][ext] for all outputs. We should probably do the same.

Warning

Module Federation entrypoints need static names, so the remote entrypoint cannot have a hashed filename. Cache can be bypassed in other ways, e.g. using a URL parameter, but that is the responsability of the host module or a framework to do.

@patricklafrance
Copy link
Member

patricklafrance commented Jan 10, 2025

Hey @tjosepo!

We used to have unique hashes but we removed them because of the following issue: https://workleap.atlassian.net/browse/WP-146 and Netlify atomic deployments.

Here are additional information on the issue and fix (which is still not optimal to this day):

If you still believe that this fix is not adequate and you have a better solution to propose, we are open to it. Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants