@shopify/hydrogen 2024.4.2 → 2024.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.
@@ -6,12 +6,15 @@ import { getVirtualRoutes } from "./get-virtual-routes.js";
6
6
  const sharedOptions = {};
7
7
  function hydrogen(pluginOptions = {}) {
8
8
  let middlewareOptions = {};
9
- const isRemixChildCompiler = (config) => !config.plugins?.some((plugin) => plugin.name === "remix");
10
9
  return [
11
10
  {
12
11
  name: "hydrogen:main",
13
12
  config(_, env) {
14
13
  sharedOptions.command = env.command;
14
+ const isHydrogenMonorepo = new URL(
15
+ "../../..",
16
+ import.meta.url
17
+ ).pathname.endsWith("/hydrogen/packages/");
15
18
  return {
16
19
  ssr: {
17
20
  optimizeDeps: {
@@ -24,16 +27,16 @@ function hydrogen(pluginOptions = {}) {
24
27
  "react/jsx-dev-runtime",
25
28
  "react-dom",
26
29
  "react-dom/server",
27
- // Remix deps:
28
- "set-cookie-parser",
29
- "cookie"
30
+ "@remix-run/server-runtime"
30
31
  ]
31
32
  }
32
33
  },
33
34
  // Vite performs an initial reload after optimizing these dependencies.
34
35
  // Do it early to avoid the initial reload:
35
36
  optimizeDeps: {
36
- include: ["@shopify/hydrogen"]
37
+ // Avoid optimizing Hydrogen itself in the monorepo
38
+ // to prevent caching source code changes:
39
+ include: isHydrogenMonorepo ? ["content-security-policy-builder", "worktop/cookie"] : ["@shopify/hydrogen"]
37
40
  }
38
41
  };
39
42
  },
@@ -54,7 +57,6 @@ function hydrogen(pluginOptions = {}) {
54
57
  );
55
58
  middlewareOptions.isOxygen = !!oxygenPlugin;
56
59
  oxygenPlugin?.api?.registerPluginOptions?.({
57
- shouldStartRuntime: () => !isRemixChildCompiler(resolvedConfig),
58
60
  requestHook: ({ request, response, meta }) => {
59
61
  emitRequestEvent(
60
62
  {
@@ -112,15 +114,16 @@ function hydrogen(pluginOptions = {}) {
112
114
  ]
113
115
  });
114
116
  },
115
- configureServer(viteDevServer) {
116
- if (isRemixChildCompiler(viteDevServer.config))
117
- return;
118
- return () => {
119
- setupHydrogenMiddleware(
120
- viteDevServer,
121
- mergeOptions(pluginOptions, middlewareOptions)
122
- );
123
- };
117
+ configureServer: {
118
+ order: "pre",
119
+ handler: (viteDevServer) => {
120
+ return () => {
121
+ setupHydrogenMiddleware(
122
+ viteDevServer,
123
+ mergeOptions(pluginOptions, middlewareOptions)
124
+ );
125
+ };
126
+ }
124
127
  }
125
128
  }
126
129
  ];
@@ -1,10 +1,11 @@
1
1
  import path from "node:path";
2
2
  import { EventEmitter } from "node:events";
3
3
  import { mapSourcePosition } from "source-map-support";
4
- const DEV_ROUTES = /* @__PURE__ */ new Set([
4
+ const IGNORED_ROUTES = /* @__PURE__ */ new Set([
5
5
  "/graphiql",
6
6
  "/subrequest-profiler",
7
- "/debug-network-server"
7
+ "/debug-network-server",
8
+ "/favicon.ico"
8
9
  ]);
9
10
  const EVENT_MAP = {
10
11
  request: "Request",
@@ -32,7 +33,7 @@ function emitRequestEvent(payload, root) {
32
33
  }
33
34
  delete payload.__fromVite;
34
35
  const { pathname } = new URL(payload.url, "http://localhost");
35
- if (DEV_ROUTES.has(pathname))
36
+ if (IGNORED_ROUTES.has(pathname))
36
37
  return;
37
38
  const {
38
39
  url: descriptionUrl,
@@ -2,7 +2,6 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useLoaderData } from "@remix-run/react";
3
3
  import { HydrogenLogoBaseBW } from "../components/HydrogenLogoBaseBW.jsx";
4
4
  import { HydrogenLogoBaseColor } from "../components/HydrogenLogoBaseColor.jsx";
5
- import { IconDiscord } from "../components/IconDiscord.jsx";
6
5
  import { IconGithub } from "../components/IconGithub.jsx";
7
6
  import { IconTwitter } from "../components/IconTwitter.jsx";
8
7
  import { IconBanner } from "../components/IconBanner.jsx";
@@ -218,15 +217,6 @@ function Layout({
218
217
  /* @__PURE__ */ jsx("h1", { children: shopName?.toUpperCase() }),
219
218
  /* @__PURE__ */ jsx("p", { children: "\xA0Dev Mode\xA0" }),
220
219
  /* @__PURE__ */ jsxs("nav", { children: [
221
- /* @__PURE__ */ jsx(
222
- "a",
223
- {
224
- target: "_blank",
225
- rel: "norefferer noopener",
226
- href: "https://discord.com/invite/shopifydevs",
227
- children: /* @__PURE__ */ jsx(IconDiscord, {})
228
- }
229
- ),
230
220
  /* @__PURE__ */ jsx(
231
221
  "a",
232
222
  {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "@shopify:registry": "https://registry.npmjs.org"
6
6
  },
7
7
  "type": "module",
8
- "version": "2024.4.2",
8
+ "version": "2024.4.4",
9
9
  "license": "MIT",
10
10
  "main": "dist/index.cjs",
11
11
  "module": "dist/production/index.js",
@@ -63,21 +63,23 @@
63
63
  "dist"
64
64
  ],
65
65
  "dependencies": {
66
- "@shopify/hydrogen-react": "2024.4.2",
66
+ "@shopify/hydrogen-react": "2024.4.3",
67
67
  "content-security-policy-builder": "^2.2.0",
68
68
  "type-fest": "^4.5.0",
69
69
  "source-map-support": "^0.5.21",
70
- "tiny-invariant": "^1.3.1",
71
- "use-resize-observer": "^9.1.0"
70
+ "use-resize-observer": "^9.1.0",
71
+ "worktop": "^0.7.3"
72
72
  },
73
73
  "devDependencies": {
74
- "@remix-run/react": "^2.8.0",
75
- "@remix-run/server-runtime": "^2.8.0",
74
+ "@remix-run/dev": "^2.9.2",
75
+ "@remix-run/react": "^2.9.2",
76
+ "@remix-run/server-runtime": "^2.9.2",
76
77
  "@shopify/generate-docs": "0.11.1",
77
78
  "@shopify/hydrogen-codegen": "*",
78
79
  "@testing-library/jest-dom": "^5.17.0",
79
80
  "@testing-library/react": "^14.0.0",
80
81
  "@types/source-map-support": "^0.5.10",
82
+ "formdata-polyfill": "^4.0.10",
81
83
  "happy-dom": "^8.9.0",
82
84
  "react": "^18.2.0",
83
85
  "schema-dts": "^1.1.0",
@@ -1,21 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- const IconDiscord = (props) => /* @__PURE__ */ jsx(
3
- "svg",
4
- {
5
- width: 26,
6
- height: 20,
7
- fill: "none",
8
- xmlns: "http://www.w3.org/2000/svg",
9
- ...props,
10
- children: /* @__PURE__ */ jsx(
11
- "path",
12
- {
13
- d: "M21.19 1.675A19.91 19.91 0 0 0 16.03 0c-.223.415-.482.973-.661 1.418a18.355 18.355 0 0 0-5.72 0A15.367 15.367 0 0 0 8.98 0a19.844 19.844 0 0 0-5.165 1.68C.55 6.776-.336 11.747.106 16.647c2.167 1.67 4.266 2.686 6.33 3.35.51-.724.964-1.495 1.356-2.306a13.149 13.149 0 0 1-2.135-1.073c.179-.137.354-.28.523-.428 4.116 1.989 8.588 1.989 12.655 0 .172.148.347.291.524.428a13.12 13.12 0 0 1-2.139 1.075c.392.81.844 1.582 1.356 2.306 2.066-.664 4.167-1.68 6.333-3.352.52-5.68-.887-10.606-3.718-14.973ZM8.353 13.635c-1.235 0-2.249-1.192-2.249-2.643 0-1.45.992-2.644 2.25-2.644 1.257 0 2.27 1.191 2.248 2.644.002 1.45-.991 2.642-2.249 2.642Zm8.311 0c-1.235 0-2.249-1.192-2.249-2.643 0-1.45.992-2.644 2.25-2.644 1.257 0 2.27 1.191 2.248 2.644 0 1.45-.991 2.642-2.249 2.642Z",
14
- fill: "#5C5F62"
15
- }
16
- )
17
- }
18
- );
19
- export {
20
- IconDiscord
21
- };