vite
vite copied to clipboard
feat: 🧪 chunkMap
for Production: #16552
Proof of Concept Implementation for #15372
This PR shows that ChunkMap (to avoid cascading cache invalidation problem with importmap) can be implemented seamlessly without impact on existing systems.
Run & review this pull request in StackBlitz Codeflow.
I wanted to surface a couple of comments about this PR over in the SvelteKit repo that reviewers should probably be aware of: https://github.com/sveltejs/kit/pull/11615#issuecomment-1890489236
Thanks for working on this issue, I've tried it on my actual app and:
-
it seems to work at first glance, two consecutive builds resulted only in changed
index-*.js
(I'm using build time env var which apparently is not in its own module, so it lands in the main entry point, and only that entry point was changed), then I've changed some.vue
file and the result was ok as well -
I get some error that seems to be related to PWA:
Not sure if that's the problem that needs to be fixed in vite or in the PWA plugin
Thank you for checking ✨ The error doesn't seem to be related to the hash. I wonder what it is. In systems that, like VitePress, directly load and process generated JS instead of HTML, there can be issues if the import-map is not considered during loading.
Thanks for testing @jacekkarczmarczyk! cc @userquin in case this rings a bell
The error doesn't seem to be related to the hash. I wonder what it is.
I've build first with [email protected]
and then with this PR, there's a lot of commits since 5.0.5 on the main
branch, so error might be caused by one of them and not by this PR. Didn't check it against current main
branch, maybe I'll do it tomorrow.
I've rebased PR branch against the current main
and PWA error dissapeared👍
I've tested it also with legacy plugin (5.3.0), and all chunks have new hashes, I think it's fine for legacy chunks (old browsers don't support import maps I guess, although it could use System.js, not a big issue though) but modern ones should not be changed.
Not sure if I'm going to use legacy plugin after switching to vite, just letting you know.
I've experimented with applying this POC to our large vite app, and it works brilliantly!