@shopify/cli-hydrogen 10.0.2 → 11.0.0

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.
Files changed (74) hide show
  1. package/dist/assets/hydrogen/starter/.cursor/rules/hydrogen-react-router.mdc +50 -0
  2. package/dist/assets/hydrogen/starter/CHANGELOG.md +10 -14
  3. package/dist/assets/hydrogen/starter/app/components/AddToCartButton.tsx +1 -1
  4. package/dist/assets/hydrogen/starter/app/components/CartLineItem.tsx +1 -1
  5. package/dist/assets/hydrogen/starter/app/components/CartMain.tsx +1 -1
  6. package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +1 -1
  7. package/dist/assets/hydrogen/starter/app/components/Footer.tsx +1 -1
  8. package/dist/assets/hydrogen/starter/app/components/Header.tsx +1 -1
  9. package/dist/assets/hydrogen/starter/app/components/PageLayout.tsx +1 -1
  10. package/dist/assets/hydrogen/starter/app/components/ProductForm.tsx +1 -1
  11. package/dist/assets/hydrogen/starter/app/components/ProductItem.tsx +1 -1
  12. package/dist/assets/hydrogen/starter/app/components/SearchForm.tsx +1 -1
  13. package/dist/assets/hydrogen/starter/app/components/SearchFormPredictive.tsx +1 -6
  14. package/dist/assets/hydrogen/starter/app/components/SearchResults.tsx +1 -1
  15. package/dist/assets/hydrogen/starter/app/components/SearchResultsPredictive.tsx +1 -1
  16. package/dist/assets/hydrogen/starter/app/entry.client.tsx +2 -2
  17. package/dist/assets/hydrogen/starter/app/entry.server.tsx +9 -4
  18. package/dist/assets/hydrogen/starter/app/lib/variants.ts +1 -1
  19. package/dist/assets/hydrogen/starter/app/root.tsx +1 -1
  20. package/dist/assets/hydrogen/starter/app/routes/_index.tsx +1 -1
  21. package/dist/assets/hydrogen/starter/app/routes/account.addresses.tsx +1 -1
  22. package/dist/assets/hydrogen/starter/app/routes/account.orders.$id.tsx +4 -4
  23. package/dist/assets/hydrogen/starter/app/routes/account.orders._index.tsx +1 -1
  24. package/dist/assets/hydrogen/starter/app/routes/account.profile.tsx +1 -7
  25. package/dist/assets/hydrogen/starter/app/routes/account.tsx +1 -1
  26. package/dist/assets/hydrogen/starter/app/routes/api.$version.[graphql.json].tsx +14 -0
  27. package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle.$articleHandle.tsx +1 -1
  28. package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle._index.tsx +1 -1
  29. package/dist/assets/hydrogen/starter/app/routes/blogs._index.tsx +1 -1
  30. package/dist/assets/hydrogen/starter/app/routes/cart.tsx +7 -2
  31. package/dist/assets/hydrogen/starter/app/routes/collections.$handle.tsx +1 -1
  32. package/dist/assets/hydrogen/starter/app/routes/collections._index.tsx +1 -1
  33. package/dist/assets/hydrogen/starter/app/routes/collections.all.tsx +2 -2
  34. package/dist/assets/hydrogen/starter/app/routes/pages.$handle.tsx +1 -1
  35. package/dist/assets/hydrogen/starter/app/routes/policies.$handle.tsx +1 -1
  36. package/dist/assets/hydrogen/starter/app/routes/policies._index.tsx +1 -1
  37. package/dist/assets/hydrogen/starter/app/routes/products.$handle.tsx +1 -1
  38. package/dist/assets/hydrogen/starter/app/routes/search.tsx +1 -1
  39. package/dist/assets/hydrogen/starter/app/routes.ts +2 -2
  40. package/dist/assets/hydrogen/starter/env.d.ts +12 -2
  41. package/dist/assets/hydrogen/starter/eslint.config.js +2 -0
  42. package/dist/assets/hydrogen/starter/package.json +10 -11
  43. package/dist/assets/hydrogen/starter/react-router.config.ts +7 -0
  44. package/dist/assets/hydrogen/starter/server.ts +2 -5
  45. package/dist/assets/hydrogen/starter/tsconfig.json +18 -6
  46. package/dist/assets/hydrogen/starter/vite.config.ts +2 -23
  47. package/dist/assets/hydrogen/virtual-routes/components/RequestDetails.jsx +1 -1
  48. package/dist/assets/hydrogen/virtual-routes/layout.jsx +1 -7
  49. package/dist/assets/hydrogen/virtual-routes/routes/index.jsx +1 -1
  50. package/dist/assets/hydrogen/virtual-routes/routes/subrequest-profiler.jsx +1 -1
  51. package/dist/assets/hydrogen/virtual-routes/virtual-root-with-layout.jsx +1 -1
  52. package/dist/assets/hydrogen/virtual-routes/virtual-root.jsx +1 -1
  53. package/dist/assets/hydrogen/vite/vite.config.js +1 -1
  54. package/dist/commands/hydrogen/build.js +7 -3
  55. package/dist/commands/hydrogen/debug/cpu.js +5 -9
  56. package/dist/commands/hydrogen/deploy.js +5 -4
  57. package/dist/commands/hydrogen/dev.js +10 -17
  58. package/dist/commands/hydrogen/preview.js +16 -27
  59. package/dist/commands/hydrogen/upgrade.js +42 -0
  60. package/dist/hooks/init.js +1 -1
  61. package/dist/index.d.ts +0 -3
  62. package/dist/lib/codegen.js +17 -3
  63. package/dist/lib/flags.js +0 -6
  64. package/dist/lib/mini-oxygen/index.js +1 -6
  65. package/dist/lib/onboarding/common.js +1 -0
  66. package/dist/lib/remix-config.js +7 -132
  67. package/dist/lib/setups/routes/generate.js +2 -1
  68. package/dist/lib/vite-config.js +13 -9
  69. package/oclif.manifest.json +3 -23
  70. package/package.json +4 -4
  71. package/dist/lib/classic-compiler/build.js +0 -139
  72. package/dist/lib/classic-compiler/debug-cpu.js +0 -52
  73. package/dist/lib/classic-compiler/dev.js +0 -280
  74. package/dist/lib/virtual-routes.js +0 -49
