@shopify/hydrogen 2026.4.2 → 2026.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  import { Preset } from '@react-router/dev/config';
2
2
 
3
3
  /**
4
- * Official Hydrogen Preset for React Router 7.12.x
4
+ * Official Hydrogen Preset for React Router 7.16.x
5
5
  *
6
6
  * Provides optimal React Router configuration for Hydrogen applications on Oxygen.
7
7
  * Enables validated performance optimizations while ensuring CLI compatibility.
8
8
  *
9
- * React Router 7.12.x Feature Support Matrix for Hydrogen 2025.7.0
9
+ * React Router 7.16.x Feature Support Matrix for Hydrogen 2025.7.0
10
10
  *
11
11
  * +----------------------------------+----------+----------------------------------+
12
12
  * | Feature | Status | Notes |
@@ -34,7 +34,7 @@ import { Preset } from '@react-router/dev/config';
34
34
  * | prerender: ['/routes'] | Blocked | Plugin incompatibility |
35
35
  * | serverBundles: () => {} | Blocked | Manifest incompatibility |
36
36
  * | buildEnd: () => {} | Blocked | CLI bypasses hook execution |
37
- * | unstable_subResourceIntegrity | Blocked | CSP nonce/hash conflict |
37
+ * | subResourceIntegrity | Blocked | CSP nonce/hash conflict |
38
38
  * | v8_viteEnvironmentApi | Blocked | CLI fallback detection used |
39
39
  * +----------------------------------+----------+----------------------------------+
40
40
  *
@@ -10,9 +10,9 @@ function hydrogenPreset() {
10
10
  v8_middleware: true,
11
11
  v8_splitRouteModules: true,
12
12
  v8_viteEnvironmentApi: false,
13
- unstable_optimizeDeps: true,
14
- unstable_subResourceIntegrity: false
15
- }
13
+ unstable_optimizeDeps: true
14
+ },
15
+ subResourceIntegrity: false
16
16
  }),
17
17
  reactRouterConfigResolved: ({ reactRouterConfig }) => {
18
18
  if (reactRouterConfig.basename && reactRouterConfig.basename !== "/") {
@@ -35,9 +35,9 @@ function hydrogenPreset() {
35
35
  "[Hydrogen Preset] buildEnd is not supported in Hydrogen 2025.7.0.\nReason: Hydrogen CLI bypasses React Router buildEnd hook execution.\nWorkaround: Use external build scripts or package.json post-build hooks."
36
36
  );
37
37
  }
38
- if (reactRouterConfig.future?.unstable_subResourceIntegrity === true) {
38
+ if (reactRouterConfig.subResourceIntegrity === true) {
39
39
  throw new Error(
40
- "[Hydrogen Preset] unstable_subResourceIntegrity cannot be enabled.\nReason: Conflicts with Hydrogen CSP nonce-based authentication.\nImpact: Would break Content Security Policy and cause script execution failures."
40
+ "[Hydrogen Preset] subResourceIntegrity cannot be enabled.\nReason: Conflicts with Hydrogen CSP nonce-based authentication.\nImpact: Would break Content Security Policy and cause script execution failures."
41
41
  );
42
42
  }
43
43
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react-router-preset.ts"],"sourcesContent":["import type {Preset} from '@react-router/dev/config';\n\n/**\n * Official Hydrogen Preset for React Router 7.12.x\n *\n * Provides optimal React Router configuration for Hydrogen applications on Oxygen.\n * Enables validated performance optimizations while ensuring CLI compatibility.\n *\n * React Router 7.12.x Feature Support Matrix for Hydrogen 2025.7.0\n *\n * +----------------------------------+----------+----------------------------------+\n * | Feature | Status | Notes |\n * +----------------------------------+----------+----------------------------------+\n * | CORE CONFIGURATION |\n * +----------------------------------+----------+----------------------------------+\n * | appDirectory: 'app' | Enabled | Core application structure |\n * | buildDirectory: 'dist' | Enabled | Build output configuration |\n * | ssr: true | Enabled | Server-side rendering |\n * +----------------------------------+----------+----------------------------------+\n * | PERFORMANCE FLAGS |\n * +----------------------------------+----------+----------------------------------+\n * | v8_middleware | Enabled | Required for Hydrogen context |\n * | v8_splitRouteModules | Enabled | Route code splitting |\n * | unstable_optimizeDeps | Enabled | Build performance optimization |\n * +----------------------------------+----------+----------------------------------+\n * | ROUTE DISCOVERY |\n * +----------------------------------+----------+----------------------------------+\n * | routeDiscovery: { mode: 'lazy' } | Default | Lazy route loading |\n * | routeDiscovery: { mode: 'init' } | Allowed | Eager route loading |\n * +----------------------------------+----------+----------------------------------+\n * | UNSUPPORTED FEATURES |\n * +----------------------------------+----------+----------------------------------+\n * | basename: '/path' | Blocked | CLI infrastructure limitation |\n * | prerender: ['/routes'] | Blocked | Plugin incompatibility |\n * | serverBundles: () => {} | Blocked | Manifest incompatibility |\n * | buildEnd: () => {} | Blocked | CLI bypasses hook execution |\n * | unstable_subResourceIntegrity | Blocked | CSP nonce/hash conflict |\n * | v8_viteEnvironmentApi | Blocked | CLI fallback detection used |\n * +----------------------------------+----------+----------------------------------+\n *\n * @version 2025.7.0\n */\nexport function hydrogenPreset(): Preset {\n return {\n name: 'hydrogen-2025.7.0',\n\n reactRouterConfig: () => ({\n appDirectory: 'app',\n buildDirectory: 'dist',\n ssr: true,\n\n future: {\n v8_middleware: true,\n v8_splitRouteModules: true,\n v8_viteEnvironmentApi: false,\n unstable_optimizeDeps: true,\n unstable_subResourceIntegrity: false,\n },\n }),\n\n reactRouterConfigResolved: ({reactRouterConfig}) => {\n if (reactRouterConfig.basename && reactRouterConfig.basename !== '/') {\n throw new Error(\n '[Hydrogen Preset] basename is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: Requires major CLI infrastructure modernization.\\n' +\n 'Workaround: Use reverse proxy or CDN path rewriting for subdirectory hosting.',\n );\n }\n\n if (reactRouterConfig.prerender) {\n throw new Error(\n '[Hydrogen Preset] prerender is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: React Router plugin incompatibility with Hydrogen CLI build pipeline.\\n' +\n 'Workaround: Use external static generation tools or server-side caching.',\n );\n }\n\n if (reactRouterConfig.serverBundles) {\n throw new Error(\n '[Hydrogen Preset] serverBundles is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: React Router plugin manifest incompatibility with Hydrogen CLI.\\n' +\n 'Alternative: Route-level code splitting via v8_splitRouteModules is enabled.',\n );\n }\n\n if (reactRouterConfig.buildEnd) {\n throw new Error(\n '[Hydrogen Preset] buildEnd is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: Hydrogen CLI bypasses React Router buildEnd hook execution.\\n' +\n 'Workaround: Use external build scripts or package.json post-build hooks.',\n );\n }\n\n if (reactRouterConfig.future?.unstable_subResourceIntegrity === true) {\n throw new Error(\n '[Hydrogen Preset] unstable_subResourceIntegrity cannot be enabled.\\n' +\n 'Reason: Conflicts with Hydrogen CSP nonce-based authentication.\\n' +\n 'Impact: Would break Content Security Policy and cause script execution failures.',\n );\n }\n },\n };\n}\n"],"mappings":";AA0CO,SAAS,iBAAyB;AACvC,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,mBAAmB,OAAO;AAAA,MACxB,cAAc;AAAA,MACd,gBAAgB;AAAA,MAChB,KAAK;AAAA,MAEL,QAAQ;AAAA,QACN,eAAe;AAAA,QACf,sBAAsB;AAAA,QACtB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,QACvB,+BAA+B;AAAA,MACjC;AAAA,IACF;AAAA,IAEA,2BAA2B,CAAC,EAAC,kBAAiB,MAAM;AAClD,UAAI,kBAAkB,YAAY,kBAAkB,aAAa,KAAK;AACpE,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,WAAW;AAC/B,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,eAAe;AACnC,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,UAAU;AAC9B,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,QAAQ,kCAAkC,MAAM;AACpE,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/react-router-preset.ts"],"sourcesContent":["import type {Preset} from '@react-router/dev/config';\n\n/**\n * Official Hydrogen Preset for React Router 7.16.x\n *\n * Provides optimal React Router configuration for Hydrogen applications on Oxygen.\n * Enables validated performance optimizations while ensuring CLI compatibility.\n *\n * React Router 7.16.x Feature Support Matrix for Hydrogen 2025.7.0\n *\n * +----------------------------------+----------+----------------------------------+\n * | Feature | Status | Notes |\n * +----------------------------------+----------+----------------------------------+\n * | CORE CONFIGURATION |\n * +----------------------------------+----------+----------------------------------+\n * | appDirectory: 'app' | Enabled | Core application structure |\n * | buildDirectory: 'dist' | Enabled | Build output configuration |\n * | ssr: true | Enabled | Server-side rendering |\n * +----------------------------------+----------+----------------------------------+\n * | PERFORMANCE FLAGS |\n * +----------------------------------+----------+----------------------------------+\n * | v8_middleware | Enabled | Required for Hydrogen context |\n * | v8_splitRouteModules | Enabled | Route code splitting |\n * | unstable_optimizeDeps | Enabled | Build performance optimization |\n * +----------------------------------+----------+----------------------------------+\n * | ROUTE DISCOVERY |\n * +----------------------------------+----------+----------------------------------+\n * | routeDiscovery: { mode: 'lazy' } | Default | Lazy route loading |\n * | routeDiscovery: { mode: 'init' } | Allowed | Eager route loading |\n * +----------------------------------+----------+----------------------------------+\n * | UNSUPPORTED FEATURES |\n * +----------------------------------+----------+----------------------------------+\n * | basename: '/path' | Blocked | CLI infrastructure limitation |\n * | prerender: ['/routes'] | Blocked | Plugin incompatibility |\n * | serverBundles: () => {} | Blocked | Manifest incompatibility |\n * | buildEnd: () => {} | Blocked | CLI bypasses hook execution |\n * | subResourceIntegrity | Blocked | CSP nonce/hash conflict |\n * | v8_viteEnvironmentApi | Blocked | CLI fallback detection used |\n * +----------------------------------+----------+----------------------------------+\n *\n * @version 2025.7.0\n */\nexport function hydrogenPreset(): Preset {\n return {\n name: 'hydrogen-2025.7.0',\n\n reactRouterConfig: () => ({\n appDirectory: 'app',\n buildDirectory: 'dist',\n ssr: true,\n\n future: {\n v8_middleware: true,\n v8_splitRouteModules: true,\n v8_viteEnvironmentApi: false,\n unstable_optimizeDeps: true,\n },\n subResourceIntegrity: false,\n }),\n\n reactRouterConfigResolved: ({reactRouterConfig}) => {\n if (reactRouterConfig.basename && reactRouterConfig.basename !== '/') {\n throw new Error(\n '[Hydrogen Preset] basename is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: Requires major CLI infrastructure modernization.\\n' +\n 'Workaround: Use reverse proxy or CDN path rewriting for subdirectory hosting.',\n );\n }\n\n if (reactRouterConfig.prerender) {\n throw new Error(\n '[Hydrogen Preset] prerender is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: React Router plugin incompatibility with Hydrogen CLI build pipeline.\\n' +\n 'Workaround: Use external static generation tools or server-side caching.',\n );\n }\n\n if (reactRouterConfig.serverBundles) {\n throw new Error(\n '[Hydrogen Preset] serverBundles is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: React Router plugin manifest incompatibility with Hydrogen CLI.\\n' +\n 'Alternative: Route-level code splitting via v8_splitRouteModules is enabled.',\n );\n }\n\n if (reactRouterConfig.buildEnd) {\n throw new Error(\n '[Hydrogen Preset] buildEnd is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: Hydrogen CLI bypasses React Router buildEnd hook execution.\\n' +\n 'Workaround: Use external build scripts or package.json post-build hooks.',\n );\n }\n\n if (reactRouterConfig.subResourceIntegrity === true) {\n throw new Error(\n '[Hydrogen Preset] subResourceIntegrity cannot be enabled.\\n' +\n 'Reason: Conflicts with Hydrogen CSP nonce-based authentication.\\n' +\n 'Impact: Would break Content Security Policy and cause script execution failures.',\n );\n }\n },\n };\n}\n"],"mappings":";AA0CO,SAAS,iBAAyB;AACvC,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,mBAAmB,OAAO;AAAA,MACxB,cAAc;AAAA,MACd,gBAAgB;AAAA,MAChB,KAAK;AAAA,MAEL,QAAQ;AAAA,QACN,eAAe;AAAA,QACf,sBAAsB;AAAA,QACtB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,MACzB;AAAA,MACA,sBAAsB;AAAA,IACxB;AAAA,IAEA,2BAA2B,CAAC,EAAC,kBAAiB,MAAM;AAClD,UAAI,kBAAkB,YAAY,kBAAkB,aAAa,KAAK;AACpE,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,WAAW;AAC/B,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,eAAe;AACnC,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,UAAU;AAC9B,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,yBAAyB,MAAM;AACnD,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -31,6 +31,30 @@ type CreateRequestHandlerOptions<Context = unknown> = {
31
31
  */
32
32
  declare function createRequestHandler<Context = unknown>({ build, mode, poweredByHeader, getLoadContext, collectTrackingInformation, }: CreateRequestHandlerOptions<Context>): (request: Request) => Promise<Response>;
33
33
 
34
+ declare global {
35
+ /**
36
+ * Extensible interface for typing cart results with a custom cart fragment.
37
+ * Augment this interface with your codegen'd fragment type to get full type
38
+ * safety on every cart operation — whether accessed via `context.cart`,
39
+ * `createCartHandler`, or `createHydrogenContext`.
40
+ *
41
+ * When empty (the default), `HydrogenCustomCartFragment & Cart` collapses
42
+ * to `Cart`, so existing behaviour is unchanged.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * // In app/lib/context.ts
47
+ * import type {CartApiQueryFragment} from 'storefrontapi.generated';
48
+ *
49
+ * declare global {
50
+ * interface HydrogenCustomCartFragment extends CartApiQueryFragment {}
51
+ * }
52
+ * ```
53
+ */
54
+ interface HydrogenCustomCartFragment {
55
+ }
56
+ }
57
+
34
58
  type RequestEventPayload = {
35
59
  url: string;
36
60
  eventType: 'request' | 'subrequest';