-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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): keep code-split JS files in SSR build #8042
fix(remix-dev/vite): keep code-split JS files in SSR build #8042
Conversation
🦋 Changeset detectedLatest commit: c6813bf 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 |
packages/remix-dev/vite/plugin.ts
Outdated
@@ -789,7 +793,7 @@ export const remixVitePlugin: RemixVitePlugin = (options = {}) => { | |||
Array.from(ssrOnlyAssetPaths).map(async (ssrAssetPath) => { | |||
let src = path.join(serverBuildDir, ssrAssetPath); | |||
let dest = path.join(assetsBuildDirectory, ssrAssetPath); | |||
await fse.move(src, dest); | |||
await fse.copy(src, dest); |
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.
For consistency, I also changed from move
to copy
so that ssr build assets will be kept intact.
@hi-ogawa Thanks for looking into this!
I'd prefer for us to aim for a clean server build output so that people aren't deploying a tonne of unused assets along with their server code. Especially when we're still marked as unstable and have a bit of leeway to get this right. Maybe a more safe approach, rather than removing the entire assets directory, is to do a more targeted removal of all |
Thanks for the feedback! The another concern I'm thinking about is that, for experienced vite users (who are familiar with This might be out of scope right now, but for example, for whatever reasons, such users (or other plugins) might wish to customize But, I totally understand that, for the most of use cases, this won't be an issue and remix doesn't want to bloat default server output which users are likely consume and deploy directly. Also probably removing |
You're raising fair concerns for sure. I think we aim for a clean build output for now, but we can always add an option to disable this behaviour if it turns out it's a legitimate issue for someone. |
I updated a PR to cleanup unnecessary |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Closes: #8041
Follow up for #7892
EDIT: following comment is for initial approach. Now it's written to remove only unnecessary files based on the suggestion in #8042 (comment)
Instead of keeping whole
assets
directory, maybe we could probe vite manifest and keep onlyisDynamicEntry
.(EDIT: I further extended reproduction https://github.com/hi-ogawa/remix-reproduction-8041 and I found that
isDynamicEntry
is not a right way to detect this)For example, vite manifest from ssr build for
vite-build-test.ts
looks like this:reveal build/.vite/manifest.json
(here
assets/test2-LxNzCzR4.txt
is server-only assets, so it's moved to client assets directory.assets/test1-eT52RzBS.txt
andassets/_virtual_server-entry-119NVDiu.css
are unnecessary files to keep.)However, I don't think it's so important to clean up the rest so strictly (and also I'm not entirely sure if there could be more edge cases which I'm not aware of). So, I chose to keep the directory as is.
Please let me know what you think!