@shopify/cli-hydrogen 10.1.0 → 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 +45 -58
- 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 +1 -1
- 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 +1 -1
- 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/vite-config.js +13 -9
- package/oclif.manifest.json +1 -22
- 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,5 +1,5 @@
|
|
|
1
1
|
import {type LoaderFunctionArgs} from '@shopify/remix-oxygen';
|
|
2
|
-
import {useLoaderData, Link} from '
|
|
2
|
+
import { useLoaderData, Link } from 'react-router';
|
|
3
3
|
|
|
4
4
|
export async function loader({context}: LoaderFunctionArgs) {
|
|
5
5
|
const data = await context.storefront.query(POLICIES_QUERY);
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
type LoaderFunctionArgs,
|
|
3
3
|
type ActionFunctionArgs,
|
|
4
4
|
} from '@shopify/remix-oxygen';
|
|
5
|
-
import {useLoaderData, type MetaFunction} from '
|
|
5
|
+
import { useLoaderData, type MetaFunction } from 'react-router';
|
|
6
6
|
import {getPaginationVariables, Analytics} from '@shopify/hydrogen';
|
|
7
7
|
import {SearchForm} from '~/components/SearchForm';
|
|
8
8
|
import {SearchResults} from '~/components/SearchResults';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {flatRoutes} from '@
|
|
2
|
-
import {type RouteConfig} from '@
|
|
1
|
+
import {flatRoutes} from '@react-router/fs-routes';
|
|
2
|
+
import {type RouteConfig} from '@react-router/dev/routes';
|
|
3
3
|
import {hydrogenRoutes} from '@shopify/hydrogen';
|
|
4
4
|
|
|
5
5
|
export default hydrogenRoutes([
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="vite/client" />
|
|
2
|
-
/// <reference types="
|
|
2
|
+
/// <reference types="react-router" />
|
|
3
3
|
/// <reference types="@shopify/oxygen-workers-types" />
|
|
4
4
|
|
|
5
5
|
// Enhance TypeScript's built-in typings.
|
|
@@ -23,12 +23,22 @@ declare global {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
declare module '
|
|
26
|
+
declare module 'react-router' {
|
|
27
27
|
interface AppLoadContext
|
|
28
28
|
extends Awaited<ReturnType<typeof createAppLoadContext>> {
|
|
29
29
|
// to change context type, change the return of createAppLoadContext() instead
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// TODO: remove this once we've migrated our loaders to `Route.LoaderArgs`
|
|
33
|
+
interface LoaderFunctionArgs {
|
|
34
|
+
context: AppLoadContext;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// TODO: remove this once we've migrated our loaders to `Route.ActionArgs`
|
|
38
|
+
interface ActionFunctionArgs {
|
|
39
|
+
context: AppLoadContext;
|
|
40
|
+
}
|
|
41
|
+
|
|
32
42
|
interface SessionData extends HydrogenSessionData {
|
|
33
43
|
// declare local additions to the Remix session data here
|
|
34
44
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "skeleton",
|
|
3
3
|
"private": true,
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "2025.
|
|
5
|
+
"version": "2025.5.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "shopify hydrogen build --codegen",
|
|
@@ -14,31 +14,29 @@
|
|
|
14
14
|
},
|
|
15
15
|
"prettier": "@shopify/prettier-config",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@remix-
|
|
17
|
+
"@shopify/hydrogen": "2025.5.0",
|
|
18
|
+
"@shopify/remix-oxygen": "^3.0.0",
|
|
19
19
|
"graphql": "^16.10.0",
|
|
20
|
-
"@shopify/hydrogen": "2025.4.1",
|
|
21
|
-
"@shopify/remix-oxygen": "^2.0.12",
|
|
22
20
|
"graphql-tag": "^2.12.6",
|
|
23
21
|
"isbot": "^5.1.22",
|
|
24
22
|
"react": "^18.2.0",
|
|
25
|
-
"react-dom": "^18.2.0"
|
|
23
|
+
"react-dom": "^18.2.0",
|
|
24
|
+
"react-router": "7.6.0",
|
|
25
|
+
"react-router-dom": "7.6.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@eslint/compat": "^1.2.5",
|
|
29
29
|
"@eslint/eslintrc": "^3.2.0",
|
|
30
30
|
"@eslint/js": "^9.18.0",
|
|
31
31
|
"@graphql-codegen/cli": "5.0.2",
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@remix-run/route-config": "^2.16.1",
|
|
32
|
+
"@react-router/dev": "7.6.0",
|
|
33
|
+
"@react-router/fs-routes": "7.6.0",
|
|
35
34
|
"@shopify/cli": "~3.79.2",
|
|
36
35
|
"@shopify/hydrogen-codegen": "^0.3.3",
|
|
37
36
|
"@shopify/mini-oxygen": "^3.2.1",
|
|
38
37
|
"@shopify/oxygen-workers-types": "^4.1.6",
|
|
39
38
|
"@shopify/prettier-config": "^1.1.2",
|
|
40
39
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
41
|
-
"prettier": "^3.4.2",
|
|
42
40
|
"@types/eslint": "^9.6.1",
|
|
43
41
|
"@types/react": "^18.2.22",
|
|
44
42
|
"@types/react-dom": "^18.2.7",
|
|
@@ -54,6 +52,7 @@
|
|
|
54
52
|
"eslint-plugin-react": "^7.37.4",
|
|
55
53
|
"eslint-plugin-react-hooks": "^5.1.0",
|
|
56
54
|
"globals": "^15.14.0",
|
|
55
|
+
"prettier": "^3.4.2",
|
|
57
56
|
"typescript": "^5.2.2",
|
|
58
57
|
"vite": "^6.2.4",
|
|
59
58
|
"vite-tsconfig-paths": "^4.3.1"
|
|
@@ -61,4 +60,4 @@
|
|
|
61
60
|
"engines": {
|
|
62
61
|
"node": ">=18.0.0"
|
|
63
62
|
}
|
|
64
|
-
}
|
|
63
|
+
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
// Virtual entry point for the app
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
// eslint-disable-next-line import/no-unresolved
|
|
5
|
-
import * as remixBuild from 'virtual:remix/server-build';
|
|
6
2
|
import {storefrontRedirect} from '@shopify/hydrogen';
|
|
7
3
|
import {createRequestHandler} from '@shopify/remix-oxygen';
|
|
8
4
|
import {createAppLoadContext} from '~/lib/context';
|
|
@@ -28,7 +24,8 @@ export default {
|
|
|
28
24
|
* Hydrogen's Storefront client to the loader context.
|
|
29
25
|
*/
|
|
30
26
|
const handleRequest = createRequestHandler({
|
|
31
|
-
|
|
27
|
+
// eslint-disable-next-line import/no-unresolved
|
|
28
|
+
build: await import('virtual:react-router/server-build'),
|
|
32
29
|
mode: process.env.NODE_ENV,
|
|
33
30
|
getLoadContext: () => appLoadContext,
|
|
34
31
|
});
|
|
@@ -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 {
|