vinext 1.0.0-beta.12 → 1.0.0-beta.13
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/README.md +39 -12
- package/dist/build/action-owner-manifest.js +23 -5
- package/dist/build/lifecycle.d.ts +42 -0
- package/dist/build/lifecycle.js +246 -0
- package/dist/build/nitro-route-rules.js +1 -1
- package/dist/build/pages-client-assets-module.d.ts +0 -3
- package/dist/build/pages-client-assets-module.js +1 -13
- package/dist/build/precompress.js +1 -1
- package/dist/build/prerender-paths.d.ts +1 -1
- package/dist/build/prerender-paths.js +6 -6
- package/dist/build/prerender-server-pool.js +1 -1
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +5 -5
- package/dist/build/preview-credentials.d.ts +1 -1
- package/dist/build/preview-credentials.js +2 -2
- package/dist/build/report.js +1 -1
- package/dist/build/run-prerender.d.ts +2 -2
- package/dist/build/run-prerender.js +5 -5
- package/dist/build/standalone.js +2 -2
- package/dist/cli-args.d.ts +5 -13
- package/dist/cli-args.js +2 -45
- package/dist/cli-dev-config.d.ts +6 -2
- package/dist/cli-dev-config.js +160 -3
- package/dist/cli.js +104 -439
- package/dist/config/config-matchers.js +1 -1
- package/dist/config/next-config.d.ts +2 -2
- package/dist/config/next-config.js +5 -5
- package/dist/config/prerender.d.ts +3 -0
- package/dist/config/prerender.js +8 -2
- package/dist/entries/app-browser-entry.js +1 -1
- package/dist/entries/app-rsc-entry.js +1 -1
- package/dist/entries/pages-client-entry.d.ts +1 -0
- package/dist/entries/pages-client-entry.js +17 -2
- package/dist/index.d.ts +6 -8
- package/dist/index.js +262 -101
- package/dist/init-cloudflare.d.ts +3 -2
- package/dist/init-cloudflare.js +117 -5
- package/dist/init-platform.d.ts +2 -0
- package/dist/init-platform.js +9 -3
- package/dist/init.d.ts +7 -5
- package/dist/init.js +41 -22
- package/dist/plugins/dynamic-preload-metadata.js +1 -1
- package/dist/plugins/extensionless-dynamic-import.js +2 -2
- package/dist/plugins/fonts.js +1 -1
- package/dist/plugins/ignore-dynamic-requests.js +1 -1
- package/dist/plugins/import-meta-url.js +1 -1
- package/dist/plugins/instrumentation-client.js +1 -1
- package/dist/plugins/og-assets.js +32 -13
- package/dist/plugins/og-harfbuzz.d.ts +24 -0
- package/dist/plugins/og-harfbuzz.js +260 -0
- package/dist/plugins/optimize-imports.js +1 -1
- package/dist/plugins/require-condition-resolution.js +2 -2
- package/dist/plugins/require-context.js +2 -2
- package/dist/plugins/typeof-window.js +1 -1
- package/dist/plugins/use-cache-callable.d.ts +0 -2
- package/dist/plugins/use-cache-callable.js +8 -16
- package/dist/plugins/worker-image-imports.js +1 -1
- package/dist/routing/app-route-graph.js +1 -1
- package/dist/routing/app-router.js +1 -1
- package/dist/routing/pages-router.js +1 -1
- package/dist/server/app-action-forwarding.js +1 -1
- package/dist/server/app-browser-error.js +1 -1
- package/dist/server/app-elements-wire.js +2 -2
- package/dist/server/app-middleware.js +1 -1
- package/dist/server/app-optimistic-routing.js +1 -1
- package/dist/server/app-page-dispatch.js +1 -1
- package/dist/server/app-page-element-builder.js +3 -2
- package/dist/server/app-page-probe.js +3 -3
- package/dist/server/app-request-stage-independent-entry.js +2 -2
- package/dist/server/app-route-handler-dispatch.js +1 -1
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-router-entry.js +2 -2
- package/dist/server/app-rsc-handler.d.ts +1 -1
- package/dist/server/app-rsc-handler.js +4 -4
- package/dist/server/app-rsc-response-stage.js +1 -1
- package/dist/server/app-rsc-route-matching.js +1 -1
- package/dist/server/app-server-action-execution.js +4 -4
- package/dist/server/artifact-compatibility.js +1 -1
- package/dist/server/client-reuse-manifest.js +1 -1
- package/dist/server/dev-lockfile.d.ts +1 -1
- package/dist/server/dev-lockfile.js +4 -1
- package/dist/server/dev-server.d.ts +1 -1
- package/dist/server/dev-server.js +28 -6
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/isr-cache.js +1 -1
- package/dist/server/metadata-route-response.js +8 -0
- package/dist/server/middleware-runtime.js +3 -3
- package/dist/server/pages-data-route.js +1 -1
- package/dist/server/pages-dev-hydration.d.ts +6 -0
- package/dist/server/pages-dev-hydration.js +19 -7
- package/dist/server/pages-page-data.js +2 -2
- package/dist/server/pages-page-handler.js +1 -1
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/pages-request-pipeline.js +3 -3
- package/dist/server/pages-request-stage-entry.js +3 -3
- package/dist/server/pages-revalidate.js +1 -1
- package/dist/server/prerender-route-params.js +1 -1
- package/dist/server/prod-server.js +7 -7
- package/dist/server/request-pipeline.js +2 -2
- package/dist/server/socket-error-backstop.js +1 -1
- package/dist/shims/cache-callable-runtime.d.ts +38 -0
- package/dist/shims/cache-callable-runtime.js +162 -11
- package/dist/shims/cache-runtime.d.ts +6 -8
- package/dist/shims/cache-runtime.js +82 -22
- package/dist/shims/font-local.js +1 -1
- package/dist/shims/form.js +1 -1
- package/dist/shims/headers.js +2 -2
- package/dist/shims/internal/app-page-props-cache-key.d.ts +29 -0
- package/dist/shims/internal/app-page-props-cache-key.js +53 -1
- package/dist/shims/internal/format-url-object.d.ts +7 -0
- package/dist/shims/internal/format-url-object.js +53 -0
- package/dist/shims/internal/normalize-router-href.d.ts +15 -0
- package/dist/shims/internal/normalize-router-href.js +41 -0
- package/dist/shims/internal/pages-data-target.d.ts +4 -1
- package/dist/shims/internal/pages-data-target.js +28 -35
- package/dist/shims/internal/route-pattern-for-warning.d.ts +2 -2
- package/dist/shims/internal/route-pattern-for-warning.js +3 -3
- package/dist/shims/link.js +31 -92
- package/dist/shims/metadata.js +5 -4
- package/dist/shims/navigation.js +2 -2
- package/dist/shims/router-state.js +1 -1
- package/dist/shims/router.d.ts +8 -7
- package/dist/shims/router.js +312 -148
- package/dist/shims/server.js +3 -3
- package/dist/utils/built-asset-url.js +1 -1
- package/dist/utils/project.d.ts +1 -11
- package/dist/utils/project.js +19 -28
- package/dist/utils/react-version.d.ts +3 -1
- package/dist/utils/react-version.js +19 -1
- package/dist/utils/vite-cli-invocation.d.ts +21 -0
- package/dist/utils/vite-cli-invocation.js +144 -0
- package/package.json +10 -2
package/dist/shims/server.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { bindRequestContextSnapshot, getRequestContext, isInsideUnifiedScope, queueAfterCallback, trackAfterPromise } from "./unified-request-context.js";
|
|
2
|
+
import { MIDDLEWARE_SET_COOKIE_HEADER } from "../utils/protocol-headers.js";
|
|
3
|
+
import { encodeMiddlewareRequestHeaders } from "../utils/middleware-request-headers.js";
|
|
4
|
+
import { parseEdgeRequestCookieHeader } from "../utils/parse-cookie.js";
|
|
2
5
|
import { hasBasePath, removeTrailingSlash, stripBasePath } from "../utils/base-path.js";
|
|
3
6
|
import { getRequestExecutionContext } from "./request-context.js";
|
|
4
|
-
import { parseEdgeRequestCookieHeader } from "../utils/parse-cookie.js";
|
|
5
|
-
import { MIDDLEWARE_SET_COOKIE_HEADER } from "../utils/protocol-headers.js";
|
|
6
7
|
import { MIDDLEWARE_NEXT_HEADER, MIDDLEWARE_REWRITE_HEADER } from "../server/headers.js";
|
|
7
|
-
import { encodeMiddlewareRequestHeaders } from "../utils/middleware-request-headers.js";
|
|
8
8
|
import { validateCookieAttributeValue, validateCookieName } from "./internal/cookie-serialize.js";
|
|
9
9
|
import { assertSafeNavigationUrl } from "./url-safety.js";
|
|
10
10
|
import { userAgent, userAgentFromString } from "./user-agent.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { appendDeploymentIdQuery } from "./deployment-id.js";
|
|
2
1
|
import { ASSET_PREFIX_URL_DIR, resolveAssetUrlPrefix, resolveAssetsDir } from "./asset-prefix.js";
|
|
2
|
+
import { appendDeploymentIdQuery } from "./deployment-id.js";
|
|
3
3
|
//#region src/utils/built-asset-url.ts
|
|
4
4
|
function renderVinextBuiltUrl(filename, assetPrefix, deploymentId, hostType, hostId) {
|
|
5
5
|
const urlPrefix = resolveAssetUrlPrefix(assetPrefix);
|
package/dist/utils/project.d.ts
CHANGED
|
@@ -17,17 +17,7 @@ export declare function ensureESModule(root: string): boolean;
|
|
|
17
17
|
* Returns array of [oldName, newName] pairs that were renamed.
|
|
18
18
|
*/
|
|
19
19
|
export declare function renameCJSConfigs(root: string): Array<[string, string]>;
|
|
20
|
-
/**
|
|
21
|
-
* Ensure the project is configured for ESM before Vite loads vite.config.ts.
|
|
22
|
-
*
|
|
23
|
-
* This mirrors what `vinext init` does, but is applied lazily at dev/build
|
|
24
|
-
* time for projects that were set up before `vinext init` added the step.
|
|
25
|
-
*
|
|
26
|
-
* Side effects: may rename `.js` CJS config files to `.cjs` and add
|
|
27
|
-
* `"type": "module"` to package.json.
|
|
28
|
-
*
|
|
29
|
-
* @returns Object describing what was changed, or null if nothing was done.
|
|
30
|
-
*/
|
|
20
|
+
/** Preserve the old CLI's ESM migration for projects with a legacy Vite config. */
|
|
31
21
|
export declare function ensureViteConfigCompatibility(root: string): {
|
|
32
22
|
renamed: Array<[string, string]>;
|
|
33
23
|
addedTypeModule: boolean;
|
package/dist/utils/project.js
CHANGED
|
@@ -61,40 +61,31 @@ function renameCJSConfigs(root) {
|
|
|
61
61
|
}
|
|
62
62
|
return renamed;
|
|
63
63
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Ensure the project is configured for ESM before Vite loads vite.config.ts.
|
|
66
|
-
*
|
|
67
|
-
* This mirrors what `vinext init` does, but is applied lazily at dev/build
|
|
68
|
-
* time for projects that were set up before `vinext init` added the step.
|
|
69
|
-
*
|
|
70
|
-
* Side effects: may rename `.js` CJS config files to `.cjs` and add
|
|
71
|
-
* `"type": "module"` to package.json.
|
|
72
|
-
*
|
|
73
|
-
* @returns Object describing what was changed, or null if nothing was done.
|
|
74
|
-
*/
|
|
64
|
+
/** Preserve the old CLI's ESM migration for projects with a legacy Vite config. */
|
|
75
65
|
function ensureViteConfigCompatibility(root) {
|
|
76
|
-
|
|
66
|
+
const config = findViteConfigPath(root);
|
|
67
|
+
if (!config || !/\.(?:ts|js)$/.test(config)) return null;
|
|
77
68
|
const pkgPath = path.join(root, "package.json");
|
|
78
69
|
if (!fs.existsSync(pkgPath)) return null;
|
|
79
|
-
let pkg;
|
|
80
70
|
try {
|
|
81
|
-
pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
71
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
72
|
+
if (pkg.type !== void 0) return null;
|
|
73
|
+
if (config.endsWith(".js") && /\b(?:module\.exports|require\s*\()/.test(fs.readFileSync(config, "utf-8"))) return null;
|
|
74
|
+
for (const fileName of CJS_CONFIG_FILES) {
|
|
75
|
+
const source = path.join(root, fileName);
|
|
76
|
+
const destination = path.join(root, fileName.replace(/\.js$/, ".cjs"));
|
|
77
|
+
if (fs.existsSync(source) && fs.existsSync(destination) && /\bmodule\.exports\b|\brequire\s*\(/.test(fs.readFileSync(source, "utf-8"))) return null;
|
|
78
|
+
}
|
|
79
|
+
const renamed = renameCJSConfigs(root);
|
|
80
|
+
pkg.type = "module";
|
|
81
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
82
|
+
return {
|
|
83
|
+
renamed,
|
|
84
|
+
addedTypeModule: true
|
|
85
|
+
};
|
|
82
86
|
} catch {
|
|
83
87
|
return null;
|
|
84
88
|
}
|
|
85
|
-
if (pkg.type === "module") return null;
|
|
86
|
-
if (pkg.type !== void 0) return null;
|
|
87
|
-
const renamed = renameCJSConfigs(root);
|
|
88
|
-
let addedTypeModule = false;
|
|
89
|
-
try {
|
|
90
|
-
pkg.type = "module";
|
|
91
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
92
|
-
addedTypeModule = true;
|
|
93
|
-
} catch {}
|
|
94
|
-
return {
|
|
95
|
-
renamed,
|
|
96
|
-
addedTypeModule
|
|
97
|
-
};
|
|
98
89
|
}
|
|
99
90
|
/**
|
|
100
91
|
* Walk from `start` up to the filesystem root, calling `check` on each
|
|
@@ -386,7 +377,7 @@ function getMissingDeps(info, _isResolvable = isPackageResolvable) {
|
|
|
386
377
|
name: "@cloudflare/vite-plugin",
|
|
387
378
|
version: "latest"
|
|
388
379
|
});
|
|
389
|
-
if (!info.hasWrangler) missing.push({
|
|
380
|
+
if (!info.hasWrangler && !fs.existsSync(path.join(info.root, "cloudflare.config.ts"))) missing.push({
|
|
390
381
|
name: "wrangler",
|
|
391
382
|
version: "latest"
|
|
392
383
|
});
|
|
@@ -12,7 +12,25 @@ function getDependencyUpgradeDeps(root, recommendations) {
|
|
|
12
12
|
}
|
|
13
13
|
return [];
|
|
14
14
|
}
|
|
15
|
-
function getReactUpgradeDeps(root) {
|
|
15
|
+
function getReactUpgradeDeps(root, options = {}) {
|
|
16
|
+
if (options.fromManifest) {
|
|
17
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf-8"));
|
|
18
|
+
for (const name of ["react", "react-dom"]) {
|
|
19
|
+
const declared = pkg.dependencies?.[name] ?? pkg.devDependencies?.[name];
|
|
20
|
+
const version = /^[~^]?([0-9]+(?:\.[0-9]+){0,2}(?:-[0-9A-Za-z.*-]+)?)(?:\.[x*])?$/.exec(declared ?? "")?.[1];
|
|
21
|
+
if (version && (version.includes("-") || isVersionBelow(version, [
|
|
22
|
+
19,
|
|
23
|
+
2,
|
|
24
|
+
6
|
|
25
|
+
]))) {
|
|
26
|
+
const upgrades = ["react@latest", "react-dom@latest"];
|
|
27
|
+
const rsdw = pkg.dependencies?.["react-server-dom-webpack"] ?? pkg.devDependencies?.["react-server-dom-webpack"];
|
|
28
|
+
if (rsdw && rsdw !== "latest") upgrades.push("react-server-dom-webpack@latest");
|
|
29
|
+
return upgrades;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
16
34
|
return getDependencyUpgradeDeps(root, { react: {
|
|
17
35
|
minimumVersion: [
|
|
18
36
|
19,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InlineConfig } from "vite";
|
|
2
|
+
//#region src/utils/vite-cli-invocation.d.ts
|
|
3
|
+
type Command = "dev" | "build";
|
|
4
|
+
type Invocation = {
|
|
5
|
+
command: Command;
|
|
6
|
+
mode: string;
|
|
7
|
+
root: string;
|
|
8
|
+
rootArg?: string;
|
|
9
|
+
configFile?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function valueOptionName(arg: string): string;
|
|
12
|
+
export declare function findViteRoot(command: Command, args: string[]): {
|
|
13
|
+
root: string | undefined;
|
|
14
|
+
shouldPreflight: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function getViteCliInvocation(argv?: string[]): Invocation | undefined;
|
|
17
|
+
/** Only the config loaded by the outer CLI may claim its dev lifecycle. */
|
|
18
|
+
export declare function isViteCliConfigFile(configFile: string, inlineConfig?: Pick<InlineConfig, "root" | "configFile">): boolean;
|
|
19
|
+
export declare function isViteCliInvocation(command: Command, argv?: string[]): boolean;
|
|
20
|
+
export declare function claimViteCliBuildInvocation(argv?: string[]): boolean;
|
|
21
|
+
//#endregion
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { findViteConfigPath } from "./project.js";
|
|
3
|
+
//#region src/utils/vite-cli-invocation.ts
|
|
4
|
+
let buildClaimed = false;
|
|
5
|
+
const valued = new Set("--config -c --mode -m --logLevel -l --filter -f --configLoader --port --outDir --target --assetsDir --assetsInlineLimit".split(" "));
|
|
6
|
+
const optional = new Set("--base --debug -d --host --open --profile --ssr --sourcemap --minify --manifest --ssrManifest".split(" "));
|
|
7
|
+
const flags = new Set("--app --clearScreen --cors --emptyOutDir --experimentalBundle --force --strictPort --watch -w --help -h --version -v".split(" "));
|
|
8
|
+
const devOnly = new Set("--host --port --open --cors --strictPort --force --experimentalBundle".split(" "));
|
|
9
|
+
const buildOnly = new Set("--target --outDir --assetsDir --assetsInlineLimit --ssr --sourcemap --minify --manifest --ssrManifest --emptyOutDir --watch -w --app".split(" "));
|
|
10
|
+
function valueOptionName(arg) {
|
|
11
|
+
const name = arg.split("=", 1)[0];
|
|
12
|
+
if (!name.startsWith("-") || name.startsWith("--") || name.length <= 2) return name;
|
|
13
|
+
const parts = name.slice(1).split("").map((part) => `-${part}`);
|
|
14
|
+
return parts.every((part) => valued.has(part) || optional.has(part) || flags.has(part)) ? parts.at(-1) : name;
|
|
15
|
+
}
|
|
16
|
+
function consumesNext(arg, next) {
|
|
17
|
+
if (arg.includes("=")) return false;
|
|
18
|
+
const name = valueOptionName(arg);
|
|
19
|
+
if (valued.has(name)) return true;
|
|
20
|
+
if (optional.has(name)) return next !== void 0 && !next.startsWith("-");
|
|
21
|
+
return flags.has(name) && /^(?:true|false)$/.test(next ?? "");
|
|
22
|
+
}
|
|
23
|
+
function parse(args, command) {
|
|
24
|
+
let root;
|
|
25
|
+
let mode;
|
|
26
|
+
let config;
|
|
27
|
+
let preflight = true;
|
|
28
|
+
let uncertainRoot = false;
|
|
29
|
+
let configs = 0;
|
|
30
|
+
for (let i = 0; i < args.length; i++) {
|
|
31
|
+
const arg = args[i];
|
|
32
|
+
if (arg === "--") break;
|
|
33
|
+
const name = valueOptionName(arg);
|
|
34
|
+
const normalized = name.startsWith("--no-") ? `--${name.slice(5)}` : name;
|
|
35
|
+
const inline = arg.includes("=") ? arg.slice(arg.indexOf("=") + 1) : void 0;
|
|
36
|
+
const takesNext = consumesNext(arg, args[i + 1]);
|
|
37
|
+
const value = inline ?? (takesNext ? args[i + 1] : void 0);
|
|
38
|
+
if (name === "--config" || name === "-c") {
|
|
39
|
+
configs++;
|
|
40
|
+
if (command === "dev") config = value;
|
|
41
|
+
else config ??= value;
|
|
42
|
+
} else if (name === "--mode" || name === "-m") mode = value;
|
|
43
|
+
if ((name === "--help" || name === "-h") && value !== "false" || /^-[^-]*h/.test(arg) && arg.length > 2) preflight = false;
|
|
44
|
+
if (valued.has(name) && (!value || value.startsWith("-"))) {
|
|
45
|
+
preflight = false;
|
|
46
|
+
if (!root) uncertainRoot = true;
|
|
47
|
+
}
|
|
48
|
+
if ((command === "build" ? devOnly : buildOnly).has(normalized)) preflight = false;
|
|
49
|
+
if (arg.startsWith("-")) {
|
|
50
|
+
if (!valued.has(normalized) && !optional.has(normalized) && !flags.has(normalized) || name.startsWith("--no-") && (valued.has(normalized) || inline !== void 0) || /^-[^-]{2,}/.test(arg) && arg.slice(1).split("=", 1)[0].split("").slice(0, -1).some((part) => valued.has(`-${part}`))) {
|
|
51
|
+
preflight = false;
|
|
52
|
+
if (!root) uncertainRoot = true;
|
|
53
|
+
}
|
|
54
|
+
if (takesNext) i++;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (root) preflight = false;
|
|
58
|
+
else root = arg;
|
|
59
|
+
}
|
|
60
|
+
if (configs > 1) preflight = false;
|
|
61
|
+
return {
|
|
62
|
+
root: uncertainRoot ? void 0 : root,
|
|
63
|
+
mode,
|
|
64
|
+
config,
|
|
65
|
+
preflight
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function findViteRoot(command, args) {
|
|
69
|
+
const { root, preflight } = parse(args, command);
|
|
70
|
+
return {
|
|
71
|
+
root,
|
|
72
|
+
shouldPreflight: preflight
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function commandArguments(argv) {
|
|
76
|
+
const entry = toSlash(argv[1] ?? "");
|
|
77
|
+
const vite = entry.endsWith("/vite/bin/vite.js") || entry.endsWith("/vite/node/cli.js") || entry.endsWith("/dist/vite/node/cli.js");
|
|
78
|
+
let args = argv.slice(2);
|
|
79
|
+
if (!vite) {
|
|
80
|
+
if (path.basename(entry) !== "vp") return void 0;
|
|
81
|
+
if (args[0] === "-C") args = args.slice(2);
|
|
82
|
+
if (args[0] === "exec" && args[1] === "vite") args = args.slice(2);
|
|
83
|
+
}
|
|
84
|
+
for (let i = 0; i < args.length; i++) {
|
|
85
|
+
const arg = args[i];
|
|
86
|
+
if (arg === "--") break;
|
|
87
|
+
if (arg.startsWith("-")) {
|
|
88
|
+
if (consumesNext(arg, args[i + 1])) i++;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (arg === "build") return {
|
|
92
|
+
command: "build",
|
|
93
|
+
args: args.slice(0, i).concat(args.slice(i + 1))
|
|
94
|
+
};
|
|
95
|
+
if (arg === "dev" || arg === "serve") return {
|
|
96
|
+
command: "dev",
|
|
97
|
+
args: args.slice(0, i).concat(args.slice(i + 1))
|
|
98
|
+
};
|
|
99
|
+
return vite && arg !== "preview" && arg !== "optimize" ? {
|
|
100
|
+
command: "dev",
|
|
101
|
+
args
|
|
102
|
+
} : void 0;
|
|
103
|
+
}
|
|
104
|
+
return vite ? {
|
|
105
|
+
command: "dev",
|
|
106
|
+
args
|
|
107
|
+
} : void 0;
|
|
108
|
+
}
|
|
109
|
+
function getViteCliInvocation(argv = process.argv) {
|
|
110
|
+
const invocation = commandArguments(argv);
|
|
111
|
+
if (!invocation) return void 0;
|
|
112
|
+
const { root, mode, config } = parse(invocation.args, invocation.command);
|
|
113
|
+
const cwd = toSlash(process.cwd());
|
|
114
|
+
return {
|
|
115
|
+
command: invocation.command,
|
|
116
|
+
mode: mode || (invocation.command === "build" ? "production" : "development"),
|
|
117
|
+
root: path.resolve(cwd, root ?? "."),
|
|
118
|
+
...root ? { rootArg: root } : {},
|
|
119
|
+
...config ? { configFile: path.resolve(cwd, config) } : {}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** Only the config loaded by the outer CLI may claim its dev lifecycle. */
|
|
123
|
+
function isViteCliConfigFile(configFile, inlineConfig) {
|
|
124
|
+
const invocation = getViteCliInvocation();
|
|
125
|
+
if (!invocation || !path.isAbsolute(configFile)) return false;
|
|
126
|
+
if (inlineConfig) {
|
|
127
|
+
if (inlineConfig.root !== invocation.rootArg) return false;
|
|
128
|
+
if (invocation.configFile) {
|
|
129
|
+
if (typeof inlineConfig.configFile !== "string" || path.resolve(toSlash(process.cwd()), inlineConfig.configFile) !== invocation.configFile) return false;
|
|
130
|
+
} else if (inlineConfig.configFile !== void 0) return false;
|
|
131
|
+
}
|
|
132
|
+
const expected = invocation.configFile ?? findViteConfigPath(invocation.root);
|
|
133
|
+
return expected !== void 0 && path.resolve(configFile) === expected;
|
|
134
|
+
}
|
|
135
|
+
function isViteCliInvocation(command, argv = process.argv) {
|
|
136
|
+
return commandArguments(argv)?.command === command;
|
|
137
|
+
}
|
|
138
|
+
function claimViteCliBuildInvocation(argv = process.argv) {
|
|
139
|
+
if (buildClaimed || !isViteCliInvocation("build", argv)) return false;
|
|
140
|
+
buildClaimed = true;
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { claimViteCliBuildInvocation, findViteRoot, getViteCliInvocation, isViteCliConfigFile, isViteCliInvocation, valueOptionName };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vinext",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
4
4
|
"description": "Run Next.js apps on Vite. Drop-in replacement for the next CLI.",
|
|
5
5
|
"homepage": "https://vinext.dev/",
|
|
6
6
|
"license": "MIT",
|
|
@@ -138,6 +138,14 @@
|
|
|
138
138
|
"types": "./dist/build/prerender-paths.d.ts",
|
|
139
139
|
"import": "./dist/build/prerender-paths.js"
|
|
140
140
|
},
|
|
141
|
+
"./internal/build/lifecycle": {
|
|
142
|
+
"types": "./dist/build/lifecycle.d.ts",
|
|
143
|
+
"import": "./dist/build/lifecycle.js"
|
|
144
|
+
},
|
|
145
|
+
"./internal/build/report": {
|
|
146
|
+
"types": "./dist/build/report.d.ts",
|
|
147
|
+
"import": "./dist/build/report.js"
|
|
148
|
+
},
|
|
141
149
|
"./internal/cache-adapters": {
|
|
142
150
|
"types": "./dist/cache/cache-adapters-virtual.d.ts",
|
|
143
151
|
"import": "./dist/cache/cache-adapters-virtual.js"
|
|
@@ -209,7 +217,7 @@
|
|
|
209
217
|
},
|
|
210
218
|
"dependencies": {
|
|
211
219
|
"@unpic/react": "^1.0.2",
|
|
212
|
-
"@vercel/og": "
|
|
220
|
+
"@vercel/og": "1.0.3",
|
|
213
221
|
"ipaddr.js": "^2.1.0",
|
|
214
222
|
"magic-string": "^0.30.21",
|
|
215
223
|
"vite-plugin-commonjs": "^0.10.4",
|