Build fails when customizing SSR entrypoint due to hardcoded deletion of SSR build `assets/` (chunks) directory
Opened this issue · 1 comments
What is the location of your example repository?
netlify/hydrogen-template@71145c9
Which package or tool is having this issue?
CLI
What version of that package or tool are you using?
@shopify/cli@3.66.1, @shopify/hydrogen@2024.7.4
What version of Remix are you using?
2.11.2
Steps to Reproduce
- Create a Hydrogen site (e.g. with
create-hydrogen
) - Override Remix's default SSR entrypoint configuration, e.g. to build a Netlify Edge Function
shopify hydrogen build
(don't runnpm run build
; we've changed this as a workaround)
This is a bit vague, so here are some more concrete steps you can actually follow:
- Clone https://github.com/netlify/hydrogen-template and checkout commit
71145c98d6245d05012fd110bf88ab1c4e83a099
,npm i
- Clone https://github.com/netlify/remix-compute and checkout netlify/remix-compute#441,
pnpm i && pnpm build:packages
, then in the hydrogen template runnpm link ../remix-compute/packages/remix-edge-adapter
shopify hydrogen build
(don't runnpm run build
; we've changed this as a workaround)
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 isn't ideal 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) customizing my SSR entrypoint configuration, I'm (or said other Vite plugin is) responsible for knowing this and handling it from end to end. Other than this one hiccup — and #2496 — this does seem to work just fine.)
Actual Behavior
The details here will vary depending on the specifics, but if you use the template linked above, you'll get:
Packaging Functions from .netlify/functions-internal directory:
- remix-server.mjs
✘ [ERROR] Could not resolve "./assets/server-build-BOKKiHSv.js"
This is because for some reason I don't quite grasp the hydrogen CLI build command deletes the assets/
directory from the server build output directory after building. Maybe the command is assuming chunking has been disabled? I'm not really sure, but it seems to be a leaky assumption, perhaps related to the Oxygen platform.
If I comment out this line inside my node_modules
, everything works.
For now, we're going to have our Netlify template and docs use remix vite:build
instead of shopify hydrogen build
as a workaround.
Thanks!
Another great catch @serhalp! Thanks for the report. Big fans of Netlify over here ❤