@@ -1,15 +1,11 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import path from 'node:path';
3
- import { readdir } from 'node:fs/promises';
3
+ import 'node:fs/promises';
4
4
  import { AbortError } from '@shopify/cli-kit/node/error';
5
- import { outputWarn } from '@shopify/cli-kit/node/output';
6
- import { fileExists } from '@shopify/cli-kit/node/fs';
7
- import { muteRemixLogs } from './log.js';
5
+ import '@shopify/cli-kit/node/fs';
8
6
  import { REQUIRED_REMIX_VERSION } from './remix-version-check.js';
9
7
  import { findFileWithExtension } from './file.js';
10
- import { isViteProject, getViteConfig } from './vite-config.js';
11
- import { importLocal, importVite } from './import-utils.js';
12
- import { isHydrogenMonorepo, hydrogenPackagesPath } from './build.js';
8
+ import { isViteProject, REMIX_COMPILER_ERROR_MESSAGE, getViteConfig } from './vite-config.js';
13
9
 
14
10
  async function hasRemixConfigFile(root) {
15
11
  const result = await findFileWithExtension(root, "remix.config");
@@ -23,7 +19,6 @@ async function isClassicProject(root) {
23
19
  const BUILD_DIR = "dist";
24
20
  const CLIENT_SUBDIR = "client";
25
21
  const WORKER_SUBDIR = "worker";
26
- const oxygenServerMainFields = ["browser", "module", "main"];
27
22
  function getProjectPaths(appPath) {
28
23
  const root = appPath ?? process.cwd();
29
24
  const publicPath = path.join(root, "public");
@@ -52,130 +47,10 @@ function getRawRemixConfig(root) {
52
47
  });
53
48
  }
54
49
  async function getRemixConfig(root, mode = process.env.NODE_ENV) {
55
- if (await isViteProject(root)) {
56
- return (await getViteConfig(root)).remixConfig;
57
- }
58
- await muteRemixLogs(root);
59
- const { resolveConfig } = await importLocal(
60
- "@remix-run/dev/dist/config.js",
61
- root
62
- ).catch(handleRemixImportFail);
63
- const { createContext } = await importLocal(
64
- "@remix-run/dev/dist/vite/vite-node.js",
65
- root
66
- ).catch(handleRemixImportFail);
67
- const appConfig = await getRawRemixConfig(root);
68
- const routesViteNodeContext = await createContext({ root, mode });
69
- const vite = await importVite(root);
70
- const config = await resolveConfig(appConfig, {
71
- rootDirectory: root,
72
- serverMode: mode,
73
- vite,
74
- routesViteNodeContext
75
- });
76
- if (isHydrogenMonorepo && hydrogenPackagesPath) {
77
- const packagesPath = hydrogenPackagesPath;
78
- config.watchPaths ??= [];
79
- config.watchPaths.push(
80
- ...(await readdir(packagesPath)).map(
81
- (pkg) => pkg === "hydrogen-react" ? path.resolve(packagesPath, pkg, "dist", "browser-dev", "index.mjs") : path.resolve(packagesPath, pkg, "dist", "development", "index.js")
82
- )
83
- );
84
- config.watchPaths.push(
85
- path.join(packagesPath, "cli", "dist", "virtual-routes", "**", "*")
86
- );
87
- }
88
- routesViteNodeContext.server.server.close();
89
- return config;
90
- }
91
- function assertOxygenChecks(config) {
92
- try {
93
- createRequire(import.meta.url).resolve("@shopify/remix-oxygen");
94
- } catch {
95
- return;
96
- }
97
- if (!config.serverEntryPoint) {
98
- throw new AbortError(
99
- "Could not find a server entry point.",
100
- "Please add a server option to your remix.config.js pointing to an Oxygen worker entry file."
101
- );
102
- } else {
103
- assertEntryFileExists(config.rootDirectory, config.serverEntryPoint);
104
- }
105
- if (config.serverPlatform !== "neutral") {
106
- throw new AbortError(
107
- 'The serverPlatform in remix.config.js must be "neutral".'
108
- );
109
- }
110
- if (config.serverModuleFormat !== "esm") {
111
- throw new AbortError(
112
- 'The serverModuleFormat in remix.config.js must be "esm".'
113
- );
114
- }
115
- if (config.serverDependenciesToBundle !== "all") {
116
- throw new AbortError(
117
- 'The serverDependenciesToBundle in remix.config.js must be "all".'
118
- );
119
- }
120
- if (!config.serverConditions?.includes("worker")) {
121
- throw new AbortError(
122
- 'The serverConditions in remix.config.js must include "worker".'
123
- );
124
- }
125
- if (process.env.NODE_ENV === "development" && !config.serverConditions?.includes("development")) {
126
- outputWarn(
127
- "Add `process.env.NODE_ENV` value to serverConditions in remix.config.js to enable debugging features in development."
128
- );
129
- }
130
- if (!config.serverMainFields || !oxygenServerMainFields.every((v, i) => config.serverMainFields?.[i] === v)) {
131
- throw new AbortError(
132
- `The serverMainFields in remix.config.js must be ${JSON.stringify(
133
- oxygenServerMainFields
134
- )}.`
135
- );
136
- }
137
- const cdnUrl = process.env.HYDROGEN_ASSET_BASE_URL;
138
- if (cdnUrl && !config.publicPath.startsWith(cdnUrl)) {
139
- throw new AbortError(
140
- "The publicPath in remix.config.js must be prepended with the value of `process.env.HYDROGEN_ASSET_BASE_URL`."
141
- );
142
- }
143
- const expectedServerBuildPath = path.join(
144
- BUILD_DIR,
145
- WORKER_SUBDIR,
146
- "index.js"
147
- );
148
- if (config.serverBuildPath !== path.resolve(config.rootDirectory, expectedServerBuildPath)) {
149
- throw new AbortError(
150
- `The serverBuildPath in remix.config.js must be "${expectedServerBuildPath}".`
151
- );
152
- }
153
- const expectedAssetsBuildDirectory = path.join(BUILD_DIR, CLIENT_SUBDIR);
154
- if (!config.assetsBuildDirectory.startsWith(
155
- path.resolve(config.rootDirectory, expectedAssetsBuildDirectory)
156
- )) {
157
- throw new AbortError(
158
- `The assetsBuildDirectory in remix.config.js must be in "${expectedAssetsBuildDirectory}".`
159
- );
160
- }
161
- }
162
- async function assertEntryFileExists(root, fileRelative) {
163
- const fileAbsolute = path.resolve(root, fileRelative);
164
- const exists = await fileExists(fileAbsolute);
165
- if (!exists) {
166
- if (!path.extname(fileAbsolute)) {
167
- const files = await readdir(path.dirname(fileAbsolute));
168
- const exists2 = files.some((file) => {
169
- const { name, ext } = path.parse(file);
170
- return name === path.basename(fileAbsolute) && /^\.[jt]s$/.test(ext);
171
- });
172
- if (exists2) return;
173
- }
174
- throw new AbortError(
175
- `Entry file "${fileRelative}" not found.`,
176
- "Please ensure the file exists and that the path is correctly added to the `server` property in remix.config.js."
177
- );
50
+ if (!await isViteProject(root)) {
51
+ throw new AbortError(REMIX_COMPILER_ERROR_MESSAGE);
178
52
  }
53
+ return (await getViteConfig(root)).remixConfig;
179
54
  }
180
55
 
181
- export { assertOxygenChecks, getProjectPaths, getRawRemixConfig, getRemixConfig, handleRemixImportFail, hasRemixConfigFile, isClassicProject };
56
+ export { getProjectPaths, getRawRemixConfig, getRemixConfig, handleRemixImportFail, hasRemixConfigFile, isClassicProject };
@@ -22,7 +22,8 @@ const ROUTE_MAP = {
22
22
  account: "account*",
23
23
  search: ["search", "api.predictive-search"],
24
24
  robots: "[robots.txt]",
25
- sitemap: ["[sitemap.xml]", "sitemap.$type.$page[.xml]"]
25
+ sitemap: ["[sitemap.xml]", "sitemap.$type.$page[.xml]"],
26
+ tokenlessApi: "api.$version.[graphql.json]"
26
27
  };
27
28
  let allRouteTemplateFiles = [];
28
29
  async function getResolvedRoutes(routeKeys = Object.keys(ROUTE_MAP)) {
@@ -4,6 +4,7 @@ import { importVite } from './import-utils.js';
4
4
  import { hasRemixConfigFile } from './remix-config.js';
5
5
  import { renderWarning } from '@shopify/cli-kit/node/ui';
6
6
 
7
+ const REMIX_COMPILER_ERROR_MESSAGE = "Classic Remix Compiler projects are no longer supported, please upgrade to Vite by running 'npx shopify hydrogen setup vite'";
7
8
  async function hasViteConfig(root) {
8
9
  const result = await findFileWithExtension(root, "vite.config");
9
10
  return !!result.filepath;
@@ -57,8 +58,8 @@ async function getViteConfig(root, ssrEntryFlag) {
57
58
  resolvedViteConfig,
58
59
  userViteConfig: maybeConfig.config,
59
60
  remixConfig: {
60
- routes: routes ?? {},
61
- appDirectory: appDirectory ?? joinPath(resolvedViteConfig.root, "app"),
61
+ routes,
62
+ appDirectory,
62
63
  rootDirectory: resolvedViteConfig.root,
63
64
  serverEntryPoint: (await findFileWithExtension(
64
65
  dirname(resolvedSsrEntry),
@@ -68,12 +69,15 @@ async function getViteConfig(root, ssrEntryFlag) {
68
69
  };
69
70
  }
70
71
  function getRemixConfigFromVite(viteConfig) {
71
- const { remixConfig } = findHydrogenPlugin(viteConfig)?.api?.getPluginOptions() ?? {};
72
- return remixConfig ? {
73
- appDirectory: remixConfig.appDirectory,
74
- serverBuildFile: remixConfig.serverBuildFile,
75
- routes: remixConfig.routes
76
- } : {};
72
+ if (!viteConfig.__reactRouterPluginContext) {
73
+ throw new Error("Could not resolve React Router config");
74
+ }
75
+ const { appDirectory, serverBuildFile, routes } = viteConfig.__reactRouterPluginContext.reactRouterConfig;
76
+ return {
77
+ appDirectory,
78
+ serverBuildFile,
79
+ routes
80
+ };
77
81
  }
78
82
  function findPlugin(config, name) {
79
83
  return config.plugins.find((plugin) => plugin.name === name);
@@ -85,4 +89,4 @@ function findOxygenPlugin(config) {
85
89
  return findPlugin(config, "oxygen:main");
86
90
  }
87
91
 
88
- export { findHydrogenPlugin, findOxygenPlugin, getViteConfig, hasViteConfig, isViteProject };
92
+ export { REMIX_COMPILER_ERROR_MESSAGE, findHydrogenPlugin, findOxygenPlugin, getViteConfig, hasViteConfig, isViteProject };
@@ -668,20 +668,6 @@
668
668
  "name": "disable-deps-optimizer",
669
669
  "allowNo": false,
670
670
  "type": "boolean"
671
- },
672
- "legacy-runtime": {
673
- "description": "[Classic Remix Compiler] Runs the app in a Node.js sandbox instead of an Oxygen worker.",
674
- "env": "SHOPIFY_HYDROGEN_FLAG_LEGACY_RUNTIME",
675
- "name": "legacy-runtime",
676
- "allowNo": false,
677
- "type": "boolean"
678
- },
679
- "sourcemap": {
680
- "description": "[Classic Remix Compiler] Controls whether server sourcemaps are generated. Default to `true`. Deactivate `--no-sourcemaps`.",
681
- "env": "SHOPIFY_HYDROGEN_FLAG_SOURCEMAP",
682
- "name": "sourcemap",
683
- "allowNo": true,
684
- "type": "boolean"
685
671
  }
686
672
  },
687
673
  "hasDynamicHelp": false,
@@ -880,7 +866,7 @@
880
866
  "aliases": [],
881
867
  "args": {
882
868
  "routeName": {
883
- "description": "The route to generate. One of home,page,cart,products,collections,policies,blogs,account,search,robots,sitemap,all.",
869
+ "description": "The route to generate. One of home,page,cart,products,collections,policies,blogs,account,search,robots,sitemap,tokenlessApi,all.",
884
870
  "name": "routeName",
885
871
  "options": [
886
872
  "home",
@@ -894,6 +880,7 @@
894
880
  "search",
895
881
  "robots",
896
882
  "sitemap",
883
+ "tokenlessApi",
897
884
  "all"
898
885
  ],
899
886
  "required": true
@@ -1318,13 +1305,6 @@
1318
1305
  "multiple": false,
1319
1306
  "type": "option"
1320
1307
  },
1321
- "legacy-runtime": {
1322
- "description": "Runs the app in a Node.js sandbox instead of an Oxygen worker.",
1323
- "env": "SHOPIFY_HYDROGEN_FLAG_LEGACY_RUNTIME",
1324
- "name": "legacy-runtime",
1325
- "allowNo": false,
1326
- "type": "boolean"
1327
- },
1328
1308
  "env": {
1329
1309
  "description": "Specifies the environment to perform the operation using its handle. Fetch the handle using the `env list` command.",
1330
1310
  "exclusive": [
@@ -1748,5 +1728,5 @@
1748
1728
  ]
1749
1729
  }
1750
1730
  },
1751
- "version": "10.0.2"
1731
+ "version": "11.0.0"
1752
1732
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "@shopify:registry": "https://registry.npmjs.org"
6
6
  },
7
- "version": "10.0.2",
7
+ "version": "11.0.0",
8
8
  "license": "MIT",
9
9
  "type": "module",
10
10
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "test:watch": "cross-env SHOPIFY_UNIT_TEST=1 LANG=en-US.UTF-8 vitest --test-timeout=60000"
22
22
  },
23
23
  "devDependencies": {
24
- "@remix-run/dev": "^2.16.1",
24
+ "@react-router/dev": "7.6.0",
25
25
  "@types/diff": "^5.0.2",
26
26
  "@types/gunzip-maybe": "^1.4.0",
27
27
  "@types/prettier": "^2.7.2",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@graphql-codegen/cli": "^5.0.2",
63
- "@remix-run/dev": "^2.16.1",
63
+ "@react-router/dev": "7.6.0",
64
64
  "@shopify/hydrogen-codegen": "^0.3.3",
65
65
  "@shopify/mini-oxygen": "^3.2.1",
66
66
  "graphql-config": "^5.0.3",
@@ -70,7 +70,7 @@
70
70
  "@graphql-codegen/cli": {
71
71
  "optional": true
72
72
  },
73
- "@remix-run/dev": {
73
+ "@react-router/dev": {
74
74
  "optional": true
75
75
  },
76
76
  "@shopify/hydrogen-codegen": {
@@ -1,139 +0,0 @@
1
- import { outputInfo, outputToken, outputContent, outputWarn } from '@shopify/cli-kit/node/output';
2
- import { rmdir, fileSize, glob, readFile, writeFile, fileExists, copyFile } from '@shopify/cli-kit/node/fs';
3
- import { relativePath, joinPath } from '@shopify/cli-kit/node/path';
4
- import { getPackageManager } from '@shopify/cli-kit/node/node-package-manager';
5
- import colors from '@shopify/cli-kit/node/colors';
6
- import { getProjectPaths, getRemixConfig, handleRemixImportFail, assertOxygenChecks } from '../remix-config.js';
7
- import { checkLockfileStatus } from '../check-lockfile.js';
8
- import { findMissingRoutes } from '../route-validator.js';
9
- import { muteRemixLogs, createRemixLogger } from '../log.js';
10
- import { codegen } from '../codegen.js';
11
- import { classicBuildBundleAnalysis, classicGetBundleAnalysisSummary } from '../bundle/analyzer.js';
12
- import { isCI } from '../is-ci.js';
13
- import { importLocal } from '../import-utils.js';
14
-
15
- const LOG_WORKER_BUILT = "\u{1F4E6} Worker built";
16
- const WORKER_BUILD_SIZE_LIMIT = 5;
17
- async function runClassicCompilerBuild({
18
- directory,
19
- useCodegen = false,
20
- codegenConfigPath,
21
- sourcemap = false,
22
- disableRouteWarning = false,
23
- bundleStats = true,
24
- lockfileCheck = true,
25
- assetPath
26
- }) {
27
- if (!process.env.NODE_ENV) {
28
- process.env.NODE_ENV = "production";
29
- }
30
- if (assetPath) {
31
- process.env.HYDROGEN_ASSET_BASE_URL = assetPath;
32
- }
33
- const { root, buildPath, buildPathClient, buildPathWorkerFile, publicPath } = getProjectPaths(directory);
34
- if (lockfileCheck) {
35
- await checkLockfileStatus(root, isCI());
36
- }
37
- await muteRemixLogs(root);
38
- console.time(LOG_WORKER_BUILT);
39
- outputInfo(`
40
- \u{1F3D7}\uFE0F Building in ${process.env.NODE_ENV} mode...`);
41
- const [remixConfig, [{ build }, { logThrown }, { createFileWatchCache }]] = await Promise.all([
42
- getRemixConfig(root),
43
- Promise.all([
44
- importLocal("@remix-run/dev/dist/compiler/build.js", root),
45
- importLocal(
46
- "@remix-run/dev/dist/compiler/utils/log.js",
47
- root
48
- ),
49
- importLocal(
50
- "@remix-run/dev/dist/compiler/fileWatchCache.js",
51
- root
52
- )
53
- ]).catch(handleRemixImportFail),
54
- rmdir(buildPath, { force: true })
55
- ]);
56
- assertOxygenChecks(remixConfig);
57
- await Promise.all([
58
- copyPublicFiles(publicPath, buildPathClient),
59
- build({
60
- config: remixConfig,
61
- options: {
62
- mode: process.env.NODE_ENV,
63
- sourcemap
64
- },
65
- logger: createRemixLogger(),
66
- fileWatchCache: createFileWatchCache()
67
- }).catch((thrown) => {
68
- logThrown(thrown);
69
- if (process.env.SHOPIFY_UNIT_TEST) {
70
- throw thrown;
71
- } else {
72
- process.exit(1);
73
- }
74
- }),
75
- useCodegen && codegen({ ...remixConfig, configFilePath: codegenConfigPath })
76
- ]);
77
- if (process.env.NODE_ENV !== "development") {
78
- console.timeEnd(LOG_WORKER_BUILT);
79
- const bundleAnalysisPath = await classicBuildBundleAnalysis(buildPath);
80
- const sizeMB = await fileSize(buildPathWorkerFile) / (1024 * 1024);
81
- const formattedSize = colors.yellow(sizeMB.toFixed(2) + " MB");
82
- outputInfo(
83
- outputContent` ${colors.dim(
84
- relativePath(root, buildPathWorkerFile)
85
- )} ${bundleAnalysisPath ? outputToken.link(formattedSize, bundleAnalysisPath) : formattedSize}\n`
86
- );
87
- if (bundleStats && bundleAnalysisPath) {
88
- outputInfo(
89
- outputContent`${await classicGetBundleAnalysisSummary(buildPathWorkerFile) || "\n"}\n │\n └─── ${outputToken.link(
90
- "Complete analysis: " + bundleAnalysisPath,
91
- bundleAnalysisPath
92
- )}\n\n`
93
- );
94
- }
95
- if (sizeMB >= WORKER_BUILD_SIZE_LIMIT) {
96
- outputWarn(
97
- `\u{1F6A8} Smaller worker bundles are faster to deploy and run.${remixConfig.serverMinify ? "" : "\n Minify your bundle by adding `serverMinify: true` to remix.config.js."}
98
- Learn more about optimizing your worker bundle file: https://h2o.fyi/debugging/bundle-size
99
- `
100
- );
101
- }
102
- }
103
- if (!disableRouteWarning) {
104
- const missingRoutes = findMissingRoutes(remixConfig);
105
- if (missingRoutes.length) {
106
- const packageManager = await getPackageManager(root);
107
- const exec = packageManager === "npm" ? "npx" : packageManager;
108
- outputWarn(
109
- `Heads up: Shopify stores have a number of standard routes that aren\u2019t set up yet.
110
- Some functionality and backlinks might not work as expected until these are created or redirects are set up.
111
- This build is missing ${missingRoutes.length} route${missingRoutes.length > 1 ? "s" : ""}. For more details, run \`${exec} shopify hydrogen check routes\`.
112
- `
113
- );
114
- }
115
- }
116
- if (process.env.NODE_ENV !== "development") {
117
- await cleanClientSourcemaps(buildPathClient);
118
- }
119
- }
120
- async function cleanClientSourcemaps(buildPathClient) {
121
- const bundleFiles = await glob(joinPath(buildPathClient, "**/*.js"));
122
- await Promise.all(
123
- bundleFiles.map(async (filePath) => {
124
- const file = await readFile(filePath);
125
- return await writeFile(
126
- filePath,
127
- file.replace(/\/\/# sourceMappingURL=.+\.js\.map$/gm, "")
128
- );
129
- })
130
- );
131
- }
132
- async function copyPublicFiles(publicPath, buildPathClient) {
133
- if (!await fileExists(publicPath)) {
134
- return;
135
- }
136
- return copyFile(publicPath, buildPathClient);
137
- }
138
-
139
- export { copyPublicFiles, runClassicCompilerBuild };
@@ -1,52 +0,0 @@
1
- import { outputWarn } from '@shopify/cli-kit/node/output';
2
- import { createRemixLogger } from '../log.js';
3
- import { importLocal } from '../import-utils.js';
4
- import { handleRemixImportFail, getRemixConfig } from '../remix-config.js';
5
-
6
- async function runClassicCompilerDebugCpu({
7
- directory,
8
- hooks
9
- }) {
10
- const [{ watch }, { createFileWatchCache }] = await Promise.all([
11
- importLocal("@remix-run/dev/dist/compiler/watch.js", directory),
12
- importLocal(
13
- "@remix-run/dev/dist/compiler/fileWatchCache.js",
14
- directory
15
- )
16
- ]).catch(handleRemixImportFail);
17
- const fileWatchCache = createFileWatchCache();
18
- const closeWatcher = await watch(
19
- {
20
- config: await getRemixConfig(directory),
21
- options: {
22
- mode: process.env.NODE_ENV,
23
- sourcemap: true
24
- },
25
- fileWatchCache,
26
- logger: createRemixLogger()
27
- },
28
- {
29
- onBuildStart: hooks.onServerBuildStart,
30
- async onBuildFinish(context, duration, succeeded) {
31
- if (succeeded) {
32
- await hooks.onServerBuildFinish();
33
- } else {
34
- outputWarn("\nBuild failed, waiting for changes to restart...");
35
- }
36
- },
37
- async onFileChanged(file) {
38
- fileWatchCache.invalidateFile(file);
39
- },
40
- async onFileDeleted(file) {
41
- fileWatchCache.invalidateFile(file);
42
- }
43
- }
44
- );
45
- return {
46
- async close() {
47
- await closeWatcher();
48
- }
49
- };
50
- }
51
-
52
- export { runClassicCompilerDebugCpu };