-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix(remix-dev/vite): attach CSS from shared chunks to routes #7952
Conversation
🦋 Changeset detectedLatest commit: 134a248 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
@hi-ogawa Also, thanks for all your hard work helping us with the Vite plugin! I really appreciate it 🙏 |
Thanks for the nice cleanup. I'm happy to help and also learn a lot from remix code base! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Closes: #7941
I think the issue was due to asset resolution not taking account for code-split common assets.
I made a reproduction repo here https://github.com/hi-ogawa/test-remix-vite-css-split and this is my observation.
I attached vite manifest and remix manifest generated by
build
currently.In vite manifest,
_test-206a75ed.js
entry has reference toassets/test-ef980167.css
, but there's no direct css dependency neither fromapp/root.tsx
orapp/routes/_index.tsx
, so remix manifest ends up with no css.build/manifest.json (vite manifest)
build/manifest-(hash).js (remix manifest)
I fixed the issue by traversing
ViteManifest[key].imports
to collect depending assets of given route entry.(I had similar issue when I was experimenting my own plugin, so the code is roughly based on https://github.com/hi-ogawa/vite-plugins/blob/0591f50b53ebd6027653a0902b50a492820fbbab/packages/vite-glob-routes/src/react-router/features/preload/shared.ts#L50-L59)
I locally verified that this PR fixed my reproduction hi-ogawa/test-remix-vite-css-split#1 and also added a new test case for
vite-build-test.ts
.Testing Strategy: