Description
What is the location of your example repository?
No response
Which package or tool is having this issue?
CLI
What version of that package or tool are you using?
@shopify/[email protected], @shopify/[email protected]
What version of Remix are you using?
2.11.2
Steps to Reproduce
(I can provide a failing test or example repo if it's useful. I just wanted to open this before I lose track of it.)
- Create a Hydrogen site (e.g. with
create-hydrogen
) - Override Remix's default SSR bundle chunk name, setting it to a patterned string, e.g. in
vite.config.js
:
build: {
rollupOptions: {
output: {
entryFileNames: "[name].js"
}
}
}
(This step can also be e.g. config.build.rollupOptions.output.entryFileNames = '[name].js'
in a config()
hook in a Vite plugin, as in our case.)
npm run build
To provide a bit more context, I work at Netlify and we encountered this while building out support for Hydrogen Vite on our platform. As noted below, we have a workaround, but it feels brittle and this could bite others in the future.
Expected Behavior
The site builds successfully. (The assumption is that since I'm (or some other Vite plugin is) writing my SSR entrypoint to a different file, I'm (or said other Vite plugin is) responsible for knowing this. Other than this one hiccup — and #2497 — this does seem to work just fine.)
Actual Behavior
The build command throws ENOENT: no such file or directory dist/server/[name].js
, because it assumes here that a string entryFileNames
is a resolvable path when joined with serverOutDir
.
I believe this is leaking assumptions from the internal Remix Vite implementation.
I can work around this by changing "[name].js"
to () => "[name].js"
, but this feels pretty hacky!
There are a few options for fixing this:
- degrade gracefully when attempting to check if you should warn about the SSR bundle file size (e.g. try-catch the file read)
- skip the check if it contains a pattern
- use the actual final chunk filename from
serverBuild
(the value resolved fromvite.build()
); it should be in there somewhere
Thanks!