Skip to content

fix: ssr.optimizeDeps dependency resolution warnings with pnpm dev#3698

Draft
fredericoo wants to merge 2 commits intomainfrom
fix-skeleton-optimizedeps-resolution
Draft

fix: ssr.optimizeDeps dependency resolution warnings with pnpm dev#3698
fredericoo wants to merge 2 commits intomainfrom
fix-skeleton-optimizedeps-resolution

Conversation

@fredericoo
Copy link
Copy Markdown
Contributor

@fredericoo fredericoo commented Apr 10, 2026

WHY are these changes introduced?

A freshly scaffolded Hydrogen app shows two warnings on dev:

Failed to resolve dependency: set-cookie-parser, present in ssr 'optimizeDeps.include'
Failed to resolve dependency: cookie, present in ssr 'optimizeDeps.include'

cookie and set-cookie-parser are CJS transitive dependencies of react-router. Listed by bare name in ssr.optimizeDeps.include, Vite can't resolve them with pnpm's strict hoisting — transitive deps aren't accessible from the project root.

WHAT is this pull request doing?

Uses Vite's nested dependency syntax (react-router > dep) to resolve through react-router's own node_modules. This is the documented approach for strict package managers like pnpm.

-      include: ['set-cookie-parser', 'cookie', 'react-router'],
+      include: [
+        'react-router > set-cookie-parser',
+        'react-router > cookie',
+        'react-router',
+      ],

HOW to test your changes?

  1. pnpm create @shopify/hydrogen@latest
  2. pnpm run dev
  3. see warnings
  4. change vite.config according to previous step
  5. run dev again
  6. Confirm no Failed to resolve dependency warnings in the console

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or functional changes. Test changes or internal-only config changes do not require a changeset.
  • I've added tests to cover my changes
  • I've added or updated the documentation

@fredericoo fredericoo changed the title Fix skeleton ssr.optimizeDeps dependency resolution warnings fix: ssr.optimizeDeps dependency resolution warnings with pnpm dev Apr 10, 2026
@shopify
Copy link
Copy Markdown
Contributor

shopify bot commented Apr 10, 2026

Oxygen deployed a preview of your fix-skeleton-optimizedeps-resolution branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment April 10, 202611:47 AM

Learn more about Hydrogen's GitHub integration.

@fredericoo fredericoo marked this pull request as ready for review April 10, 2026 11:09
@fredericoo fredericoo requested a review from a team as a code owner April 10, 2026 11:09
@fredericoo fredericoo marked this pull request as draft April 10, 2026 11:28
fredericoo and others added 2 commits April 10, 2026 12:43
set-cookie-parser and cookie are CJS transitive dependencies of
react-router. Listed by bare name in ssr.optimizeDeps.include, Vite
can't resolve them with pnpm's strict hoisting because transitive
deps aren't accessible from the project root.

Using Vite's `parent > child` nested dependency syntax
(e.g. `react-router > cookie`) tells Vite to resolve through
react-router's own node_modules, which works with strict package
managers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The express, multipass, and partytown recipes all patch the skeleton's
vite.config.ts ssr.optimizeDeps.include array. Update the patch
context lines, READMEs, and LLM prompts to match the new multi-line
format using `react-router > dep` nested resolution syntax.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fredericoo fredericoo force-pushed the fix-skeleton-optimizedeps-resolution branch from c6d2b7b to ef6d10f Compare April 10, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant