-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
Using single-spa with webpack hashing? #564
Comments
I solved this by adding https://github.com/webdeveric/webpack-assets-manifest to our webpack config and reading that file in packages that depend on other packages to create the import map. There are two main caveats to that approach:
Not able to share any code. |
That is not the reason why we recommend this. Webpack chunking isn't compatible with non-AMD modules, and our webpack config is configured to output System module format to interop best with SystemJS. The hashes aren't related.
This configuration isn't dependent on webpack optimizations, so it should be as noted in webpack's docs: https://webpack.js.org/configuration/output/#outputfilename
I don't think an entire import map is necessary here... unless you want some advanced SystemJS features like subpath imports. You just need the output filename of the entry file, and that is what you'd use to update your import map. Then, its just a matter of hitting your import-map-deployer endpoint with that updated value.
Ah, I see. By externalizing the import map in some fashion (i'd previously referenced import-map-deployer) you can avoid redeploying the root-config project every time those URLs change. Then "deploying" is just a matter of updating a JSON file.
Having a single output entry filename to deal with could possibly make this pain go away. |
The recommended setup suggests to not use webpack caching features, since it would be easier to add a commit hash at deployment time.
Since the suggested method will produce new URLs for bundles even though their content didn't change, I would love to know what exactly is required to let webpack create bundles with consistent hashes in the bundle file names.
We are using a monorepo with lerna (currently still v4).
I assume we would need to generate something like an import map for each package the "resolves" the filename with the hash and merge those import maps of the required packages for each root config, but I'm not sure how to access the hash value in the webpack build to create/dump such an import map per package.
Another approach might of course be to calculate and add the hashes to the files after webpack is done, including modifying the import map accordingly.
Any other ideas, or showcases of how it can be done?
The text was updated successfully, but these errors were encountered: