@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.
- package/dist/assets/hydrogen/starter/.cursor/rules/hydrogen-react-router.mdc +50 -0
- package/dist/assets/hydrogen/starter/CHANGELOG.md +10 -14
- package/dist/assets/hydrogen/starter/app/components/AddToCartButton.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/CartLineItem.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/CartMain.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/Footer.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/Header.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/PageLayout.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/ProductForm.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/ProductItem.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/SearchForm.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/SearchFormPredictive.tsx +1 -6
- package/dist/assets/hydrogen/starter/app/components/SearchResults.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/components/SearchResultsPredictive.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/entry.client.tsx +2 -2
- package/dist/assets/hydrogen/starter/app/entry.server.tsx +9 -4
- package/dist/assets/hydrogen/starter/app/lib/variants.ts +1 -1
- package/dist/assets/hydrogen/starter/app/root.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/_index.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/account.addresses.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/account.orders.$id.tsx +4 -4
- package/dist/assets/hydrogen/starter/app/routes/account.orders._index.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/account.profile.tsx +1 -7
- package/dist/assets/hydrogen/starter/app/routes/account.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/api.$version.[graphql.json].tsx +14 -0
- package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle.$articleHandle.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/blogs.$blogHandle._index.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/blogs._index.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/cart.tsx +7 -2
- package/dist/assets/hydrogen/starter/app/routes/collections.$handle.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/collections._index.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/collections.all.tsx +2 -2
- package/dist/assets/hydrogen/starter/app/routes/pages.$handle.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/policies.$handle.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/policies._index.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/products.$handle.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes/search.tsx +1 -1
- package/dist/assets/hydrogen/starter/app/routes.ts +2 -2
- package/dist/assets/hydrogen/starter/env.d.ts +12 -2
- package/dist/assets/hydrogen/starter/eslint.config.js +2 -0
- package/dist/assets/hydrogen/starter/package.json +10 -11
- package/dist/assets/hydrogen/starter/react-router.config.ts +7 -0
- package/dist/assets/hydrogen/starter/server.ts +2 -5
- package/dist/assets/hydrogen/starter/tsconfig.json +18 -6
- package/dist/assets/hydrogen/starter/vite.config.ts +2 -23
- package/dist/assets/hydrogen/virtual-routes/components/RequestDetails.jsx +1 -1
- package/dist/assets/hydrogen/virtual-routes/layout.jsx +1 -7
- package/dist/assets/hydrogen/virtual-routes/routes/index.jsx +1 -1
- package/dist/assets/hydrogen/virtual-routes/routes/subrequest-profiler.jsx +1 -1
- package/dist/assets/hydrogen/virtual-routes/virtual-root-with-layout.jsx +1 -1
- package/dist/assets/hydrogen/virtual-routes/virtual-root.jsx +1 -1
- package/dist/assets/hydrogen/vite/vite.config.js +1 -1
- package/dist/commands/hydrogen/build.js +7 -3
- package/dist/commands/hydrogen/debug/cpu.js +5 -9
- package/dist/commands/hydrogen/deploy.js +5 -4
- package/dist/commands/hydrogen/dev.js +10 -17
- package/dist/commands/hydrogen/preview.js +16 -27
- package/dist/commands/hydrogen/upgrade.js +42 -0
- package/dist/hooks/init.js +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/lib/codegen.js +17 -3
- package/dist/lib/flags.js +0 -6
- package/dist/lib/mini-oxygen/index.js +1 -6
- package/dist/lib/onboarding/common.js +1 -0
- package/dist/lib/remix-config.js +7 -132
- package/dist/lib/setups/routes/generate.js +2 -1
- package/dist/lib/vite-config.js +13 -9
- package/oclif.manifest.json +3 -23
- package/package.json +4 -4
- package/dist/lib/classic-compiler/build.js +0 -139
- package/dist/lib/classic-compiler/debug-cpu.js +0 -52
- package/dist/lib/classic-compiler/dev.js +0 -280
- package/dist/lib/virtual-routes.js +0 -49
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
"include": [
|
|
2
|
+
"include": [
|
|
3
|
+
"./**/*.d.ts",
|
|
4
|
+
"./**/*.ts",
|
|
5
|
+
"./**/*.tsx",
|
|
6
|
+
".react-router/types/**/*"
|
|
7
|
+
],
|
|
3
8
|
"compilerOptions": {
|
|
4
|
-
"lib": [
|
|
9
|
+
"lib": [
|
|
10
|
+
"DOM",
|
|
11
|
+
"DOM.Iterable",
|
|
12
|
+
"ES2022"
|
|
13
|
+
],
|
|
5
14
|
"isolatedModules": true,
|
|
6
15
|
"esModuleInterop": true,
|
|
7
16
|
"jsx": "react-jsx",
|
|
@@ -16,12 +25,15 @@
|
|
|
16
25
|
"baseUrl": ".",
|
|
17
26
|
"types": [
|
|
18
27
|
"@shopify/oxygen-workers-types",
|
|
19
|
-
"
|
|
28
|
+
"react-router",
|
|
20
29
|
"vite/client"
|
|
21
30
|
],
|
|
22
31
|
"paths": {
|
|
23
|
-
"~/*": [
|
|
32
|
+
"~/*": [
|
|
33
|
+
"app/*"
|
|
34
|
+
]
|
|
24
35
|
},
|
|
25
|
-
"noEmit": true
|
|
36
|
+
"noEmit": true,
|
|
37
|
+
"rootDirs": [".", "./.react-router/types"]
|
|
26
38
|
}
|
|
27
|
-
}
|
|
39
|
+
}
|
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
import {defineConfig} from 'vite';
|
|
2
2
|
import {hydrogen} from '@shopify/hydrogen/vite';
|
|
3
3
|
import {oxygen} from '@shopify/mini-oxygen/vite';
|
|
4
|
-
import {
|
|
4
|
+
import {reactRouter} from '@react-router/dev/vite';
|
|
5
5
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
6
6
|
|
|
7
|
-
declare module "@remix-run/server-runtime" {
|
|
8
|
-
interface Future {
|
|
9
|
-
v3_singleFetch: true;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
export default defineConfig({
|
|
14
|
-
plugins: [
|
|
15
|
-
hydrogen(),
|
|
16
|
-
oxygen(),
|
|
17
|
-
remix({
|
|
18
|
-
presets: [hydrogen.v3preset()],
|
|
19
|
-
future: {
|
|
20
|
-
v3_fetcherPersist: true,
|
|
21
|
-
v3_relativeSplatPath: true,
|
|
22
|
-
v3_throwAbortReason: true,
|
|
23
|
-
v3_lazyRouteDiscovery: true,
|
|
24
|
-
v3_routeConfig: true,
|
|
25
|
-
v3_singleFetch: true,
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
tsconfigPaths(),
|
|
29
|
-
],
|
|
8
|
+
plugins: [hydrogen(), oxygen(), reactRouter(), tsconfigPaths()],
|
|
30
9
|
build: {
|
|
31
10
|
// Allow a strict Content-Security-Policy
|
|
32
11
|
// withtout inlining assets as base64:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useRef } from "react";
|
|
3
|
-
import { Link } from "
|
|
3
|
+
import { Link } from "react-router";
|
|
4
4
|
import { IconClose } from "./IconClose.jsx";
|
|
5
5
|
import _useResizeObserver from "use-resize-observer";
|
|
6
6
|
const useResizeObserver = _useResizeObserver;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useNonce } from "@shopify/hydrogen";
|
|
3
|
-
import {
|
|
4
|
-
Links,
|
|
5
|
-
Meta,
|
|
6
|
-
Outlet,
|
|
7
|
-
Scripts,
|
|
8
|
-
ScrollRestoration
|
|
9
|
-
} from "@remix-run/react";
|
|
3
|
+
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "react-router";
|
|
10
4
|
import { Layout as VirtualLayout } from "./components/Layout.jsx";
|
|
11
5
|
import styles from "./assets/styles.css?url";
|
|
12
6
|
function Layout() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useLoaderData } from "
|
|
2
|
+
import { useLoaderData } from "react-router";
|
|
3
3
|
import { HydrogenLogoBaseBW } from "../components/HydrogenLogoBaseBW.jsx";
|
|
4
4
|
import { HydrogenLogoBaseColor } from "../components/HydrogenLogoBaseColor.jsx";
|
|
5
5
|
import { IconGithub } from "../components/IconGithub.jsx";
|
|
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
|
|
|
3
3
|
import { Script } from "@shopify/hydrogen";
|
|
4
4
|
import { RequestWaterfall } from "../components/RequestWaterfall.jsx";
|
|
5
5
|
import { RequestTable } from "../components/RequestTable.jsx";
|
|
6
|
-
import { Link } from "
|
|
6
|
+
import { Link } from "react-router";
|
|
7
7
|
import favicon from "../assets/favicon.svg";
|
|
8
8
|
import faviconDark from "../assets/favicon-dark.svg";
|
|
9
9
|
import { useDebugNetworkServer } from "../lib/useDebugNetworkServer.jsx";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ScrollRestoration,
|
|
8
8
|
isRouteErrorResponse,
|
|
9
9
|
useRouteError
|
|
10
|
-
} from "
|
|
10
|
+
} from "react-router";
|
|
11
11
|
import favicon from "./assets/favicon.svg";
|
|
12
12
|
import { Layout as VirtualLayout } from "./components/Layout.jsx";
|
|
13
13
|
import { useNonce } from "@shopify/hydrogen";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ScrollRestoration,
|
|
8
8
|
isRouteErrorResponse,
|
|
9
9
|
useRouteError
|
|
10
|
-
} from "
|
|
10
|
+
} from "react-router";
|
|
11
11
|
import favicon from "./assets/favicon.svg";
|
|
12
12
|
import { Layout as VirtualLayout } from "./components/Layout.jsx";
|
|
13
13
|
import { useNonce } from "@shopify/hydrogen";
|
|
@@ -6,10 +6,9 @@ import { removeFile, fileSize } from '@shopify/cli-kit/node/fs';
|
|
|
6
6
|
import { getPackageManager } from '@shopify/cli-kit/node/node-package-manager';
|
|
7
7
|
import { commonFlags, flagsToCamelObject } from '../../lib/flags.js';
|
|
8
8
|
import { prepareDiffDirectory } from '../../lib/template-diff.js';
|
|
9
|
-
import { isViteProject, getViteConfig } from '../../lib/vite-config.js';
|
|
9
|
+
import { isViteProject, REMIX_COMPILER_ERROR_MESSAGE, getViteConfig } from '../../lib/vite-config.js';
|
|
10
10
|
import { checkLockfileStatus } from '../../lib/check-lockfile.js';
|
|
11
11
|
import { findMissingRoutes, warnReservedRoutes, findReservedRoutes } from '../../lib/route-validator.js';
|
|
12
|
-
import { runClassicCompilerBuild } from '../../lib/classic-compiler/build.js';
|
|
13
12
|
import { hydrogenBundleAnalyzer } from '../../lib/bundle/vite-plugin.js';
|
|
14
13
|
import { BUNDLE_ANALYZER_HTML_FILE, getBundleAnalysisSummary } from '../../lib/bundle/analyzer.js';
|
|
15
14
|
import { spawnCodegenProcess, codegen } from '../../lib/codegen.js';
|
|
@@ -17,6 +16,7 @@ import { isCI } from '../../lib/is-ci.js';
|
|
|
17
16
|
import { importVite } from '../../lib/import-utils.js';
|
|
18
17
|
import { deferPromise } from '../../lib/defer.js';
|
|
19
18
|
import { setupResourceCleanup } from '../../lib/resource-cleanup.js';
|
|
19
|
+
import { AbortError } from '@shopify/cli-kit/node/error';
|
|
20
20
|
|
|
21
21
|
class Build extends Command {
|
|
22
22
|
static descriptionWithMarkdown = `Builds a Hydrogen storefront for production. The client and app worker files are compiled to a \`/dist\` folder in your Hydrogen project directory.`;
|
|
@@ -52,7 +52,11 @@ class Build extends Command {
|
|
|
52
52
|
useCodegen: flags.codegen,
|
|
53
53
|
directory
|
|
54
54
|
};
|
|
55
|
-
const
|
|
55
|
+
const isVite = await isViteProject(directory);
|
|
56
|
+
if (!isVite) {
|
|
57
|
+
throw new AbortError(REMIX_COMPILER_ERROR_MESSAGE);
|
|
58
|
+
}
|
|
59
|
+
const result = await runBuild(buildParams);
|
|
56
60
|
if (buildParams.watch) {
|
|
57
61
|
if (diff || result?.close) {
|
|
58
62
|
setupResourceCleanup(async () => {
|
|
@@ -9,11 +9,11 @@ import { getProjectPaths, isClassicProject } from '../../../lib/remix-config.js'
|
|
|
9
9
|
import { muteDevLogs } from '../../../lib/log.js';
|
|
10
10
|
import { commonFlags, flagsToCamelObject } from '../../../lib/flags.js';
|
|
11
11
|
import { prepareDiffDirectory } from '../../../lib/template-diff.js';
|
|
12
|
-
import { runClassicCompilerDebugCpu } from '../../../lib/classic-compiler/debug-cpu.js';
|
|
13
12
|
import { setupResourceCleanup } from '../../../lib/resource-cleanup.js';
|
|
14
13
|
import { createCpuStartupProfiler } from '../../../lib/cpu-profiler.js';
|
|
15
14
|
import { runBuild } from '../build.js';
|
|
16
|
-
import { getViteConfig } from '../../../lib/vite-config.js';
|
|
15
|
+
import { REMIX_COMPILER_ERROR_MESSAGE, getViteConfig } from '../../../lib/vite-config.js';
|
|
16
|
+
import { AbortError } from '@shopify/cli-kit/node/error';
|
|
17
17
|
|
|
18
18
|
const DEFAULT_OUTPUT_PATH = "startup.cpuprofile";
|
|
19
19
|
class DebugCpu extends Command {
|
|
@@ -79,13 +79,9 @@ ${colors.dim(output)}`
|
|
|
79
79
|
Waiting for changes...`);
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
output,
|
|
86
|
-
buildPathWorkerFile,
|
|
87
|
-
hooks
|
|
88
|
-
});
|
|
82
|
+
const isClassicCompiler = await isClassicProject(directory);
|
|
83
|
+
if (isClassicCompiler) {
|
|
84
|
+
throw new AbortError(REMIX_COMPILER_ERROR_MESSAGE);
|
|
89
85
|
}
|
|
90
86
|
const maybeViteConfig = await getViteConfig(directory).catch(() => null);
|
|
91
87
|
buildPathWorkerFile = maybeViteConfig?.serverOutFile ?? joinPath(buildPath, "server", "index.js");
|
|
@@ -15,9 +15,8 @@ import { findEnvironmentOrThrow, findEnvironmentByBranchOrThrow, orderEnvironmen
|
|
|
15
15
|
import { execAsync } from '../../lib/process.js';
|
|
16
16
|
import { commonFlags, overrideFlag, flagsToCamelObject } from '../../lib/flags.js';
|
|
17
17
|
import { getOxygenDeploymentData } from '../../lib/get-oxygen-deployment-data.js';
|
|
18
|
-
import { runClassicCompilerBuild } from '../../lib/classic-compiler/build.js';
|
|
19
18
|
import { runBuild } from './build.js';
|
|
20
|
-
import { getViteConfig } from '../../lib/vite-config.js';
|
|
19
|
+
import { getViteConfig, REMIX_COMPILER_ERROR_MESSAGE } from '../../lib/vite-config.js';
|
|
21
20
|
import { prepareDiffDirectory } from '../../lib/template-diff.js';
|
|
22
21
|
import { isClassicProject, getProjectPaths } from '../../lib/remix-config.js';
|
|
23
22
|
import { packageManagers } from '../../lib/package-managers.js';
|
|
@@ -441,8 +440,10 @@ Continue?`.value
|
|
|
441
440
|
outputInfo(
|
|
442
441
|
outputContent`${colors.whiteBright("Building project...")}`.value
|
|
443
442
|
);
|
|
444
|
-
|
|
445
|
-
|
|
443
|
+
if (isClassicCompiler) {
|
|
444
|
+
throw new AbortError(REMIX_COMPILER_ERROR_MESSAGE);
|
|
445
|
+
}
|
|
446
|
+
await runBuild({
|
|
446
447
|
directory: root,
|
|
447
448
|
assetPath,
|
|
448
449
|
lockfileCheck,
|
|
@@ -7,7 +7,7 @@ import { renderSuccess, renderInfo } from '@shopify/cli-kit/node/ui';
|
|
|
7
7
|
import { AbortError } from '@shopify/cli-kit/node/error';
|
|
8
8
|
import { removeFile } from '@shopify/cli-kit/node/fs';
|
|
9
9
|
import { setH2OVerbose, isH2Verbose, muteDevLogs, enhanceH2Logs } from '../../lib/log.js';
|
|
10
|
-
import {
|
|
10
|
+
import { commonFlags, overrideFlag, flagsToCamelObject, DEFAULT_INSPECTOR_PORT, DEFAULT_APP_PORT } from '../../lib/flags.js';
|
|
11
11
|
import { spawnCodegenProcess } from '../../lib/codegen.js';
|
|
12
12
|
import { getAllEnvironmentVariables } from '../../lib/environment-variables.js';
|
|
13
13
|
import { displayDevUpgradeNotice } from './upgrade.js';
|
|
@@ -16,8 +16,7 @@ import { getDevConfigInBackground, TUNNEL_DOMAIN, startTunnelAndPushConfig, isMo
|
|
|
16
16
|
import { getCliCommand } from '../../lib/shell.js';
|
|
17
17
|
import { findPort } from '../../lib/find-port.js';
|
|
18
18
|
import { logRequestLine } from '../../lib/mini-oxygen/common.js';
|
|
19
|
-
import { isViteProject, findHydrogenPlugin, findOxygenPlugin } from '../../lib/vite-config.js';
|
|
20
|
-
import { runClassicCompilerDev } from '../../lib/classic-compiler/dev.js';
|
|
19
|
+
import { isViteProject, REMIX_COMPILER_ERROR_MESSAGE, findHydrogenPlugin, findOxygenPlugin, getViteConfig } from '../../lib/vite-config.js';
|
|
21
20
|
import { importVite } from '../../lib/import-utils.js';
|
|
22
21
|
import { createEntryPointErrorHandler } from '../../lib/deps-optimizer.js';
|
|
23
22
|
import { getCodeFormatOptions } from '../../lib/format-code.js';
|
|
@@ -63,17 +62,6 @@ class Dev extends Command {
|
|
|
63
62
|
description: "Disable adding dependencies to Vite's `ssr.optimizeDeps.include` automatically",
|
|
64
63
|
env: "SHOPIFY_HYDROGEN_FLAG_DISABLE_DEPS_OPTIMIZER",
|
|
65
64
|
default: false
|
|
66
|
-
}),
|
|
67
|
-
// For the classic compiler:
|
|
68
|
-
...overrideFlag(commonFlags.legacyRuntime, {
|
|
69
|
-
"legacy-runtime": {
|
|
70
|
-
description: "[Classic Remix Compiler] " + commonFlags.legacyRuntime["legacy-runtime"].description
|
|
71
|
-
}
|
|
72
|
-
}),
|
|
73
|
-
...overrideFlag(commonFlags.sourcemap, {
|
|
74
|
-
sourcemap: {
|
|
75
|
-
description: "[Classic Remix Compiler] " + commonFlags.sourcemap.sourcemap.description
|
|
76
|
-
}
|
|
77
65
|
})
|
|
78
66
|
};
|
|
79
67
|
async run() {
|
|
@@ -87,7 +75,11 @@ class Dev extends Command {
|
|
|
87
75
|
path: directory,
|
|
88
76
|
cliConfig: this.config
|
|
89
77
|
};
|
|
90
|
-
const
|
|
78
|
+
const isVite = await isViteProject(directory);
|
|
79
|
+
if (!isVite) {
|
|
80
|
+
throw new AbortError(REMIX_COMPILER_ERROR_MESSAGE);
|
|
81
|
+
}
|
|
82
|
+
const { close } = await runDev(devParams);
|
|
91
83
|
setupResourceCleanup(async () => {
|
|
92
84
|
await close();
|
|
93
85
|
if (diff) {
|
|
@@ -212,14 +204,15 @@ async function runDev({
|
|
|
212
204
|
"Add `hydrogen()` plugin to your Vite config."
|
|
213
205
|
);
|
|
214
206
|
}
|
|
215
|
-
|
|
207
|
+
h2Plugin.api?.getPluginOptions?.();
|
|
208
|
+
const remixConfig = (await getViteConfig(root)).remixConfig;
|
|
216
209
|
let codegenProcess;
|
|
217
210
|
const setupCodegen = useCodegen ? () => {
|
|
218
211
|
codegenProcess?.kill(0);
|
|
219
212
|
codegenProcess = spawnCodegenProcess({
|
|
220
213
|
rootDirectory: root,
|
|
221
214
|
configFilePath: codegenConfigPath,
|
|
222
|
-
appDirectory:
|
|
215
|
+
appDirectory: remixConfig?.appDirectory
|
|
223
216
|
});
|
|
224
217
|
} : void 0;
|
|
225
218
|
setupCodegen?.();
|
|
@@ -10,9 +10,8 @@ import { startMiniOxygen } from '../../lib/mini-oxygen/index.js';
|
|
|
10
10
|
import { getAllEnvironmentVariables } from '../../lib/environment-variables.js';
|
|
11
11
|
import { getConfig } from '../../lib/shopify-config.js';
|
|
12
12
|
import { findPort } from '../../lib/find-port.js';
|
|
13
|
-
import { getViteConfig } from '../../lib/vite-config.js';
|
|
13
|
+
import { REMIX_COMPILER_ERROR_MESSAGE, getViteConfig } from '../../lib/vite-config.js';
|
|
14
14
|
import { runBuild } from './build.js';
|
|
15
|
-
import { runClassicCompilerBuild } from '../../lib/classic-compiler/build.js';
|
|
16
15
|
import { setupResourceCleanup } from '../../lib/resource-cleanup.js';
|
|
17
16
|
import { deferPromise } from '../../lib/defer.js';
|
|
18
17
|
import { prepareDiffDirectory } from '../../lib/template-diff.js';
|
|
@@ -23,7 +22,6 @@ class Preview extends Command {
|
|
|
23
22
|
static flags = {
|
|
24
23
|
...commonFlags.path,
|
|
25
24
|
...commonFlags.port,
|
|
26
|
-
...commonFlags.legacyRuntime,
|
|
27
25
|
...commonFlags.env,
|
|
28
26
|
...commonFlags.envBranch,
|
|
29
27
|
...commonFlags.envFile,
|
|
@@ -74,7 +72,6 @@ class Preview extends Command {
|
|
|
74
72
|
async function runPreview({
|
|
75
73
|
port: appPort,
|
|
76
74
|
directory,
|
|
77
|
-
legacyRuntime = false,
|
|
78
75
|
env: envHandle,
|
|
79
76
|
envBranch,
|
|
80
77
|
inspectorPort,
|
|
@@ -93,11 +90,8 @@ async function runPreview({
|
|
|
93
90
|
if (!isH2Verbose()) muteDevLogs();
|
|
94
91
|
let { root, buildPath, buildPathWorkerFile, buildPathClient } = getProjectPaths(directory);
|
|
95
92
|
const useClassicCompiler = await isClassicProject(root);
|
|
96
|
-
if (
|
|
97
|
-
throw new AbortError(
|
|
98
|
-
"Preview in watch mode is not supported for classic Remix projects.",
|
|
99
|
-
"Please use the dev command instead, which is the equivalent for classic projects."
|
|
100
|
-
);
|
|
93
|
+
if (useClassicCompiler) {
|
|
94
|
+
throw new AbortError(REMIX_COMPILER_ERROR_MESSAGE);
|
|
101
95
|
}
|
|
102
96
|
let miniOxygen;
|
|
103
97
|
const projectBuild = deferPromise();
|
|
@@ -111,9 +105,7 @@ async function runPreview({
|
|
|
111
105
|
useCodegen,
|
|
112
106
|
codegenConfigPath
|
|
113
107
|
};
|
|
114
|
-
const buildProcess = shouldBuild ?
|
|
115
|
-
...buildOptions
|
|
116
|
-
}).then(projectBuild.resolve) : await runBuild({
|
|
108
|
+
const buildProcess = shouldBuild ? await runBuild({
|
|
117
109
|
...buildOptions,
|
|
118
110
|
watch,
|
|
119
111
|
async onServerBuildFinish() {
|
|
@@ -143,23 +135,20 @@ async function runPreview({
|
|
|
143
135
|
if (!appPort) {
|
|
144
136
|
appPort = await findPort(DEFAULT_APP_PORT);
|
|
145
137
|
}
|
|
146
|
-
const assetsPort =
|
|
138
|
+
const assetsPort = await findPort(appPort + 100);
|
|
147
139
|
await projectBuild.promise;
|
|
148
140
|
logInjectedVariables();
|
|
149
|
-
miniOxygen = await startMiniOxygen(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
legacyRuntime
|
|
162
|
-
);
|
|
141
|
+
miniOxygen = await startMiniOxygen({
|
|
142
|
+
root,
|
|
143
|
+
appPort,
|
|
144
|
+
assetsPort,
|
|
145
|
+
env: allVariables,
|
|
146
|
+
buildPathClient,
|
|
147
|
+
buildPathWorkerFile,
|
|
148
|
+
inspectorPort,
|
|
149
|
+
debug,
|
|
150
|
+
watch
|
|
151
|
+
});
|
|
163
152
|
miniOxygen.showBanner({
|
|
164
153
|
mode: "preview",
|
|
165
154
|
headlinePrefix: watch ? "Watching for changes. " : ""
|
|
@@ -318,6 +318,12 @@ function isRemixDependency([name]) {
|
|
|
318
318
|
}
|
|
319
319
|
return false;
|
|
320
320
|
}
|
|
321
|
+
function isReactRouterDependency([name]) {
|
|
322
|
+
if (name.includes("react-router")) {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
321
327
|
function maybeIncludeDependency({
|
|
322
328
|
currentDependencies,
|
|
323
329
|
dependency: [name, version],
|
|
@@ -326,6 +332,8 @@ function maybeIncludeDependency({
|
|
|
326
332
|
const existingDependencyVersion = currentDependencies[name];
|
|
327
333
|
const isRemixPackage = isRemixDependency([name, version]);
|
|
328
334
|
if (isRemixPackage) return false;
|
|
335
|
+
const isReactRouterPackage = isReactRouterDependency([name, version]);
|
|
336
|
+
if (isReactRouterPackage) return false;
|
|
329
337
|
const isNextVersion = existingDependencyVersion === "next";
|
|
330
338
|
if (isNextVersion) return false;
|
|
331
339
|
const depMeta = selectedRelease.dependenciesMeta?.[name];
|
|
@@ -380,6 +388,26 @@ function buildUpgradeCommandArgs({
|
|
|
380
388
|
);
|
|
381
389
|
}
|
|
382
390
|
}
|
|
391
|
+
const currentReactRouter = Object.entries(currentDependencies).find(
|
|
392
|
+
isReactRouterDependency
|
|
393
|
+
);
|
|
394
|
+
const selectedReactRouter = Object.entries(selectedRelease.dependencies).find(
|
|
395
|
+
isReactRouterDependency
|
|
396
|
+
);
|
|
397
|
+
if (currentReactRouter && selectedReactRouter) {
|
|
398
|
+
const shouldUpgradeReactRouter = semver.lt(
|
|
399
|
+
getAbsoluteVersion(currentReactRouter[1]),
|
|
400
|
+
getAbsoluteVersion(selectedReactRouter[1])
|
|
401
|
+
);
|
|
402
|
+
if (shouldUpgradeReactRouter) {
|
|
403
|
+
args.push(
|
|
404
|
+
...appendReactRouterDependencies({
|
|
405
|
+
currentDependencies,
|
|
406
|
+
selectedReactRouter
|
|
407
|
+
})
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
383
411
|
return args;
|
|
384
412
|
}
|
|
385
413
|
async function upgradeNodeModules({
|
|
@@ -420,6 +448,20 @@ function appendRemixDependencies({
|
|
|
420
448
|
}
|
|
421
449
|
return command;
|
|
422
450
|
}
|
|
451
|
+
function appendReactRouterDependencies({
|
|
452
|
+
currentDependencies,
|
|
453
|
+
selectedReactRouter
|
|
454
|
+
}) {
|
|
455
|
+
const command = [];
|
|
456
|
+
for (const [name, version] of Object.entries(currentDependencies)) {
|
|
457
|
+
const isReactRouterPackage = isReactRouterDependency([name, version]);
|
|
458
|
+
if (!isReactRouterPackage) {
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
command.push(`${name}@${getAbsoluteVersion(selectedReactRouter[1])}`);
|
|
462
|
+
}
|
|
463
|
+
return command;
|
|
464
|
+
}
|
|
423
465
|
function getAbsoluteVersion(version) {
|
|
424
466
|
const result = semver.minVersion(version);
|
|
425
467
|
if (!result) {
|
package/dist/hooks/init.js
CHANGED
|
@@ -48,7 +48,7 @@ const hook = async function(options) {
|
|
|
48
48
|
};
|
|
49
49
|
const EXPERIMENTAL_VM_MODULES_FLAG = "--experimental-vm-modules";
|
|
50
50
|
function commandNeedsVM(id = "", argv = []) {
|
|
51
|
-
return id === "hydrogen:debug:cpu"
|
|
51
|
+
return id === "hydrogen:debug:cpu";
|
|
52
52
|
}
|
|
53
53
|
function isHydrogenProject(projectPath) {
|
|
54
54
|
try {
|
package/dist/index.d.ts
CHANGED
|
@@ -84,8 +84,6 @@ declare class Dev extends Command {
|
|
|
84
84
|
static descriptionWithMarkdown: string;
|
|
85
85
|
static description: string;
|
|
86
86
|
static flags: {
|
|
87
|
-
sourcemap: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
88
|
-
'legacy-runtime': _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
89
87
|
host: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
90
88
|
'disable-deps-optimizer': _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
91
89
|
verbose: _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
@@ -231,7 +229,6 @@ declare class Preview extends Command {
|
|
|
231
229
|
'env-file': _oclif_core_lib_interfaces_parser_js.OptionFlag<string, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
232
230
|
'env-branch': _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
233
231
|
env: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
234
|
-
'legacy-runtime': _oclif_core_lib_interfaces_parser_js.BooleanFlag<boolean>;
|
|
235
232
|
port: _oclif_core_lib_interfaces_parser_js.OptionFlag<number | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
236
233
|
path: _oclif_core_lib_interfaces_parser_js.OptionFlag<string | undefined, _oclif_core_lib_interfaces_parser_js.CustomOptions>;
|
|
237
234
|
};
|
package/dist/lib/codegen.js
CHANGED
|
@@ -84,8 +84,9 @@ function spawnCodegenProcess({
|
|
|
84
84
|
});
|
|
85
85
|
return child;
|
|
86
86
|
}
|
|
87
|
-
function codegen(options) {
|
|
88
|
-
|
|
87
|
+
async function codegen(options) {
|
|
88
|
+
await executeReactRouterCodegen(options);
|
|
89
|
+
return runGraphQLCodegen(options).catch((error) => {
|
|
89
90
|
if (error instanceof AbortError) throw error;
|
|
90
91
|
const { message, details } = normalizeCodegenError(
|
|
91
92
|
error.message,
|
|
@@ -94,7 +95,20 @@ function codegen(options) {
|
|
|
94
95
|
throw new AbortError(message, details);
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
|
-
async function
|
|
98
|
+
async function executeReactRouterCodegen(options) {
|
|
99
|
+
const { execSync, exec } = await import('child_process');
|
|
100
|
+
if (options.watch) {
|
|
101
|
+
exec("npx react-router typegen --watch", {
|
|
102
|
+
cwd: options.rootDirectory
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
execSync("npx react-router typegen", {
|
|
106
|
+
cwd: options.rootDirectory,
|
|
107
|
+
stdio: "inherit"
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function runGraphQLCodegen({
|
|
98
112
|
watch,
|
|
99
113
|
configFilePath,
|
|
100
114
|
forceSfapiVersion,
|
package/dist/lib/flags.js
CHANGED
|
@@ -21,12 +21,6 @@ const commonFlags = {
|
|
|
21
21
|
env: "SHOPIFY_HYDROGEN_FLAG_PORT"
|
|
22
22
|
})
|
|
23
23
|
},
|
|
24
|
-
legacyRuntime: {
|
|
25
|
-
"legacy-runtime": Flags.boolean({
|
|
26
|
-
description: "Runs the app in a Node.js sandbox instead of an Oxygen worker.",
|
|
27
|
-
env: "SHOPIFY_HYDROGEN_FLAG_LEGACY_RUNTIME"
|
|
28
|
-
})
|
|
29
|
-
},
|
|
30
24
|
force: {
|
|
31
25
|
force: Flags.boolean({
|
|
32
26
|
description: "Overwrites the destination directory and files if they already exist.",
|
|
@@ -9,12 +9,7 @@ async function buildAssetsUrl(port, root) {
|
|
|
9
9
|
).catch(handleMiniOxygenImportFail);
|
|
10
10
|
return _buildAssetsUrl(port);
|
|
11
11
|
}
|
|
12
|
-
async function startMiniOxygen(options
|
|
13
|
-
if (useNodeRuntime) {
|
|
14
|
-
process.env.MINIFLARE_SUBREQUEST_LIMIT = 100;
|
|
15
|
-
const { startNodeServer } = await import('./node.js');
|
|
16
|
-
return startNodeServer(options);
|
|
17
|
-
}
|
|
12
|
+
async function startMiniOxygen(options) {
|
|
18
13
|
const { startWorkerdServer } = await import('./workerd.js');
|
|
19
14
|
return startWorkerdServer(options);
|
|
20
15
|
}
|