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

Build fails when customizing SSR entrypoint due to hardcoded deletion of SSR build assets/ (chunks) directory #2497

Open
serhalp opened this issue Sep 4, 2024 · 1 comment
Labels
Bug Something isn't working SEV-4

Comments

@serhalp
Copy link

serhalp commented Sep 4, 2024

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/[email protected], @shopify/[email protected]

What version of Remix are you using?

2.11.2

Steps to Reproduce

  1. Create a Hydrogen site (e.g. with create-hydrogen)
  2. Override Remix's default SSR entrypoint configuration, e.g. to build a Netlify Edge Function
  3. shopify hydrogen build (don't run npm 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:

  1. Clone https://github.com/netlify/hydrogen-template and checkout commit 71145c98d6245d05012fd110bf88ab1c4e83a099, npm i
  2. Clone https://github.com/netlify/remix-compute and checkout feat(@netlify/remix-edge-adapter): support Hydrogen Vite sites netlify/remix-compute#441, pnpm i && pnpm build:packages, then in the hydrogen template run npm link ../remix-compute/packages/remix-edge-adapter
  3. shopify hydrogen build (don't run npm 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!

@scottdixon
Copy link
Contributor

Another great catch @serhalp! Thanks for the report. Big fans of Netlify over here ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working SEV-4
Projects
None yet
Development

No branches or pull requests

2 participants