vite icon indicating copy to clipboard operation
vite copied to clipboard

feat: 🧪 chunkMap

Open bhbs opened this issue 1 year ago • 9 comments

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.

bhbs avatar Dec 17 '23 14:12 bhbs

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

stackblitz[bot] avatar Dec 17 '23 14:12 stackblitz[bot]

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

benmccann avatar Jan 15 '24 21:01 benmccann

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:

image

Not sure if that's the problem that needs to be fixed in vite or in the PWA plugin

jacekkarczmarczyk avatar Jan 31 '24 10:01 jacekkarczmarczyk

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.

bhbs avatar Jan 31 '24 15:01 bhbs

Thanks for testing @jacekkarczmarczyk! cc @userquin in case this rings a bell

patak-dev avatar Jan 31 '24 15:01 patak-dev

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.

jacekkarczmarczyk avatar Jan 31 '24 16:01 jacekkarczmarczyk

I've rebased PR branch against the current main and PWA error dissapeared👍

jacekkarczmarczyk avatar Feb 03 '24 04:02 jacekkarczmarczyk

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.

jacekkarczmarczyk avatar Feb 03 '24 04:02 jacekkarczmarczyk

I've experimented with applying this POC to our large vite app, and it works brilliantly!

olivierbeaulieu avatar Apr 03 '24 18:04 olivierbeaulieu