Skip to content
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

SSR assets code removed after build #8041

Closed
paul-phan opened this issue Nov 17, 2023 · 6 comments
Closed

SSR assets code removed after build #8041

paul-phan opened this issue Nov 17, 2023 · 6 comments

Comments

@paul-phan
Copy link

Reproduction

The reproduction requires a real-world like app, for example, a migrated indie/blues stack that uses sideEffect import or dynamic import.
Previously, running vite build -ssr would generate a build/index.js file, and the server code would be placed in build/assets folder. However, it appears that the build/assets folder is now removed immediately after the build process is completed.
I believe it is because of the newly added writeBundle code: 8cd31d6#diff-476a4eef80e39b35b744a556f1aec1762581b6864177c5f3a7ec9717ff415c28R750-R823

Screenshot 2023-11-17 at 12 31 26

System Info

System:
    OS: macOS 14.2
    CPU: (8) arm64 Apple M1
    Memory: 88.95 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    bun: 0.5.6 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 117.1.58.135
    Chrome: 118.0.5993.117
    Safari: 17.2
  npmPackages:
    @remix-run/dev: 2.3.0 => 2.3.0 
    @remix-run/eslint-config: 2.3.0 => 2.3.0 
    @remix-run/express: 2.3.0 => 2.3.0 
    @remix-run/node: 2.3.0 => 2.3.0 
    @remix-run/react: 2.3.0 => 2.3.0 
    @remix-run/serve: 2.3.0 => 2.3.0 
    vite: 5.0.0 => 5.0.0

Used Package Manager

npm

Expected Behavior

SRR entry output should be build/index.js and build/assets folder.

Actual Behavior

build/assets folder is missing/removed.

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Nov 17, 2023

Thanks for reporting the issue.
I made a simpler reproduction here https://github.com/hi-ogawa/remix-reproduction-8041 (also forked to stackblitz https://stackblitz.com/edit/hi-ogawa-remix-reproduction-8041-cjachi?file=README.md)
Indeed, this is a regression from #7892 as I wasn't aware of code-split js during ssr build.
I thought removing build/assets in writeBundle is harmless, but probably remix has to keep that directory as is (or at least generated code split js files).

@hi-ogawa
Copy link
Contributor

@paul-phan I'm hoping this next PR would fix the issue #8042, but it would be still helpful if you could provide a little more details about your app to spot potential edge cases.
For example, can you provide "vite manifest" of ssr build like I wrote in my reproduction README.md?
There should be a file either build/manifest.json (if vite 4) or build/.vite/manifest.json (if vite 5). I think this one is still left there without being deleted.

@paul-phan
Copy link
Author

@hi-ogawa Thanks for the quick update; here is my manifest.json file with Vite 5
manifest.json

@nicksrandall
Copy link
Contributor

Could be related to #8038 ?

@markdalgleish
Copy link
Member

This should be fixed by #8042. It will be available in the next nightly release if you want to try it out and report back.

@paul-phan Looking at your manifest (thanks for sharing it, by the way!), the only files that will be deleted with the fix linked above will be assets/playground-geHbun2U.css and assets/_virtual_server-entry-GEA9ZESU.css so I'm confident this will fix your issue.

@hilja
Copy link

hilja commented Nov 21, 2023

I was just majorly blocked by this. The nightly works great! 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants