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
|
@@ -25,6 +25,7 @@ export type CloudflarePlatformSetupResult = {
|
|
|
25
25
|
export declare function validateCloudflarePlatformSetup(context: CloudflarePlatformSetupContext, cloudflare: CloudflareInitOptions): void;
|
|
26
26
|
export declare function setupCloudflarePlatform(context: CloudflarePlatformSetupContext, cloudflare: CloudflareInitOptions): CloudflarePlatformSetupResult;
|
|
27
27
|
export declare function generateWranglerConfig(info: CloudflareProjectInfo, options?: CloudflareInitOptions, today?: string): string;
|
|
28
|
+
export declare function compactResourceName(name: string, suffix: string, maxLength: number): string;
|
|
28
29
|
export declare function generateResponseStoreWranglerConfig(appWranglerCode: string, root: string): string;
|
|
29
30
|
export declare function updateWranglerConfigForCloudflare(code: string, options: CloudflareInitOptions, context?: {
|
|
30
31
|
root?: string;
|
|
@@ -32,9 +33,9 @@ export declare function updateWranglerConfigForCloudflare(code: string, options:
|
|
|
32
33
|
export declare function getWranglerImagesBinding(code: string): string;
|
|
33
34
|
export declare function getWranglerVersionMetadataBinding(code: string): string;
|
|
34
35
|
/** Generate vite.config.ts for App Router */
|
|
35
|
-
export declare function generateAppRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, prerender?: boolean, versionMetadataBinding?: string): string;
|
|
36
|
+
export declare function generateAppRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, prerender?: boolean, versionMetadataBinding?: string, serviceBinding?: boolean): string;
|
|
36
37
|
/** Generate vite.config.ts for Pages Router */
|
|
37
|
-
export declare function generatePagesRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, prerender?: boolean, versionMetadataBinding?: string): string;
|
|
38
|
+
export declare function generatePagesRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, prerender?: boolean, versionMetadataBinding?: string, serviceBinding?: boolean): string;
|
|
38
39
|
export declare function updateViteConfigForCloudflare(filePath: string, code: string, options: {
|
|
39
40
|
isAppRouter: boolean;
|
|
40
41
|
nativeModulesToStub: string[];
|
package/dist/init-cloudflare.js
CHANGED
|
@@ -26,6 +26,25 @@ const CACHE_METADATA_EXPORT = {
|
|
|
26
26
|
};
|
|
27
27
|
const CTX_EXPORTS_DEFAULT_DATE = "2025-11-17";
|
|
28
28
|
function validateCloudflarePlatformSetup(context, cloudflare) {
|
|
29
|
+
if (cloudflare.experimentalCf) {
|
|
30
|
+
const existingWrangler = [
|
|
31
|
+
"wrangler.toml",
|
|
32
|
+
"wrangler.json",
|
|
33
|
+
"wrangler.jsonc",
|
|
34
|
+
RESPONSE_STORE_WRANGLER_CONFIG
|
|
35
|
+
].find((name) => fs.existsSync(path.join(context.root, name)));
|
|
36
|
+
if (existingWrangler) throw new Error(`--experimental-cf cannot replace an existing Wrangler config (${existingWrangler}). Migrate its bindings to cloudflare.config.ts first.`);
|
|
37
|
+
const typedConfigPath = path.join(context.root, "cloudflare.config.ts");
|
|
38
|
+
if (cloudflare.cdnCache === "response-store" && (cloudflare.responseStoreMode ?? "service-binding") === "service-binding" && fs.existsSync(typedConfigPath) && !fs.readFileSync(typedConfigPath, "utf-8").includes("export const responseStoreServiceBinding")) throw new Error("The existing cloudflare.config.ts must export responseStoreServiceBinding for the Response Store auxiliary Worker. Configure it before rerunning init.");
|
|
39
|
+
if (context.existingViteConfigPath && cloudflare.cdnCache === "response-store" && (cloudflare.responseStoreMode ?? "service-binding") === "service-binding" && !fs.readFileSync(context.existingViteConfigPath, "utf-8").includes("auxiliaryWorkers: [{ config: responseStoreServiceBinding }]")) throw new Error("--experimental-cf with Response Store service-binding requires a fresh Vite config so the auxiliary Worker is connected. Remove the existing Vite config or configure it manually.");
|
|
40
|
+
if (context.existingViteConfigPath) updateViteConfigForCloudflare(context.existingViteConfigPath, fs.readFileSync(context.existingViteConfigPath, "utf-8"), {
|
|
41
|
+
isAppRouter: context.isAppRouter,
|
|
42
|
+
nativeModulesToStub: detectProject(context.root).nativeModulesToStub,
|
|
43
|
+
cache: cloudflare,
|
|
44
|
+
prerender: context.prerender
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
29
48
|
const tomlPath = path.join(context.root, "wrangler.toml");
|
|
30
49
|
if (fs.existsSync(tomlPath)) throw new Error("wrangler.toml is not supported by vinext init. Convert it to wrangler.jsonc and rerun.");
|
|
31
50
|
const projectInfo = detectProject(context.root);
|
|
@@ -45,6 +64,7 @@ function validateCloudflarePlatformSetup(context, cloudflare) {
|
|
|
45
64
|
});
|
|
46
65
|
}
|
|
47
66
|
function setupCloudflarePlatform(context, cloudflare) {
|
|
67
|
+
if (cloudflare.experimentalCf) return setupExperimentalCfPlatform(context, cloudflare);
|
|
48
68
|
const projectInfo = detectProject(context.root);
|
|
49
69
|
const wranglerPath = ["wrangler.jsonc", "wrangler.json"].map((fileName) => path.join(context.root, fileName)).find((candidate) => fs.existsSync(candidate));
|
|
50
70
|
const wranglerCode = wranglerPath ? fs.readFileSync(wranglerPath, "utf-8") : void 0;
|
|
@@ -103,6 +123,96 @@ function setupCloudflarePlatform(context, cloudflare) {
|
|
|
103
123
|
nextSteps
|
|
104
124
|
};
|
|
105
125
|
}
|
|
126
|
+
function setupExperimentalCfPlatform(context, cloudflare) {
|
|
127
|
+
const projectInfo = detectProject(context.root);
|
|
128
|
+
const serviceBinding = cloudflare.cdnCache === "response-store" && (cloudflare.responseStoreMode ?? "service-binding") === "service-binding";
|
|
129
|
+
let generatedViteConfig = false;
|
|
130
|
+
if (context.existingViteConfigPath) {
|
|
131
|
+
const current = fs.readFileSync(context.existingViteConfigPath, "utf-8");
|
|
132
|
+
const updated = updateViteConfigForCloudflare(context.existingViteConfigPath, current, {
|
|
133
|
+
isAppRouter: context.isAppRouter,
|
|
134
|
+
nativeModulesToStub: projectInfo.nativeModulesToStub,
|
|
135
|
+
cache: cloudflare,
|
|
136
|
+
prerender: context.prerender
|
|
137
|
+
});
|
|
138
|
+
if (updated !== current) {
|
|
139
|
+
fs.writeFileSync(context.existingViteConfigPath, updated, "utf-8");
|
|
140
|
+
generatedViteConfig = true;
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
const viteConfig = context.isAppRouter ? generateAppRouterViteConfig(projectInfo, cloudflare, "IMAGES", context.prerender, DEFAULT_VERSION_METADATA_BINDING, serviceBinding) : generatePagesRouterViteConfig(projectInfo, cloudflare, "IMAGES", context.prerender, DEFAULT_VERSION_METADATA_BINDING, serviceBinding);
|
|
144
|
+
fs.writeFileSync(path.join(context.root, "vite.config.ts"), viteConfig, "utf-8");
|
|
145
|
+
generatedViteConfig = true;
|
|
146
|
+
}
|
|
147
|
+
const configPath = path.join(context.root, "cloudflare.config.ts");
|
|
148
|
+
const generatedPlatformFiles = [];
|
|
149
|
+
if (!fs.existsSync(configPath)) {
|
|
150
|
+
fs.writeFileSync(configPath, generateTypedCloudflareConfig(projectInfo, cloudflare, context.today));
|
|
151
|
+
generatedPlatformFiles.push("cloudflare.config.ts");
|
|
152
|
+
}
|
|
153
|
+
const nextSteps = [];
|
|
154
|
+
if (cloudflare.dataCache === "kv") nextSteps.push("Cloudflare setup is incomplete until you create a KV namespace:", ` cf kv namespaces create --title=${projectInfo.projectName}-cache`, "Copy its ID into VINEXT_KV_CACHE in cloudflare.config.ts (replace \"<your-kv-namespace-id>\").");
|
|
155
|
+
if (cloudflare.cdnCache === "response-store") {
|
|
156
|
+
const bucket = serviceBinding ? compactResourceName(`${projectInfo.projectName}-response-store`, "-cache-bodies", 63) : compactResourceName(projectInfo.projectName, "-response-store-cache-bodies", 63);
|
|
157
|
+
nextSteps.push(`Create the Response Store R2 bucket if needed: cf r2 buckets create --name=${bucket}`);
|
|
158
|
+
if (serviceBinding) nextSteps.push("After `vinext build`, deploy the Response Store Worker explicitly (and repeat when its code/config changes):", ` ${context.packageManager ?? "npm"} run deploy:response-store`, "vinext-cloudflare deploy only deploys the application Worker.");
|
|
159
|
+
}
|
|
160
|
+
nextSteps.push("For TypeScript, add \".cloudflare/types\" to the include list in tsconfig.json.", "Worker types are generated during dev/build; run `cf workers types` before standalone type-checks.");
|
|
161
|
+
return {
|
|
162
|
+
generatedViteConfig,
|
|
163
|
+
skippedViteConfig: !generatedViteConfig,
|
|
164
|
+
generatedPlatformFiles,
|
|
165
|
+
nextSteps
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function generateTypedCloudflareConfig(info, options, today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0]) {
|
|
169
|
+
const serviceBinding = options.cdnCache === "response-store" && (options.responseStoreMode ?? "service-binding") === "service-binding";
|
|
170
|
+
const selfContained = options.cdnCache === "response-store" && !serviceBinding;
|
|
171
|
+
const workersCache = options.cdnCache === "workers-cache";
|
|
172
|
+
const helper = serviceBinding ? "createWorkersResponseStoreServiceBindingConfig" : selfContained ? "createWorkersResponseStoreSelfContainedConfig" : workersCache ? "createWorkersCacheConfig" : void 0;
|
|
173
|
+
const imports = [`import { bindings, defineConfig, defineWorker } from "@cloudflare/vite-plugin/experimental-config";`, ...helper ? [`import { ${helper} } from "@vinext/cloudflare/cache/config";`] : []];
|
|
174
|
+
const responseStoreName = compactResourceName(info.projectName, "-response-store", 63);
|
|
175
|
+
const bucket = serviceBinding ? compactResourceName(responseStoreName, "-cache-bodies", 63) : compactResourceName(info.projectName, "-response-store-cache-bodies", 63);
|
|
176
|
+
const shared = serviceBinding ? `const responseStore = await ${helper}({
|
|
177
|
+
worker: {
|
|
178
|
+
name: ${JSON.stringify(responseStoreName)},
|
|
179
|
+
compatibilityDate: ${JSON.stringify(today)},
|
|
180
|
+
compatibilityFlags: ["nodejs_compat"],
|
|
181
|
+
},
|
|
182
|
+
bucket: ${JSON.stringify(bucket)},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
export const responseStoreServiceBinding = responseStore.serviceBindingWorker;
|
|
186
|
+
|
|
187
|
+
` : selfContained ? `const cache = await ${helper}({
|
|
188
|
+
worker: ${JSON.stringify(info.projectName)},
|
|
189
|
+
bucket: ${JSON.stringify(bucket)},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
` : workersCache ? `const cache = await ${helper}();\n\n` : "";
|
|
193
|
+
const cacheSpread = serviceBinding ? "responseStore.applicationWorker" : helper ? "cache" : void 0;
|
|
194
|
+
const envBindings = [
|
|
195
|
+
...cacheSpread ? [`...${cacheSpread}.env`] : [],
|
|
196
|
+
"ASSETS: bindings.assets()",
|
|
197
|
+
...options.imageOptimization === "cloudflare-images" ? ["IMAGES: bindings.images()"] : [],
|
|
198
|
+
...options.dataCache === "kv" ? ["VINEXT_KV_CACHE: bindings.kv({ id: \"<your-kv-namespace-id>\" })"] : []
|
|
199
|
+
];
|
|
200
|
+
return `${imports.join("\n")}
|
|
201
|
+
|
|
202
|
+
${shared}export default defineConfig({
|
|
203
|
+
worker: defineWorker({
|
|
204
|
+
${cacheSpread ? `...${cacheSpread},\n ` : ""}name: ${JSON.stringify(info.projectName)},
|
|
205
|
+
entrypoint: ${JSON.stringify(resolveWorkerEntry(info.root))},
|
|
206
|
+
compatibilityDate: ${JSON.stringify(today)},
|
|
207
|
+
compatibilityFlags: ["nodejs_compat"],
|
|
208
|
+
assets: { notFoundHandling: "none" },
|
|
209
|
+
env: {
|
|
210
|
+
${envBindings.join(",\n ")},
|
|
211
|
+
},
|
|
212
|
+
}),
|
|
213
|
+
});
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
106
216
|
/**
|
|
107
217
|
* `main` is what makes a Wrangler config a Worker rather than a static-assets
|
|
108
218
|
* project. A custom `worker/index.*` wins when present; otherwise the
|
|
@@ -587,11 +697,12 @@ function vinextExpression(options, binding = "vinext", imageBinding = "imagesOpt
|
|
|
587
697
|
return optionEntries.length === 0 ? `${binding}()` : `${binding}({\n ${optionEntries.join(",\n ")},\n})`;
|
|
588
698
|
}
|
|
589
699
|
/** Generate vite.config.ts for App Router */
|
|
590
|
-
function generateAppRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPTIONS, imagesBinding = "IMAGES", prerender = false, versionMetadataBinding = DEFAULT_VERSION_METADATA_BINDING) {
|
|
700
|
+
function generateAppRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPTIONS, imagesBinding = "IMAGES", prerender = false, versionMetadataBinding = DEFAULT_VERSION_METADATA_BINDING, serviceBinding = false) {
|
|
591
701
|
const imports = [
|
|
592
702
|
`import { defineConfig } from "vite";`,
|
|
593
703
|
`import vinext from "vinext";`,
|
|
594
704
|
`import { cloudflare } from "@cloudflare/vite-plugin";`,
|
|
705
|
+
...serviceBinding ? ["import { responseStoreServiceBinding } from \"./cloudflare.config.ts\";"] : [],
|
|
595
706
|
...cacheImports(options)
|
|
596
707
|
];
|
|
597
708
|
if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) imports.push(`import path from "node:path";`);
|
|
@@ -599,7 +710,7 @@ function generateAppRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPT
|
|
|
599
710
|
if (info?.hasMDX) plugins.push(` // vinext auto-injects @mdx-js/rollup with plugins from next.config`);
|
|
600
711
|
plugins.push(` ${vinextExpression(options, "vinext", "imagesOptimizer", imagesBinding, prerender, versionMetadataBinding).replace(/\n/g, "\n ")},`);
|
|
601
712
|
plugins.push(` cloudflare({
|
|
602
|
-
viteEnvironment: {
|
|
713
|
+
${serviceBinding ? "auxiliaryWorkers: [{ config: responseStoreServiceBinding }],\n " : ""}viteEnvironment: {
|
|
603
714
|
name: "rsc",
|
|
604
715
|
childEnvironments: ["ssr"],
|
|
605
716
|
},
|
|
@@ -618,11 +729,12 @@ ${plugins.join("\n")}
|
|
|
618
729
|
`;
|
|
619
730
|
}
|
|
620
731
|
/** Generate vite.config.ts for Pages Router */
|
|
621
|
-
function generatePagesRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPTIONS, imagesBinding = "IMAGES", prerender = false, versionMetadataBinding = DEFAULT_VERSION_METADATA_BINDING) {
|
|
732
|
+
function generatePagesRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPTIONS, imagesBinding = "IMAGES", prerender = false, versionMetadataBinding = DEFAULT_VERSION_METADATA_BINDING, serviceBinding = false) {
|
|
622
733
|
const imports = [
|
|
623
734
|
`import { defineConfig } from "vite";`,
|
|
624
735
|
`import vinext from "vinext";`,
|
|
625
736
|
`import { cloudflare } from "@cloudflare/vite-plugin";`,
|
|
737
|
+
...serviceBinding ? ["import { responseStoreServiceBinding } from \"./cloudflare.config.ts\";"] : [],
|
|
626
738
|
...cacheImports(options)
|
|
627
739
|
];
|
|
628
740
|
if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) imports.push(`import path from "node:path";`);
|
|
@@ -635,7 +747,7 @@ function generatePagesRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_O
|
|
|
635
747
|
export default defineConfig({
|
|
636
748
|
plugins: [
|
|
637
749
|
${vinextExpression(options, "vinext", "imagesOptimizer", imagesBinding, prerender, versionMetadataBinding).replace(/\n/g, "\n ")},
|
|
638
|
-
cloudflare(),
|
|
750
|
+
cloudflare(${serviceBinding ? "{ auxiliaryWorkers: [{ config: responseStoreServiceBinding }] }" : ""}),
|
|
639
751
|
],${resolveBlock}
|
|
640
752
|
});
|
|
641
753
|
`;
|
|
@@ -1202,4 +1314,4 @@ function usesCommonJsViteConfig(filePath, code) {
|
|
|
1202
1314
|
return parseViteConfig(filePath, code).body.some((statement) => statement.type === "ExpressionStatement" && statement.expression.type === "AssignmentExpression" && statement.expression.left.type === "MemberExpression" && statement.expression.left.object.type === "Identifier" && statement.expression.left.object.name === "module" && statement.expression.left.property.type === "Identifier" && statement.expression.left.property.name === "exports");
|
|
1203
1315
|
}
|
|
1204
1316
|
//#endregion
|
|
1205
|
-
export { generateAppRouterViteConfig, generatePagesRouterViteConfig, generateResponseStoreWranglerConfig, generateWranglerConfig, getWranglerImagesBinding, getWranglerVersionMetadataBinding, setupCloudflarePlatform, updateViteConfigForCloudflare, updateWranglerConfigForCloudflare, usesCommonJsViteConfig, validateCloudflarePlatformSetup };
|
|
1317
|
+
export { compactResourceName, generateAppRouterViteConfig, generatePagesRouterViteConfig, generateResponseStoreWranglerConfig, generateWranglerConfig, getWranglerImagesBinding, getWranglerVersionMetadataBinding, setupCloudflarePlatform, updateViteConfigForCloudflare, updateWranglerConfigForCloudflare, usesCommonJsViteConfig, validateCloudflarePlatformSetup };
|
package/dist/init-platform.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type CloudflareInitOptions = {
|
|
|
11
11
|
imageOptimization: InitImageOptimization;
|
|
12
12
|
responseStoreMode?: InitResponseStoreMode;
|
|
13
13
|
warmCdnCache?: boolean;
|
|
14
|
+
experimentalCf?: boolean;
|
|
14
15
|
};
|
|
15
16
|
export declare const INIT_PLATFORMS: {
|
|
16
17
|
cloudflare: {
|
|
@@ -42,6 +43,7 @@ export declare function parseImageOptimizationArg(args: string[]): InitImageOpti
|
|
|
42
43
|
export declare function parseResponseStoreModeArg(args: string[]): InitResponseStoreMode | undefined;
|
|
43
44
|
export declare function parsePrerenderArg(args: string[]): boolean | undefined;
|
|
44
45
|
export declare function parseWarmCdnCacheArg(args: string[]): boolean | undefined;
|
|
46
|
+
export declare function parseExperimentalCfArg(args: string[]): boolean | undefined;
|
|
45
47
|
export declare function resolveInitPlatform(args: string[], options?: PlatformPromptOptions): Promise<InitPlatform>;
|
|
46
48
|
export declare function resolveInitOptions(args: string[], options?: PlatformPromptOptions): Promise<ResolvedInitOptions>;
|
|
47
49
|
export declare function resolveInitPrerender(args: string[], options?: PlatformPromptOptions): Promise<boolean>;
|
package/dist/init-platform.js
CHANGED
|
@@ -71,6 +71,9 @@ function parsePrerenderArg(args) {
|
|
|
71
71
|
function parseWarmCdnCacheArg(args) {
|
|
72
72
|
return parseBooleanArg(args, "--experimental-warm-cdn-cache", "--no-experimental-warm-cdn-cache", "--experimental-warm-cdn-cache expects true or false when using the \"--experimental-warm-cdn-cache=value\" form.");
|
|
73
73
|
}
|
|
74
|
+
function parseExperimentalCfArg(args) {
|
|
75
|
+
return parseBooleanArg(args, "--experimental-cf", void 0, "--experimental-cf expects true or false when using the \"--experimental-cf=value\" form.");
|
|
76
|
+
}
|
|
74
77
|
function parseBooleanArg(args, enabledFlag, disabledFlag, errorMessage) {
|
|
75
78
|
for (const arg of args) {
|
|
76
79
|
if (arg === enabledFlag) return true;
|
|
@@ -113,9 +116,11 @@ async function resolveInitPlatform(args, options = {}) {
|
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
async function resolveInitOptions(args, options = {}) {
|
|
116
|
-
const
|
|
119
|
+
const experimentalCf = parseExperimentalCfArg(args);
|
|
120
|
+
const platform = experimentalCf && !parsePlatformArg(args) ? "cloudflare" : await resolveInitPlatform(args, options);
|
|
117
121
|
const platformOptions = await INIT_PLATFORMS[platform].options(args, options);
|
|
118
122
|
const explicitWarmCdnCache = parseWarmCdnCacheArg(args);
|
|
123
|
+
if (experimentalCf && platform !== "cloudflare") throw new Error("--experimental-cf requires --platform=cloudflare.");
|
|
119
124
|
const explicitPrerender = parsePrerenderArg(args);
|
|
120
125
|
const supportsWarmCdnCache = platformOptions?.cdnCache === "response-store" || platformOptions?.cdnCache === "workers-cache";
|
|
121
126
|
if (platform === "cloudflare" && !supportsWarmCdnCache) {
|
|
@@ -128,7 +133,8 @@ async function resolveInitOptions(args, options = {}) {
|
|
|
128
133
|
prerender,
|
|
129
134
|
cloudflare: platform === "cloudflare" && platformOptions ? {
|
|
130
135
|
...platformOptions,
|
|
131
|
-
warmCdnCache
|
|
136
|
+
warmCdnCache,
|
|
137
|
+
...experimentalCf ? { experimentalCf } : {}
|
|
132
138
|
} : void 0
|
|
133
139
|
};
|
|
134
140
|
}
|
|
@@ -305,4 +311,4 @@ async function resolveCloudflareInitOptions(args, options = {}) {
|
|
|
305
311
|
}
|
|
306
312
|
}
|
|
307
313
|
//#endregion
|
|
308
|
-
export { INIT_PLATFORMS, isAgentEnvironment, parseCdnCacheArg, parseDataCacheArg, parseImageOptimizationArg, parsePlatformArg, parsePrerenderArg, parseResponseStoreModeArg, parseWarmCdnCacheArg, resolveCloudflareInitOptions, resolveInitOptions, resolveInitPlatform, resolveInitPrerender, resolveInitWarmCdnCache };
|
|
314
|
+
export { INIT_PLATFORMS, isAgentEnvironment, parseCdnCacheArg, parseDataCacheArg, parseExperimentalCfArg, parseImageOptimizationArg, parsePlatformArg, parsePrerenderArg, parseResponseStoreModeArg, parseWarmCdnCacheArg, resolveCloudflareInitOptions, resolveInitOptions, resolveInitPlatform, resolveInitPrerender, resolveInitWarmCdnCache };
|
package/dist/init.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ type InitResult = {
|
|
|
37
37
|
addedTypeModule: boolean;
|
|
38
38
|
/** CJS config files that were renamed ([old, new] pairs) */
|
|
39
39
|
renamedConfigs: Array<[string, string]>;
|
|
40
|
-
/**
|
|
40
|
+
/** Scripts added to package.json or migrated from older generated values */
|
|
41
41
|
addedScripts: string[];
|
|
42
42
|
/** Whether vite.config.ts was generated */
|
|
43
43
|
generatedViteConfig: boolean;
|
|
@@ -52,12 +52,14 @@ type InitResult = {
|
|
|
52
52
|
};
|
|
53
53
|
export declare function generateViteConfig(_isAppRouter: boolean, prerender?: boolean): string;
|
|
54
54
|
/**
|
|
55
|
-
* Add
|
|
56
|
-
*
|
|
55
|
+
* Add Vite scripts to package.json without overwriting custom scripts.
|
|
56
|
+
* Exact scripts generated by older vinext versions are migrated in place.
|
|
57
|
+
* Returns the list of script names that were added or migrated.
|
|
57
58
|
*/
|
|
58
|
-
export declare function addScripts(root: string, port
|
|
59
|
+
export declare function addScripts(root: string, port?: number | false, platform?: InitPlatform, options?: {
|
|
59
60
|
deployResponseStore?: boolean;
|
|
60
61
|
warmCdnCache?: boolean;
|
|
62
|
+
experimentalCf?: boolean;
|
|
61
63
|
scriptNames?: "namespaced" | "standard";
|
|
62
64
|
}): string[];
|
|
63
65
|
export type InitDependencyGroups = {
|
|
@@ -72,7 +74,7 @@ export declare function isDepInstalled(root: string, dep: string): boolean;
|
|
|
72
74
|
* Creates the file if it doesn't exist. Returns true if the file was modified
|
|
73
75
|
* (or created), false if all entries were already present.
|
|
74
76
|
*/
|
|
75
|
-
export declare function updateGitignore(root: string, platform?: InitPlatform): boolean;
|
|
77
|
+
export declare function updateGitignore(root: string, platform?: InitPlatform, experimentalCf?: boolean): boolean;
|
|
76
78
|
export declare function init(options: InitOptions): Promise<InitResult>;
|
|
77
79
|
//#endregion
|
|
78
80
|
export { getReactUpgradeDeps };
|
package/dist/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { detectPackageManager, detectPackageManagerName, detectProject, ensureESModule, findViteConfigPath, hasViteConfig, renameCJSConfigs } from "./utils/project.js";
|
|
3
|
-
import { setupCloudflarePlatform, usesCommonJsViteConfig, validateCloudflarePlatformSetup } from "./init-cloudflare.js";
|
|
3
|
+
import { compactResourceName, setupCloudflarePlatform, usesCommonJsViteConfig, validateCloudflarePlatformSetup } from "./init-cloudflare.js";
|
|
4
4
|
import { getReactUpgradeDeps } from "./utils/react-version.js";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -67,8 +67,9 @@ export default defineConfig({
|
|
|
67
67
|
`;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* Add
|
|
71
|
-
*
|
|
70
|
+
* Add Vite scripts to package.json without overwriting custom scripts.
|
|
71
|
+
* Exact scripts generated by older vinext versions are migrated in place.
|
|
72
|
+
* Returns the list of script names that were added or migrated.
|
|
72
73
|
*/
|
|
73
74
|
function addScripts(root, port, platform = "node", options = {}) {
|
|
74
75
|
const pkgPath = path.join(root, "package.json");
|
|
@@ -78,19 +79,23 @@ function addScripts(root, port, platform = "node", options = {}) {
|
|
|
78
79
|
const pkg = JSON.parse(raw);
|
|
79
80
|
if (!pkg.scripts) pkg.scripts = {};
|
|
80
81
|
const added = [];
|
|
81
|
-
const addScript = (name, command) => {
|
|
82
|
+
const addScript = (name, command, legacyCommands = []) => {
|
|
82
83
|
const scriptName = options.scriptNames === "standard" ? name : `${name}:vinext`;
|
|
83
|
-
|
|
84
|
+
const existing = pkg.scripts[scriptName];
|
|
85
|
+
if (existing && !legacyCommands.some((legacy) => typeof legacy === "string" ? existing === legacy : legacy.test(existing))) return;
|
|
86
|
+
if (existing === command) return;
|
|
84
87
|
pkg.scripts[scriptName] = command;
|
|
85
88
|
added.push(scriptName);
|
|
86
89
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
addScript("
|
|
90
|
+
const devScriptName = options.scriptNames === "standard" ? "dev" : "dev:vinext";
|
|
91
|
+
const legacyDevScript = pkg.scripts[devScriptName];
|
|
92
|
+
addScript("dev", port === void 0 && typeof legacyDevScript === "string" && /^vinext dev(?: --port \d+)?$/.test(legacyDevScript) ? legacyDevScript.replace(/^vinext /, "vite ") : port === false ? "vite dev" : `vite dev --port ${port ?? 3001}`, ["vinext dev", /^vinext dev --port \d+$/]);
|
|
93
|
+
addScript("build", "vite build", ["vinext build"]);
|
|
94
|
+
addScript("start", platform === "cloudflare" ? options.experimentalCf ? "vite preview" : "wrangler dev --config dist/server/wrangler.json" : "vinext start");
|
|
90
95
|
if (platform === "cloudflare") {
|
|
91
|
-
addScript("deploy", options.warmCdnCache ? "vinext-cloudflare deploy --config dist/server/wrangler.json --experimental-warm-cdn-cache" : "vinext-cloudflare deploy --config dist/server/wrangler.json");
|
|
96
|
+
addScript("deploy", options.experimentalCf ? options.warmCdnCache ? "vinext-cloudflare deploy --experimental-warm-cdn-cache" : "vinext-cloudflare deploy" : options.warmCdnCache ? "vinext-cloudflare deploy --config dist/server/wrangler.json --experimental-warm-cdn-cache" : "vinext-cloudflare deploy --config dist/server/wrangler.json");
|
|
92
97
|
if (options.deployResponseStore && !pkg.scripts["deploy:response-store"]) {
|
|
93
|
-
pkg.scripts["deploy:response-store"] = "wrangler deploy --config wrangler.response-store.jsonc";
|
|
98
|
+
pkg.scripts["deploy:response-store"] = options.experimentalCf ? `cf deploy --prebuilt --mode production --worker ${compactResourceName(detectProject(root).projectName, "-response-store", 63)}` : "wrangler deploy --config wrangler.response-store.jsonc";
|
|
94
99
|
added.push("deploy:response-store");
|
|
95
100
|
}
|
|
96
101
|
}
|
|
@@ -110,7 +115,10 @@ function getInitDependencyGroups(isAppRouter, platform, cloudflare) {
|
|
|
110
115
|
if (platform === "cloudflare") {
|
|
111
116
|
dependencies.push("@vinext/cloudflare");
|
|
112
117
|
if (cloudflare?.cdnCache === "response-store" && (cloudflare.responseStoreMode ?? "service-binding") === "service-binding") dependencies.push("@cloudflare/workers-response-store");
|
|
113
|
-
|
|
118
|
+
if (cloudflare?.experimentalCf) {
|
|
119
|
+
devDependencies[0] = "vite@8.3.0";
|
|
120
|
+
devDependencies.push("@cloudflare/vite-plugin@beta", "cf@latest");
|
|
121
|
+
} else devDependencies.push("@cloudflare/vite-plugin", "wrangler");
|
|
114
122
|
}
|
|
115
123
|
return {
|
|
116
124
|
dependencies,
|
|
@@ -126,11 +134,13 @@ function isDepInstalled(root, dep) {
|
|
|
126
134
|
if (!fs.existsSync(pkgPath)) return false;
|
|
127
135
|
try {
|
|
128
136
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
129
|
-
|
|
137
|
+
const allDeps = {
|
|
130
138
|
...pkg.dependencies,
|
|
131
139
|
...pkg.devDependencies,
|
|
132
140
|
...pkg.peerDependencies
|
|
133
141
|
};
|
|
142
|
+
const { name, version, hasExplicitVersion } = parseDependencySpecifier(dep);
|
|
143
|
+
return name in allDeps && (!hasExplicitVersion || allDeps[name] === version);
|
|
134
144
|
} catch {
|
|
135
145
|
return false;
|
|
136
146
|
}
|
|
@@ -201,7 +211,7 @@ function addDependencyEntries(root, deps, { dev }) {
|
|
|
201
211
|
async function installDeps(root, deps, exec, { dev = true } = {}) {
|
|
202
212
|
if (deps.length === 0) return "";
|
|
203
213
|
const baseCmd = detectPackageManager(root);
|
|
204
|
-
return await exec(`${dev ? baseCmd : baseCmd.replace(/ -D$/, "")} ${deps.join(" ")}`, {
|
|
214
|
+
return await exec(`${dev ? baseCmd : baseCmd.replace(/ -D$/, "")} ${deps.map((dep) => JSON.stringify(dep)).join(" ")}`, {
|
|
205
215
|
cwd: root,
|
|
206
216
|
stdio: "inherit"
|
|
207
217
|
}) ?? "";
|
|
@@ -211,7 +221,7 @@ async function installDeps(root, deps, exec, { dev = true } = {}) {
|
|
|
211
221
|
* Creates the file if it doesn't exist. Returns true if the file was modified
|
|
212
222
|
* (or created), false if all entries were already present.
|
|
213
223
|
*/
|
|
214
|
-
function updateGitignore(root, platform = "node") {
|
|
224
|
+
function updateGitignore(root, platform = "node", experimentalCf = false) {
|
|
215
225
|
const gitignorePath = path.join(root, ".gitignore");
|
|
216
226
|
const entries = [
|
|
217
227
|
{
|
|
@@ -232,7 +242,7 @@ function updateGitignore(root, platform = "node") {
|
|
|
232
242
|
".vinext"
|
|
233
243
|
])
|
|
234
244
|
},
|
|
235
|
-
...platform === "cloudflare" ? [{
|
|
245
|
+
...platform === "cloudflare" && !experimentalCf ? [{
|
|
236
246
|
entry: ".wrangler/",
|
|
237
247
|
coveredBy: /* @__PURE__ */ new Set([
|
|
238
248
|
"/.wrangler/",
|
|
@@ -240,6 +250,15 @@ function updateGitignore(root, platform = "node") {
|
|
|
240
250
|
".wrangler/",
|
|
241
251
|
".wrangler"
|
|
242
252
|
])
|
|
253
|
+
}] : [],
|
|
254
|
+
...experimentalCf ? [{
|
|
255
|
+
entry: ".cloudflare/",
|
|
256
|
+
coveredBy: /* @__PURE__ */ new Set([
|
|
257
|
+
"/.cloudflare/",
|
|
258
|
+
"/.cloudflare",
|
|
259
|
+
".cloudflare/",
|
|
260
|
+
".cloudflare"
|
|
261
|
+
])
|
|
243
262
|
}] : []
|
|
244
263
|
];
|
|
245
264
|
let content = "";
|
|
@@ -271,7 +290,6 @@ function setupNodePlatform(context) {
|
|
|
271
290
|
}
|
|
272
291
|
async function init(options) {
|
|
273
292
|
const root = path.resolve(options.root);
|
|
274
|
-
const port = options.port ?? 3001;
|
|
275
293
|
if (!options.platform) throw new Error("A deployment platform must be selected before running vinext init.");
|
|
276
294
|
const platform = options.platform;
|
|
277
295
|
if (platform === "cloudflare" && !options.cloudflare) throw new Error("Cloudflare init options must be resolved before running vinext init.");
|
|
@@ -343,9 +361,10 @@ async function init(options) {
|
|
|
343
361
|
existingViteConfigPath = renamedPath;
|
|
344
362
|
}
|
|
345
363
|
const addedTypeModule = ensureESModule(root);
|
|
346
|
-
const addedScripts = addScripts(root, port, platform, {
|
|
364
|
+
const addedScripts = addScripts(root, options.port, platform, {
|
|
347
365
|
deployResponseStore: options.cloudflare?.cdnCache === "response-store" && (options.cloudflare.responseStoreMode ?? "service-binding") === "service-binding",
|
|
348
366
|
warmCdnCache: options.cloudflare?.warmCdnCache ?? false,
|
|
367
|
+
experimentalCf: options.cloudflare?.experimentalCf ?? false,
|
|
349
368
|
scriptNames: options.scriptNames
|
|
350
369
|
});
|
|
351
370
|
const setupContext = {
|
|
@@ -360,15 +379,15 @@ async function init(options) {
|
|
|
360
379
|
};
|
|
361
380
|
const platformSetup = platform === "cloudflare" ? setupCloudflarePlatform(setupContext, options.cloudflare) : setupNodePlatform(setupContext);
|
|
362
381
|
const { generatedViteConfig, skippedViteConfig, generatedPlatformFiles } = platformSetup;
|
|
363
|
-
const updatedGitignore = updateGitignore(root, platform);
|
|
382
|
+
const updatedGitignore = updateGitignore(root, platform, options.cloudflare?.experimentalCf);
|
|
364
383
|
const neededDeps = getInitDependencyGroups(isApp, platform, options.cloudflare);
|
|
365
384
|
const missingDependencies = neededDeps.dependencies.filter((dep) => !isDepInstalled(root, dep));
|
|
366
385
|
const missingDevDependencies = neededDeps.devDependencies.filter((dep) => !isDepInstalled(root, dep));
|
|
367
386
|
let dependencyInstallNeedsApproval = false;
|
|
368
387
|
const dependencyEntriesAdded = [];
|
|
369
388
|
const devDependencyEntriesAdded = [];
|
|
370
|
-
if (isApp && missingDependencies.includes("react-server-dom-webpack")) {
|
|
371
|
-
const reactUpgrade = getReactUpgradeDeps(root);
|
|
389
|
+
if (isApp && (!shouldInstall || missingDependencies.includes("react-server-dom-webpack"))) {
|
|
390
|
+
const reactUpgrade = getReactUpgradeDeps(root, { fromManifest: !shouldInstall });
|
|
372
391
|
if (reactUpgrade.length > 0) {
|
|
373
392
|
console.log(` ${terminalStyle.cyan(terminalStyle.bold("Upgrading dependencies:"))}`);
|
|
374
393
|
console.log(formatList(reactUpgrade.map((dep) => dep.replace(/@latest$/, "")), " "));
|
|
@@ -435,7 +454,7 @@ async function init(options) {
|
|
|
435
454
|
if (dependencyInstallNeedsApproval) console.log(` ${terminalStyle.yellow("!")} Dependency installation is waiting for build-script approval`);
|
|
436
455
|
if (addedTypeModule) console.log(` ${terminalStyle.green("✓")} Added "type": "module" to package.json`);
|
|
437
456
|
for (const [oldName, newName] of renamedConfigs) console.log(` ${terminalStyle.green("✓")} Renamed ${oldName} \u2192 ${newName}`);
|
|
438
|
-
for (const script of addedScripts) console.log(` ${terminalStyle.green("✓")}
|
|
457
|
+
for (const script of addedScripts) console.log(` ${terminalStyle.green("✓")} Configured ${script} script`);
|
|
439
458
|
if (generatedViteConfig) console.log(` ${terminalStyle.green("✓")} Generated vite.config.ts`);
|
|
440
459
|
for (const file of generatedPlatformFiles) console.log(` ${terminalStyle.green("✓")} Generated ${file}`);
|
|
441
460
|
if (skippedViteConfig) console.log(` ${terminalStyle.yellow("-")} Skipped vite.config.ts (already exists, use --force to overwrite)`);
|
|
@@ -444,7 +463,7 @@ async function init(options) {
|
|
|
444
463
|
if (dependencyInstallNeedsApproval) nextSteps.push("Dependency installation is incomplete because pnpm blocked dependency build scripts:", "1. Review and approve the required build scripts:", " pnpm approve-builds", "2. Finish installing dependencies:", " pnpm install");
|
|
445
464
|
const scriptName = (name) => options.scriptNames === "standard" ? name : `${name}:vinext`;
|
|
446
465
|
const deployCommandStep = platform === "cloudflare" ? ` ${pmName} run ${scriptName("deploy")} Deploy to Cloudflare Workers\n` : "";
|
|
447
|
-
const startCommandDescription = platform === "cloudflare" ? "Start the built Worker locally with Wrangler" : "Start vinext production server";
|
|
466
|
+
const startCommandDescription = platform === "cloudflare" ? options.cloudflare?.experimentalCf ? "Preview the built Worker locally" : "Start the built Worker locally with Wrangler" : "Start vinext production server";
|
|
448
467
|
console.log(`
|
|
449
468
|
${terminalStyle.cyan(terminalStyle.bold("Next steps:"))}
|
|
450
469
|
${nextSteps.map((step) => ` ${step}`).join("\n")}${nextSteps.length > 0 ? "\n" : ""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
-
import { stripViteModuleQuery } from "../utils/path.js";
|
|
3
2
|
import { hasTrailingComma } from "../utils/has-trailing-comma.js";
|
|
4
3
|
import { magicStringTransformResult } from "./transform-result.js";
|
|
4
|
+
import { stripViteModuleQuery } from "../utils/path.js";
|
|
5
5
|
import { collectBindingNames, forEachAstChild, stringLiteralValue, walkAst } from "./ast-utils.js";
|
|
6
6
|
import { relativeWithinRoot, tryRealpathSync } from "../build/ssr-manifest.js";
|
|
7
7
|
import { parseAst } from "vite";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
-
import { escapeRegExp } from "../utils/regex.js";
|
|
3
2
|
import { isUnknownRecord } from "../utils/record.js";
|
|
4
|
-
import {
|
|
3
|
+
import { escapeRegExp } from "../utils/regex.js";
|
|
5
4
|
import { magicStringTransformResult } from "./transform-result.js";
|
|
5
|
+
import { NODE_MODULES_PATH_RE } from "../utils/path.js";
|
|
6
6
|
import { DYNAMIC_IMPORT_PRESCAN, SCRIPT_MODULE_ID_RE, scriptParserLanguage, walkAst } from "./ast-utils.js";
|
|
7
7
|
import { createTransformCache } from "./transform-cache.js";
|
|
8
8
|
import { createRequire } from "node:module";
|
package/dist/plugins/fonts.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { escapeRegExp } from "../utils/regex.js";
|
|
3
|
-
import { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
|
|
4
3
|
import { lastSignificantChar } from "../utils/has-trailing-comma.js";
|
|
5
4
|
import { magicStringTransformResult } from "./transform-result.js";
|
|
6
5
|
import { buildFallbackFontFace, getFallbackFontOverrideMetrics } from "../build/google-fonts/fallback-metrics.js";
|
|
@@ -8,6 +7,7 @@ import { validateGoogleFontOptions } from "../build/google-fonts/validate.js";
|
|
|
8
7
|
import { getFontAxes } from "../build/google-fonts/get-axes.js";
|
|
9
8
|
import { buildGoogleFontsUrl } from "../build/google-fonts/build-url.js";
|
|
10
9
|
import { findFontFilesInCss } from "../build/google-fonts/find-font-files-in-css.js";
|
|
10
|
+
import { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
|
|
11
11
|
import { CONTENT_TYPES } from "../server/static-file-cache.js";
|
|
12
12
|
import fs from "node:fs";
|
|
13
13
|
import { parseAst } from "vite";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
-
import { stripViteModuleQuery } from "../utils/path.js";
|
|
3
2
|
import { magicStringTransformResult } from "./transform-result.js";
|
|
3
|
+
import { stripViteModuleQuery } from "../utils/path.js";
|
|
4
4
|
import { DYNAMIC_IMPORT_PRESCAN, SCRIPT_MODULE_ID_RE, collectBindingNames, forEachAstChild, isIdentifierNamed, mayContainDynamicImport, scriptParserLanguage, stringLiteralValue, unwrapExpression } from "./ast-utils.js";
|
|
5
5
|
import { collectDirectScopeBindings, collectLoopScopeBindings, collectSwitchScopeBindings, collectVarScopeBindings, hasAstBinding, isFunctionNode } from "./ast-scope.js";
|
|
6
6
|
import { createTransformCache } from "./transform-cache.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
-
import { canonicalizeFilePath, isPathInsideOrEqual, stripViteModuleQuery } from "../utils/path.js";
|
|
3
2
|
import { magicStringTransformResult } from "./transform-result.js";
|
|
3
|
+
import { canonicalizeFilePath, isPathInsideOrEqual, stripViteModuleQuery } from "../utils/path.js";
|
|
4
4
|
import { VIRTUAL_MODULE_ID_RE } from "../utils/virtual-module.js";
|
|
5
5
|
import { SCRIPT_MODULE_ID_RE, collectBindingNames, forEachAstChild, isIdentifierNamed, scriptParserLanguage } from "./ast-utils.js";
|
|
6
6
|
import fs from "node:fs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stripViteModuleQuery } from "../utils/path.js";
|
|
2
1
|
import { magicStringTransformResult } from "./transform-result.js";
|
|
2
|
+
import { stripViteModuleQuery } from "../utils/path.js";
|
|
3
3
|
import { normalizePath, parseAst } from "vite";
|
|
4
4
|
import MagicString from "magic-string";
|
|
5
5
|
//#region src/plugins/instrumentation-client.ts
|