vinext 0.1.8 → 0.2.1
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 +51 -30
- package/dist/build/css-url-assets.d.ts +3 -1
- package/dist/build/css-url-assets.js +18 -1
- package/dist/build/inject-pregenerated-paths.d.ts +7 -0
- package/dist/build/inject-pregenerated-paths.js +21 -0
- package/dist/build/layout-classification.js +1 -1
- package/dist/build/nitro-route-rules.js +1 -1
- package/dist/build/pages-client-assets-module.d.ts +11 -0
- package/dist/build/pages-client-assets-module.js +27 -0
- package/dist/build/prerender-server-entry.d.ts +1 -0
- package/dist/build/prerender-server-entry.js +49 -0
- package/dist/build/prerender-server-pool.d.ts +44 -0
- package/dist/build/prerender-server-pool.js +194 -0
- package/dist/build/prerender.d.ts +2 -1
- package/dist/build/prerender.js +98 -27
- package/dist/build/report.d.ts +13 -2
- package/dist/build/report.js +99 -2
- package/dist/build/run-prerender.d.ts +7 -0
- package/dist/build/run-prerender.js +12 -2
- package/dist/build/standalone.js +2 -0
- package/dist/cache/cache-adapters-virtual.js +3 -3
- package/dist/check.d.ts +4 -6
- package/dist/check.js +48 -11
- package/dist/cli-args.d.ts +1 -2
- package/dist/cli-args.js +1 -1
- package/dist/cli-dev-config.d.ts +12 -0
- package/dist/cli-dev-config.js +23 -0
- package/dist/cli.js +112 -96
- package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay-store.js +1 -1
- package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
- package/dist/{server → client}/dev-error-overlay.js +2 -2
- package/dist/client/navigation-runtime.d.ts +2 -0
- package/dist/client/navigation-runtime.js +3 -1
- package/dist/client/vinext-next-data.d.ts +4 -1
- package/dist/client/window-next.d.ts +2 -1
- package/dist/cloudflare/index.d.ts +2 -2
- package/dist/cloudflare/index.js +2 -2
- package/dist/config/config-matchers.js +45 -19
- package/dist/config/next-config.d.ts +41 -9
- package/dist/config/next-config.js +60 -3
- package/dist/config/prerender.d.ts +34 -0
- package/dist/config/prerender.js +55 -0
- package/dist/entries/app-browser-entry.js +5 -1
- package/dist/entries/app-rsc-entry.d.ts +5 -3
- package/dist/entries/app-rsc-entry.js +44 -10
- package/dist/entries/app-rsc-manifest.js +2 -0
- package/dist/entries/pages-client-entry.d.ts +3 -0
- package/dist/entries/pages-client-entry.js +28 -3
- package/dist/entries/pages-server-entry.js +23 -6
- package/dist/image/image-adapters-virtual.d.ts +59 -0
- package/dist/image/image-adapters-virtual.js +59 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +482 -120
- package/dist/init-cloudflare.d.ts +43 -0
- package/dist/init-cloudflare.js +839 -0
- package/dist/init-platform.d.ts +40 -0
- package/dist/init-platform.js +195 -0
- package/dist/init.d.ts +16 -38
- package/dist/init.js +209 -99
- package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
- package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
- package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
- package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +9 -2
- package/dist/packages/cloudflare/src/deploy-config.js +150 -0
- package/dist/packages/cloudflare/src/deploy-help.js +55 -0
- package/dist/packages/cloudflare/src/deploy.js +272 -0
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.d.ts +4 -41
- package/dist/{cloudflare → packages/cloudflare/src}/tpr.js +44 -20
- package/dist/plugins/ast-scope.d.ts +16 -0
- package/dist/plugins/ast-scope.js +62 -0
- package/dist/plugins/ast-utils.d.ts +27 -1
- package/dist/plugins/ast-utils.js +32 -1
- package/dist/plugins/css-module-imports.d.ts +14 -0
- package/dist/plugins/css-module-imports.js +59 -0
- package/dist/plugins/extensionless-dynamic-import.js +2 -2
- package/dist/plugins/fonts.js +1 -1
- package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
- package/dist/plugins/ignore-dynamic-requests.js +530 -0
- package/dist/plugins/og-assets.js +2 -1
- package/dist/plugins/optimize-imports.js +1 -1
- package/dist/plugins/rsc-reference-validation-normalizer.d.ts +12 -0
- package/dist/plugins/rsc-reference-validation-normalizer.js +48 -0
- package/dist/plugins/sass.d.ts +17 -1
- package/dist/plugins/sass.js +74 -1
- package/dist/plugins/styled-jsx.d.ts +16 -0
- package/dist/plugins/styled-jsx.js +149 -0
- package/dist/plugins/typeof-window.d.ts +1 -1
- package/dist/plugins/typeof-window.js +28 -56
- package/dist/routing/app-route-graph.d.ts +23 -2
- package/dist/routing/app-route-graph.js +138 -38
- package/dist/routing/file-matcher.d.ts +11 -1
- package/dist/routing/file-matcher.js +18 -3
- package/dist/routing/pages-router.js +2 -2
- package/dist/server/api-handler.js +9 -14
- package/dist/server/app-browser-action-result.d.ts +4 -1
- package/dist/server/app-browser-action-result.js +8 -1
- package/dist/server/app-browser-entry.js +198 -57
- package/dist/server/app-browser-interception-context.d.ts +1 -0
- package/dist/server/app-browser-interception-context.js +4 -2
- package/dist/server/app-browser-navigation-controller.d.ts +2 -0
- package/dist/server/app-browser-navigation-controller.js +60 -31
- package/dist/server/app-browser-server-action-client.d.ts +1 -1
- package/dist/server/app-browser-server-action-client.js +8 -7
- package/dist/server/app-browser-state.d.ts +12 -1
- package/dist/server/app-browser-state.js +25 -8
- package/dist/server/app-browser-visible-commit.d.ts +6 -1
- package/dist/server/app-browser-visible-commit.js +42 -24
- package/dist/server/app-elements-wire.d.ts +9 -2
- package/dist/server/app-elements-wire.js +8 -1
- package/dist/server/app-elements.d.ts +2 -2
- package/dist/server/app-elements.js +4 -3
- package/dist/server/app-fallback-renderer.d.ts +2 -1
- package/dist/server/app-fallback-renderer.js +10 -6
- package/dist/server/app-hydration-cache-publication.d.ts +11 -0
- package/dist/server/app-hydration-cache-publication.js +43 -0
- package/dist/server/app-middleware.d.ts +4 -3
- package/dist/server/app-middleware.js +8 -3
- package/dist/server/app-optimistic-routing.js +11 -4
- package/dist/server/app-page-boundary.js +2 -1
- package/dist/server/app-page-cache-finalizer.d.ts +1 -0
- package/dist/server/app-page-cache-finalizer.js +5 -4
- package/dist/server/app-page-cache-render.d.ts +1 -0
- package/dist/server/app-page-cache-render.js +8 -4
- package/dist/server/app-page-cache.d.ts +1 -0
- package/dist/server/app-page-cache.js +27 -7
- package/dist/server/app-page-dispatch.d.ts +1 -0
- package/dist/server/app-page-dispatch.js +26 -8
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +59 -4
- package/dist/server/app-page-execution.js +2 -1
- package/dist/server/app-page-probe.js +5 -0
- package/dist/server/app-page-render-identity.d.ts +2 -0
- package/dist/server/app-page-render-identity.js +3 -2
- package/dist/server/app-page-render.d.ts +2 -0
- package/dist/server/app-page-render.js +85 -16
- package/dist/server/app-page-request.d.ts +14 -0
- package/dist/server/app-page-request.js +69 -4
- package/dist/server/app-page-response.d.ts +7 -0
- package/dist/server/app-page-response.js +16 -4
- package/dist/server/app-page-route-wiring.d.ts +8 -1
- package/dist/server/app-page-route-wiring.js +32 -18
- package/dist/server/app-page-segment-state.d.ts +2 -1
- package/dist/server/app-page-segment-state.js +3 -1
- package/dist/server/app-page-stream.d.ts +7 -1
- package/dist/server/app-page-stream.js +3 -1
- package/dist/server/app-route-handler-execution.js +5 -1
- package/dist/server/app-route-handler-response.js +1 -0
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-route-tree-prefetch.d.ts +43 -0
- package/dist/server/app-route-tree-prefetch.js +187 -0
- package/dist/server/app-router-entry.js +9 -2
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +9 -4
- package/dist/server/app-rsc-handler.d.ts +7 -0
- package/dist/server/app-rsc-handler.js +148 -39
- package/dist/server/app-rsc-render-mode.d.ts +3 -2
- package/dist/server/app-rsc-render-mode.js +4 -1
- package/dist/server/app-rsc-request-normalization.d.ts +6 -6
- package/dist/server/app-rsc-request-normalization.js +10 -8
- package/dist/server/app-segment-config.d.ts +11 -0
- package/dist/server/app-segment-config.js +62 -6
- package/dist/server/app-server-action-execution.d.ts +1 -0
- package/dist/server/app-server-action-execution.js +61 -30
- package/dist/server/app-ssr-entry.d.ts +3 -0
- package/dist/server/app-ssr-entry.js +13 -5
- package/dist/server/app-ssr-stream.d.ts +7 -3
- package/dist/server/app-ssr-stream.js +10 -6
- package/dist/server/app-visited-response-cache.d.ts +6 -0
- package/dist/server/app-visited-response-cache.js +3 -1
- package/dist/server/cache-control.d.ts +3 -1
- package/dist/server/cache-control.js +13 -1
- package/dist/server/client-trace-metadata.js +26 -0
- package/dist/server/default-global-not-found-module.d.ts +14 -0
- package/dist/server/default-global-not-found-module.js +14 -0
- package/dist/server/dev-route-files.js +4 -0
- package/dist/server/dev-server.d.ts +11 -1
- package/dist/server/dev-server.js +94 -35
- package/dist/server/dev-stack-sourcemap.d.ts +1 -1
- package/dist/server/dev-stack-sourcemap.js +1 -1
- package/dist/server/fetch-handler.d.ts +2 -0
- package/dist/server/fetch-handler.js +18 -0
- package/dist/server/headers.d.ts +7 -15
- package/dist/server/headers.js +11 -18
- package/dist/server/image-optimization.d.ts +51 -1
- package/dist/server/image-optimization.js +52 -2
- package/dist/server/implicit-tags.js +1 -1
- package/dist/server/isr-cache.d.ts +3 -2
- package/dist/server/isr-cache.js +9 -5
- package/dist/server/metadata-routes.d.ts +3 -1
- package/dist/server/metadata-routes.js +12 -2
- package/dist/server/middleware-runtime.js +6 -1
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +14 -3
- package/dist/server/pages-api-route.js +2 -2
- package/dist/server/pages-asset-tags.d.ts +4 -6
- package/dist/server/pages-asset-tags.js +12 -12
- package/dist/server/pages-client-assets.d.ts +12 -0
- package/dist/server/pages-client-assets.js +10 -0
- package/dist/server/pages-data-route.d.ts +4 -2
- package/dist/server/pages-data-route.js +18 -4
- package/dist/server/pages-dev-module-url.d.ts +2 -1
- package/dist/server/pages-dev-module-url.js +6 -3
- package/dist/server/pages-node-compat.d.ts +19 -1
- package/dist/server/pages-node-compat.js +81 -4
- package/dist/server/pages-page-data.d.ts +33 -1
- package/dist/server/pages-page-data.js +62 -33
- package/dist/server/pages-page-handler.d.ts +2 -1
- package/dist/server/pages-page-handler.js +38 -19
- package/dist/server/pages-page-response.d.ts +8 -0
- package/dist/server/pages-page-response.js +7 -3
- package/dist/server/pages-request-pipeline.d.ts +9 -5
- package/dist/server/pages-request-pipeline.js +55 -7
- package/dist/server/pages-router-entry.d.ts +30 -0
- package/dist/server/pages-router-entry.js +108 -0
- package/dist/server/prerender-manifest.d.ts +3 -1
- package/dist/server/prerender-route-params.js +1 -1
- package/dist/server/prod-server.d.ts +5 -3
- package/dist/server/prod-server.js +68 -39
- package/dist/server/request-pipeline.js +2 -1
- package/dist/server/seed-cache.js +4 -4
- package/dist/shims/app-router-scroll-state.d.ts +1 -0
- package/dist/shims/app-router-scroll-state.js +1 -0
- package/dist/shims/app-router-scroll.js +2 -1
- package/dist/shims/cache-handler.js +8 -1
- package/dist/shims/cache.js +22 -15
- package/dist/shims/cdn-cache.js +1 -1
- package/dist/shims/dynamic-preload-chunks.js +2 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +77 -52
- package/dist/shims/form.d.ts +4 -2
- package/dist/shims/form.js +37 -43
- package/dist/shims/headers.d.ts +7 -1
- package/dist/shims/headers.js +17 -3
- package/dist/shims/image.js +75 -14
- package/dist/shims/internal/app-prefetch-fetch-queue.d.ts +10 -0
- package/dist/shims/internal/app-prefetch-fetch-queue.js +61 -0
- package/dist/shims/internal/app-route-detection.d.ts +2 -17
- package/dist/shims/internal/app-route-detection.js +4 -17
- package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
- package/dist/shims/internal/hybrid-client-route-owner.d.ts +3 -15
- package/dist/shims/internal/hybrid-client-route-owner.js +40 -58
- package/dist/shims/internal/pages-data-fetch-dedup.d.ts +10 -5
- package/dist/shims/internal/pages-data-fetch-dedup.js +84 -14
- package/dist/shims/internal/pages-data-target.d.ts +18 -12
- package/dist/shims/internal/pages-data-target.js +97 -13
- package/dist/shims/internal/pages-router-components.d.ts +7 -0
- package/dist/shims/internal/pages-router-components.js +13 -0
- package/dist/shims/layout-segment-context.d.ts +4 -1
- package/dist/shims/layout-segment-context.js +18 -4
- package/dist/shims/link.d.ts +1 -1
- package/dist/shims/link.js +224 -58
- package/dist/shims/navigation.d.ts +19 -3
- package/dist/shims/navigation.js +245 -47
- package/dist/shims/request-context.js +18 -0
- package/dist/shims/root-params.d.ts +15 -1
- package/dist/shims/root-params.js +21 -1
- package/dist/shims/router.d.ts +5 -7
- package/dist/shims/router.js +387 -102
- package/dist/shims/server.js +3 -2
- package/dist/shims/slot.js +3 -6
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/typegen.js +1 -1
- package/dist/utils/client-runtime-metadata.d.ts +2 -18
- package/dist/utils/client-runtime-metadata.js +31 -22
- package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
- package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
- package/dist/utils/domain-locale.d.ts +6 -3
- package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
- package/dist/{server → utils}/middleware-request-headers.js +3 -3
- package/dist/utils/project.d.ts +48 -2
- package/dist/utils/project.js +225 -4
- package/dist/utils/protocol-headers.d.ts +23 -0
- package/dist/utils/protocol-headers.js +23 -0
- package/dist/utils/react-version.d.ts +4 -0
- package/dist/utils/react-version.js +44 -0
- package/dist/utils/vite-version.d.ts +2 -0
- package/dist/utils/vite-version.js +11 -1
- package/package.json +47 -2
- package/dist/deploy.d.ts +0 -197
- package/dist/deploy.js +0 -1040
- package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
- /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
package/dist/check.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { detectPackageManager, findDir } from "./utils/project.js";
|
|
2
|
+
import { normalizePathSeparators } from "./utils/path.js";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { parseAst } from "vite";
|
|
@@ -192,7 +193,7 @@ const CONFIG_SUPPORT = {
|
|
|
192
193
|
env: { status: "supported" },
|
|
193
194
|
images: {
|
|
194
195
|
status: "partial",
|
|
195
|
-
detail: "remotePatterns validated,
|
|
196
|
+
detail: "remotePatterns validated; on-the-fly optimization via images.optimizer (Cloudflare Images), passthrough otherwise"
|
|
196
197
|
},
|
|
197
198
|
allowedDevOrigins: {
|
|
198
199
|
status: "supported",
|
|
@@ -258,13 +259,49 @@ const CONFIG_SUPPORT = {
|
|
|
258
259
|
status: "partial",
|
|
259
260
|
detail: "config recognized; vinext does not implement navigation result caching"
|
|
260
261
|
},
|
|
262
|
+
"experimental.middlewarePrefetch": {
|
|
263
|
+
status: "unsupported",
|
|
264
|
+
detail: "not recognized; use of this option is ignored"
|
|
265
|
+
},
|
|
266
|
+
"experimental.proxyPrefetch": {
|
|
267
|
+
status: "unsupported",
|
|
268
|
+
detail: "not recognized; use of this option is ignored"
|
|
269
|
+
},
|
|
270
|
+
"experimental.middlewareClientMaxBodySize": {
|
|
271
|
+
status: "unsupported",
|
|
272
|
+
detail: "not recognized; use of this option is ignored"
|
|
273
|
+
},
|
|
274
|
+
"experimental.proxyClientMaxBodySize": {
|
|
275
|
+
status: "unsupported",
|
|
276
|
+
detail: "not recognized; use of this option is ignored"
|
|
277
|
+
},
|
|
278
|
+
"experimental.externalMiddlewareRewritesResolve": {
|
|
279
|
+
status: "unsupported",
|
|
280
|
+
detail: "not recognized; use of this option is ignored"
|
|
281
|
+
},
|
|
282
|
+
"experimental.externalProxyRewritesResolve": {
|
|
283
|
+
status: "unsupported",
|
|
284
|
+
detail: "not recognized; use of this option is ignored"
|
|
285
|
+
},
|
|
286
|
+
"experimental.instrumentationHook": {
|
|
287
|
+
status: "unsupported",
|
|
288
|
+
detail: "not recognized; instrumentation files are enabled automatically"
|
|
289
|
+
},
|
|
290
|
+
skipMiddlewareUrlNormalize: {
|
|
291
|
+
status: "unsupported",
|
|
292
|
+
detail: "not recognized; use of this option is ignored"
|
|
293
|
+
},
|
|
294
|
+
skipProxyUrlNormalize: {
|
|
295
|
+
status: "unsupported",
|
|
296
|
+
detail: "not recognized; use of this option is ignored"
|
|
297
|
+
},
|
|
261
298
|
"i18n.domains": {
|
|
262
299
|
status: "partial",
|
|
263
300
|
detail: "supported for Pages Router; App Router unchanged"
|
|
264
301
|
},
|
|
265
302
|
reactStrictMode: {
|
|
266
303
|
status: "partial",
|
|
267
|
-
detail: "
|
|
304
|
+
detail: "enforced for the Pages Router (client root wrapped in <React.StrictMode> when true); App Router is not yet wrapped (Next.js defaults App Router strict mode on)"
|
|
268
305
|
},
|
|
269
306
|
poweredByHeader: {
|
|
270
307
|
status: "supported",
|
|
@@ -552,9 +589,8 @@ function hasFreeCjsGlobal(content) {
|
|
|
552
589
|
/**
|
|
553
590
|
* Scan source files for `import ... from 'next/...'` statements.
|
|
554
591
|
*
|
|
555
|
-
* `root` must be forward-slash: it is passed to `findSourceFiles
|
|
556
|
-
* requires it
|
|
557
|
-
* a canonical relative path when both operands are forward-slash.
|
|
592
|
+
* `root` must be forward-slash: it is passed to `findSourceFiles`, which
|
|
593
|
+
* requires it.
|
|
558
594
|
*/
|
|
559
595
|
function scanImports(root) {
|
|
560
596
|
const files = findSourceFiles(root);
|
|
@@ -572,7 +608,7 @@ function scanImports(root) {
|
|
|
572
608
|
if (mod.startsWith("next/") || mod === "next" || mod === "server-only" || mod === "client-only") {
|
|
573
609
|
const normalized = mod === "next" ? "next" : mod;
|
|
574
610
|
if (!importUsage.has(normalized)) importUsage.set(normalized, []);
|
|
575
|
-
const relFile = path.
|
|
611
|
+
const relFile = normalizePathSeparators(path.relative(root, file));
|
|
576
612
|
const usedInFiles = importUsage.get(normalized) ?? [];
|
|
577
613
|
if (!usedInFiles.includes(relFile)) usedInFiles.push(relFile);
|
|
578
614
|
}
|
|
@@ -740,7 +776,9 @@ function analyzeConfig(root) {
|
|
|
740
776
|
"transpilePackages",
|
|
741
777
|
"webpack",
|
|
742
778
|
"reactStrictMode",
|
|
743
|
-
"poweredByHeader"
|
|
779
|
+
"poweredByHeader",
|
|
780
|
+
"skipMiddlewareUrlNormalize",
|
|
781
|
+
"skipProxyUrlNormalize"
|
|
744
782
|
]) {
|
|
745
783
|
if (!present.top.has(opt)) continue;
|
|
746
784
|
const support = CONFIG_SUPPORT[opt];
|
|
@@ -792,9 +830,8 @@ function checkLibraries(root) {
|
|
|
792
830
|
/**
|
|
793
831
|
* Check file conventions (pages, app directory, middleware, etc.)
|
|
794
832
|
*
|
|
795
|
-
* `root` must be forward-slash — joined with `path.posix.join
|
|
796
|
-
* `findDir
|
|
797
|
-
* `runCheck`, which normalizes it.
|
|
833
|
+
* `root` must be forward-slash — joined with `path.posix.join` and passed to
|
|
834
|
+
* `findDir`. Only called from `runCheck`, which normalizes it.
|
|
798
835
|
*/
|
|
799
836
|
function checkConventions(root) {
|
|
800
837
|
const items = [];
|
|
@@ -893,7 +930,7 @@ function checkConventions(root) {
|
|
|
893
930
|
const cjsGlobalFiles = [];
|
|
894
931
|
for (const file of allSourceFiles) {
|
|
895
932
|
const content = fs.readFileSync(file, "utf-8");
|
|
896
|
-
const rel = path.
|
|
933
|
+
const rel = normalizePathSeparators(path.relative(root, file));
|
|
897
934
|
if (viewTransitionRegex.test(content)) viewTransitionFiles.push(rel);
|
|
898
935
|
if (hasFreeCjsGlobal(content)) cjsGlobalFiles.push(rel);
|
|
899
936
|
}
|
package/dist/cli-args.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ type ParsedArgs = {
|
|
|
18
18
|
precompress?: boolean;
|
|
19
19
|
positionals?: string[];
|
|
20
20
|
};
|
|
21
|
-
declare function parsePositiveIntegerArg(raw: string, flag: string): number;
|
|
22
21
|
/**
|
|
23
22
|
* Parse CLI arguments into a structured object.
|
|
24
23
|
*
|
|
@@ -30,4 +29,4 @@ declare function parsePositiveIntegerArg(raw: string, flag: string): number;
|
|
|
30
29
|
*/
|
|
31
30
|
declare function parseArgs(args: string[]): ParsedArgs;
|
|
32
31
|
//#endregion
|
|
33
|
-
export { parseArgs
|
|
32
|
+
export { parseArgs };
|
package/dist/cli-args.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin, ServerOptions } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/cli-dev-config.d.ts
|
|
4
|
+
type DevServerCliOptions = {
|
|
5
|
+
port?: number;
|
|
6
|
+
hostname?: string;
|
|
7
|
+
};
|
|
8
|
+
declare function applyDevServerDefaults(server: ServerOptions, options: DevServerCliOptions): void;
|
|
9
|
+
declare function createDevServerConfigPlugin(options: DevServerCliOptions): Plugin;
|
|
10
|
+
declare function normalizeDevServerHostname(host: string | boolean | undefined): string;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { DevServerCliOptions, applyDevServerDefaults, createDevServerConfigPlugin, normalizeDevServerHostname };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/cli-dev-config.ts
|
|
2
|
+
function applyDevServerDefaults(server, options) {
|
|
3
|
+
server.port = options.port ?? server.port ?? 3e3;
|
|
4
|
+
server.host = options.hostname ?? server.host ?? "localhost";
|
|
5
|
+
}
|
|
6
|
+
function createDevServerConfigPlugin(options) {
|
|
7
|
+
return {
|
|
8
|
+
name: "vinext:dev-server-config",
|
|
9
|
+
enforce: "post",
|
|
10
|
+
config: {
|
|
11
|
+
order: "post",
|
|
12
|
+
handler(config) {
|
|
13
|
+
applyDevServerDefaults(config.server ??= {}, options);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function normalizeDevServerHostname(host) {
|
|
19
|
+
if (typeof host === "string") return host;
|
|
20
|
+
return host === true ? "0.0.0.0" : "localhost";
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { applyDevServerDefaults, createDevServerConfigPlugin, normalizeDevServerHostname };
|
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { detectPackageManager, ensureViteConfigCompatibility, hasAppDir, hasViteConfig } from "./utils/project.js";
|
|
3
|
+
import { normalizePathSeparators } from "./utils/path.js";
|
|
3
4
|
import { formatReport, runCheck } from "./check.js";
|
|
4
5
|
import { parseArgs } from "./cli-args.js";
|
|
5
|
-
import {
|
|
6
|
+
import { createDevServerConfigPlugin, normalizeDevServerHostname } from "./cli-dev-config.js";
|
|
6
7
|
import { PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
7
8
|
import { createRscCompatibilityId, loadNextConfig, resolveNextConfig } from "./config/next-config.js";
|
|
8
9
|
import { generateRouteTypes } from "./typegen.js";
|
|
9
|
-
import {
|
|
10
|
+
import { clearPagesClientAssetsBuildMetadata } from "./build/pages-client-assets-module.js";
|
|
11
|
+
import { findVinextPrerenderConfigInPlugins, formatVinextPrerenderLabel, resolveVinextPrerenderDecision } from "./config/prerender.js";
|
|
12
|
+
import vinext from "./index.js";
|
|
10
13
|
import { runPrerender } from "./build/run-prerender.js";
|
|
11
14
|
import { loadDotenv } from "./config/dotenv.js";
|
|
12
|
-
import { deploy, parseDeployArgs } from "./deploy.js";
|
|
13
|
-
import
|
|
15
|
+
import { deploy, parseDeployArgs } from "./packages/cloudflare/src/deploy.js";
|
|
16
|
+
import { printDeployHelp } from "./packages/cloudflare/src/deploy-help.js";
|
|
17
|
+
import { getReactUpgradeDeps } from "./utils/react-version.js";
|
|
18
|
+
import { init } from "./init.js";
|
|
19
|
+
import { INIT_PLATFORMS, resolveInitPlatform, resolveInitPrerender } from "./init-platform.js";
|
|
14
20
|
import { resolveVinextPackageRoot } from "./utils/vinext-root.js";
|
|
15
21
|
import { emitStandaloneOutput } from "./build/standalone.js";
|
|
16
22
|
import { cleanBuildOutput } from "./build/clean-output.js";
|
|
@@ -28,7 +34,7 @@ import { execFileSync } from "node:child_process";
|
|
|
28
34
|
* vinext dev Start development server (Vite)
|
|
29
35
|
* vinext build Build for production
|
|
30
36
|
* vinext start Start production server
|
|
31
|
-
* vinext deploy
|
|
37
|
+
* vinext deploy Deprecated Cloudflare deploy shim
|
|
32
38
|
* vinext typegen Generate App Router route helper types
|
|
33
39
|
* vinext lint Run linter (delegates to eslint/oxlint)
|
|
34
40
|
*
|
|
@@ -121,13 +127,17 @@ function createBuildLogger(vite) {
|
|
|
121
127
|
function hasPagesDir() {
|
|
122
128
|
return fs.existsSync(path.join(process.cwd(), "pages")) || fs.existsSync(path.join(process.cwd(), "src", "pages"));
|
|
123
129
|
}
|
|
124
|
-
async function
|
|
125
|
-
if (!hasViteConfig(root)) return
|
|
126
|
-
const
|
|
130
|
+
async function loadBuildViteConfigMetadata(vite, root) {
|
|
131
|
+
if (!hasViteConfig(root)) return { prerenderConfig: null };
|
|
132
|
+
const loaded = await vite.loadConfigFromFile({
|
|
127
133
|
command: "build",
|
|
128
134
|
mode: "production"
|
|
129
|
-
}, void 0, root)
|
|
130
|
-
|
|
135
|
+
}, void 0, root);
|
|
136
|
+
const emptyOutDir = loaded?.config.build?.emptyOutDir;
|
|
137
|
+
return {
|
|
138
|
+
emptyOutDir: typeof emptyOutDir === "boolean" ? emptyOutDir : void 0,
|
|
139
|
+
prerenderConfig: findVinextPrerenderConfigInPlugins(loaded?.config.plugins)
|
|
140
|
+
};
|
|
131
141
|
}
|
|
132
142
|
/**
|
|
133
143
|
* Build the Vite config automatically. If a vite.config.ts exists in the
|
|
@@ -180,20 +190,20 @@ async function dev() {
|
|
|
180
190
|
});
|
|
181
191
|
applyViteConfigCompatibility(process.cwd());
|
|
182
192
|
const vite = await loadVite();
|
|
183
|
-
const
|
|
184
|
-
const
|
|
193
|
+
const initialPort = parsed.port ?? 3e3;
|
|
194
|
+
const initialHost = parsed.hostname ?? "localhost";
|
|
185
195
|
let lockfile;
|
|
186
196
|
const startedAt = Date.now();
|
|
187
197
|
if (process.env.VINEXT_NO_DEV_LOCK !== "1") {
|
|
188
198
|
const root = process.cwd();
|
|
189
|
-
const initialDisplayHost =
|
|
199
|
+
const initialDisplayHost = initialHost === "0.0.0.0" ? "localhost" : initialHost;
|
|
190
200
|
const acquired = tryAcquireLockfile({
|
|
191
201
|
root,
|
|
192
202
|
info: {
|
|
193
203
|
pid: process.pid,
|
|
194
|
-
port,
|
|
195
|
-
hostname:
|
|
196
|
-
appUrl: `http://${initialDisplayHost}:${
|
|
204
|
+
port: initialPort,
|
|
205
|
+
hostname: initialHost,
|
|
206
|
+
appUrl: `http://${initialDisplayHost}:${initialPort}`,
|
|
197
207
|
startedAt,
|
|
198
208
|
cwd: root
|
|
199
209
|
}
|
|
@@ -209,13 +219,21 @@ async function dev() {
|
|
|
209
219
|
lockfile = acquired.lockfile;
|
|
210
220
|
}
|
|
211
221
|
console.log(`\n vinext dev (Vite ${getViteVersion()})\n`);
|
|
212
|
-
const config = buildViteConfig(
|
|
213
|
-
|
|
214
|
-
host
|
|
215
|
-
} });
|
|
222
|
+
const config = buildViteConfig();
|
|
223
|
+
(config.plugins ??= []).push(createDevServerConfigPlugin(parsed));
|
|
216
224
|
let server;
|
|
217
225
|
try {
|
|
218
226
|
server = await vite.createServer(config);
|
|
227
|
+
const port = server.config.server.port ?? 3e3;
|
|
228
|
+
const host = normalizeDevServerHostname(server.config.server.host);
|
|
229
|
+
lockfile?.update({
|
|
230
|
+
pid: process.pid,
|
|
231
|
+
port,
|
|
232
|
+
hostname: host,
|
|
233
|
+
appUrl: `http://${host === "0.0.0.0" ? "localhost" : host}:${port}`,
|
|
234
|
+
startedAt,
|
|
235
|
+
cwd: process.cwd()
|
|
236
|
+
});
|
|
219
237
|
await server.listen();
|
|
220
238
|
} catch (err) {
|
|
221
239
|
lockfile?.release();
|
|
@@ -223,8 +241,10 @@ async function dev() {
|
|
|
223
241
|
}
|
|
224
242
|
server.printUrls();
|
|
225
243
|
if (lockfile) {
|
|
244
|
+
const configuredPort = server.config.server.port ?? 3e3;
|
|
245
|
+
const configuredHost = normalizeDevServerHostname(server.config.server.host);
|
|
226
246
|
const resolved = server.resolvedUrls?.local[0];
|
|
227
|
-
let actualPort =
|
|
247
|
+
let actualPort = configuredPort;
|
|
228
248
|
let appUrl;
|
|
229
249
|
if (resolved) {
|
|
230
250
|
appUrl = resolved.replace(/\/$/, "");
|
|
@@ -234,13 +254,13 @@ async function dev() {
|
|
|
234
254
|
} catch {}
|
|
235
255
|
} else {
|
|
236
256
|
const address = server.httpServer?.address();
|
|
237
|
-
actualPort = typeof address === "object" && address ? address.port :
|
|
238
|
-
appUrl = `http://${
|
|
257
|
+
actualPort = typeof address === "object" && address ? address.port : configuredPort;
|
|
258
|
+
appUrl = `http://${configuredHost === "0.0.0.0" ? "localhost" : configuredHost}:${actualPort}`;
|
|
239
259
|
}
|
|
240
260
|
lockfile.update({
|
|
241
261
|
pid: process.pid,
|
|
242
262
|
port: actualPort,
|
|
243
|
-
hostname:
|
|
263
|
+
hostname: configuredHost,
|
|
244
264
|
appUrl,
|
|
245
265
|
startedAt,
|
|
246
266
|
cwd: process.cwd()
|
|
@@ -261,7 +281,7 @@ async function buildApp() {
|
|
|
261
281
|
const withBuildBundlerOptions = (bundlerOptions) => viteMajorVersion >= 8 ? { rolldownOptions: bundlerOptions } : { rollupOptions: bundlerOptions };
|
|
262
282
|
console.log(`\n vinext build (Vite ${getViteVersion()})\n`);
|
|
263
283
|
const root = process.cwd();
|
|
264
|
-
const isApp = hasAppDir(
|
|
284
|
+
const isApp = hasAppDir(normalizePathSeparators(root));
|
|
265
285
|
const resolvedNextConfig = await resolveNextConfig(await loadNextConfig(root, PHASE_PRODUCTION_BUILD), root);
|
|
266
286
|
process.env.__VINEXT_SHARED_BUILD_ID = resolvedNextConfig.buildId;
|
|
267
287
|
process.env.__VINEXT_SHARED_RSC_COMPATIBILITY_ID = createRscCompatibilityId(resolvedNextConfig);
|
|
@@ -288,15 +308,19 @@ async function buildApp() {
|
|
|
288
308
|
});
|
|
289
309
|
}
|
|
290
310
|
}
|
|
311
|
+
const buildConfigMetadata = await loadBuildViteConfigMetadata(vite, root);
|
|
291
312
|
cleanBuildOutput({
|
|
292
313
|
root,
|
|
293
314
|
outDir: distDir,
|
|
294
|
-
emptyOutDir:
|
|
315
|
+
emptyOutDir: buildConfigMetadata.emptyOutDir
|
|
295
316
|
});
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
if (
|
|
299
|
-
|
|
317
|
+
const isHybrid = isApp && hasPagesDir();
|
|
318
|
+
const pagesClientAssetsBuildSession = isHybrid ? randomBytes(16).toString("hex") : null;
|
|
319
|
+
if (pagesClientAssetsBuildSession) process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION = pagesClientAssetsBuildSession;
|
|
320
|
+
try {
|
|
321
|
+
const config = buildViteConfig({}, logger);
|
|
322
|
+
await (await vite.createBuilder(config)).buildApp();
|
|
323
|
+
if (isHybrid) {
|
|
300
324
|
console.log(" Building Pages Router server (hybrid)...");
|
|
301
325
|
const root = process.cwd();
|
|
302
326
|
let userTransformPlugins = [];
|
|
@@ -327,6 +351,11 @@ async function buildApp() {
|
|
|
327
351
|
}
|
|
328
352
|
});
|
|
329
353
|
}
|
|
354
|
+
} finally {
|
|
355
|
+
if (pagesClientAssetsBuildSession) {
|
|
356
|
+
clearPagesClientAssetsBuildMetadata(pagesClientAssetsBuildSession);
|
|
357
|
+
if (process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION === pagesClientAssetsBuildSession) delete process.env.__VINEXT_PAGES_CLIENT_ASSETS_BUILD_SESSION;
|
|
358
|
+
}
|
|
330
359
|
}
|
|
331
360
|
if (outputMode === "standalone") {
|
|
332
361
|
const standalone = emitStandaloneOutput({
|
|
@@ -338,23 +367,27 @@ async function buildApp() {
|
|
|
338
367
|
return process.exit(0);
|
|
339
368
|
}
|
|
340
369
|
let prerenderResult;
|
|
341
|
-
|
|
370
|
+
const prerenderDecision = resolveVinextPrerenderDecision({
|
|
371
|
+
prerenderAllFlag: parsed.prerenderAll,
|
|
372
|
+
vinextPrerenderConfig: buildConfigMetadata.prerenderConfig,
|
|
373
|
+
nextOutput: resolvedNextConfig.output
|
|
374
|
+
});
|
|
375
|
+
if (prerenderDecision) {
|
|
342
376
|
if (resolvedNextConfig.enablePrerenderSourceMaps) {
|
|
343
377
|
process.setSourceMapsEnabled(true);
|
|
344
378
|
Error.stackTraceLimit = Math.max(Error.stackTraceLimit, 50);
|
|
345
379
|
}
|
|
346
|
-
const label = parsed.prerenderAll ? "Pre-rendering all routes..." : "Pre-rendering all routes (output: 'export')...";
|
|
347
380
|
process.stdout.write("\x1B[0m");
|
|
348
|
-
console.log(` ${
|
|
381
|
+
console.log(` ${formatVinextPrerenderLabel(prerenderDecision)}`);
|
|
349
382
|
prerenderResult = await runPrerender({
|
|
350
|
-
root: process.cwd(),
|
|
383
|
+
root: normalizePathSeparators(process.cwd()),
|
|
351
384
|
concurrency: parsed.prerenderConcurrency
|
|
352
385
|
});
|
|
353
386
|
}
|
|
354
387
|
process.stdout.write("\x1B[0m");
|
|
355
388
|
const { printBuildReport } = await import("./build/report.js");
|
|
356
389
|
await printBuildReport({
|
|
357
|
-
root: process.cwd(),
|
|
390
|
+
root: normalizePathSeparators(process.cwd()),
|
|
358
391
|
pageExtensions: resolvedNextConfig.pageExtensions,
|
|
359
392
|
prerenderResult: prerenderResult ?? void 0
|
|
360
393
|
});
|
|
@@ -421,7 +454,12 @@ async function lint() {
|
|
|
421
454
|
}
|
|
422
455
|
async function deployCommand() {
|
|
423
456
|
const parsed = parseDeployArgs(rawArgs);
|
|
424
|
-
if (parsed.help)
|
|
457
|
+
if (parsed.help) {
|
|
458
|
+
printDeployDeprecationWarning();
|
|
459
|
+
printDeployHelp();
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
printDeployDeprecationWarning();
|
|
425
463
|
await loadVite();
|
|
426
464
|
console.log(`\n vinext deploy (Vite ${getViteVersion()})\n`);
|
|
427
465
|
await deploy({
|
|
@@ -439,6 +477,9 @@ async function deployCommand() {
|
|
|
439
477
|
tprWindow: parsed.tprWindow
|
|
440
478
|
});
|
|
441
479
|
}
|
|
480
|
+
function printDeployDeprecationWarning() {
|
|
481
|
+
console.log(" ⚠️ Warning: `vinext deploy` has moved to the `@vinext/cloudflare` package.\n Please switch to `npx @vinext/cloudflare deploy` or `vp exec vinext-cloudflare deploy`; this compatibility command will be removed in a future release.\n");
|
|
482
|
+
}
|
|
442
483
|
async function check() {
|
|
443
484
|
if (parseArgs(rawArgs).help) return printHelp("check");
|
|
444
485
|
console.log(`\n vinext check\n`);
|
|
@@ -467,11 +508,17 @@ async function initCommand() {
|
|
|
467
508
|
const port = parsed.port ?? 3001;
|
|
468
509
|
const skipCheck = rawArgs.includes("--skip-check");
|
|
469
510
|
const force = rawArgs.includes("--force");
|
|
511
|
+
const platform = await resolveInitPlatform(rawArgs);
|
|
512
|
+
const platformOptions = await INIT_PLATFORMS[platform].options(rawArgs);
|
|
513
|
+
const prerender = await resolveInitPrerender(rawArgs);
|
|
470
514
|
await init({
|
|
471
515
|
root: process.cwd(),
|
|
472
516
|
port,
|
|
473
517
|
skipCheck,
|
|
474
|
-
force
|
|
518
|
+
force,
|
|
519
|
+
platform,
|
|
520
|
+
prerender,
|
|
521
|
+
cloudflare: platform === "cloudflare" ? platformOptions : void 0
|
|
475
522
|
});
|
|
476
523
|
}
|
|
477
524
|
function printHelp(cmd) {
|
|
@@ -501,8 +548,8 @@ function printHelp(cmd) {
|
|
|
501
548
|
|
|
502
549
|
Options:
|
|
503
550
|
--verbose Show full Vite/Rollup build output (suppressed by default)
|
|
504
|
-
--prerender-all Pre-render discovered routes after building
|
|
505
|
-
|
|
551
|
+
--prerender-all Pre-render discovered routes after building. Equivalent
|
|
552
|
+
to vinext({ prerender: true }) and takes priority.
|
|
506
553
|
--prerender-concurrency <count>
|
|
507
554
|
Maximum number of routes to pre-render in parallel
|
|
508
555
|
--precompress Precompress static assets at build time (.br, .gz, .zst)
|
|
@@ -528,52 +575,8 @@ function printHelp(cmd) {
|
|
|
528
575
|
return;
|
|
529
576
|
}
|
|
530
577
|
if (cmd === "deploy") {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
Usage: vinext deploy [options]
|
|
535
|
-
|
|
536
|
-
One-command deployment to Cloudflare Workers. Automatically:
|
|
537
|
-
- Detects App Router or Pages Router
|
|
538
|
-
- Generates wrangler.jsonc, worker/index.ts, vite.config.ts if missing
|
|
539
|
-
- Installs @cloudflare/vite-plugin and wrangler if needed
|
|
540
|
-
- Builds the project with Vite
|
|
541
|
-
- Deploys via wrangler
|
|
542
|
-
|
|
543
|
-
Options:
|
|
544
|
-
--preview Deploy to preview environment (same as --env preview)
|
|
545
|
-
--env <name> Deploy using wrangler env.<name>
|
|
546
|
-
--name <name> Custom Worker name (default: from package.json)
|
|
547
|
-
--skip-build Skip the build step (use existing dist/)
|
|
548
|
-
--dry-run Generate config files without building or deploying
|
|
549
|
-
--prerender-all Pre-render discovered routes after building (future
|
|
550
|
-
releases will auto-populate the remote cache)
|
|
551
|
-
--prerender-concurrency <count>
|
|
552
|
-
Maximum number of routes to pre-render in parallel
|
|
553
|
-
-h, --help Show this help
|
|
554
|
-
|
|
555
|
-
Experimental:
|
|
556
|
-
--experimental-tpr Enable Traffic-aware Pre-Rendering
|
|
557
|
-
--tpr-coverage <pct> Traffic coverage target, 0–100 (default: 90)
|
|
558
|
-
--tpr-limit <count> Hard cap on pages to pre-render (default: 1000)
|
|
559
|
-
--tpr-window <hours> Analytics lookback window in hours (default: 24)
|
|
560
|
-
|
|
561
|
-
TPR (Traffic-aware Pre-Rendering) uses Cloudflare zone analytics to determine
|
|
562
|
-
which pages get the most traffic and pre-renders them into KV cache during
|
|
563
|
-
deploy. This feature is experimental and must be explicitly enabled. Requires
|
|
564
|
-
a custom domain (zone analytics are unavailable on *.workers.dev) and the
|
|
565
|
-
CLOUDFLARE_API_TOKEN environment variable with Zone.Analytics read permission.
|
|
566
|
-
|
|
567
|
-
Examples:
|
|
568
|
-
vinext deploy Build and deploy to production
|
|
569
|
-
vinext deploy --preview Deploy to a preview URL
|
|
570
|
-
vinext deploy --env staging Deploy using wrangler env.staging
|
|
571
|
-
vinext deploy --dry-run See what files would be generated
|
|
572
|
-
vinext deploy --name my-app Deploy with a custom Worker name
|
|
573
|
-
vinext deploy --experimental-tpr Enable TPR during deploy
|
|
574
|
-
vinext deploy --experimental-tpr --tpr-coverage 95 Cover 95% of traffic
|
|
575
|
-
vinext deploy --experimental-tpr --tpr-limit 500 Cap at 500 pages
|
|
576
|
-
`);
|
|
578
|
+
printDeployDeprecationWarning();
|
|
579
|
+
printDeployHelp();
|
|
577
580
|
return;
|
|
578
581
|
}
|
|
579
582
|
if (cmd === "check") {
|
|
@@ -605,10 +608,23 @@ function printHelp(cmd) {
|
|
|
605
608
|
-p, --port <port> Dev server port for the vinext script (default: 3001)
|
|
606
609
|
--skip-check Skip the compatibility check step
|
|
607
610
|
--force Overwrite existing vite.config.ts
|
|
611
|
+
--platform <target> Deployment target: cloudflare or node
|
|
612
|
+
--prerender Configure vinext build to pre-render all static routes
|
|
613
|
+
(default: prompt, with No selected by default)
|
|
614
|
+
--data-cache <type> Cloudflare data cache: kv or none (default: kv)
|
|
615
|
+
--image-optimization <type>
|
|
616
|
+
Cloudflare image optimization: cloudflare-images or none
|
|
608
617
|
-h, --help Show this help
|
|
609
618
|
|
|
610
619
|
Examples:
|
|
611
|
-
vinext init
|
|
620
|
+
vinext init Prompt for a deployment platform
|
|
621
|
+
vinext init --platform=cloudflare Configure Cloudflare Workers (default)
|
|
622
|
+
vinext init --platform=cloudflare --data-cache=kv
|
|
623
|
+
Configure the default Cloudflare cache handlers
|
|
624
|
+
vinext init --platform=cloudflare --image-optimization=none
|
|
625
|
+
Do not configure Cloudflare Images
|
|
626
|
+
vinext init --prerender Add prerender: { routes: "*" } to vite.config.ts
|
|
627
|
+
vinext init --platform=node Configure a Node deployment
|
|
612
628
|
vinext init -p 4000 Use port 4000 for dev:vinext
|
|
613
629
|
vinext init --force Overwrite existing vite.config.ts
|
|
614
630
|
vinext init --skip-check Skip the compatibility report
|
|
@@ -653,7 +669,6 @@ function printHelp(cmd) {
|
|
|
653
669
|
dev Start development server
|
|
654
670
|
build Build for production
|
|
655
671
|
start Start production server
|
|
656
|
-
deploy Deploy to Cloudflare Workers
|
|
657
672
|
typegen Generate App Router route helper types
|
|
658
673
|
init Migrate a Next.js project to vinext
|
|
659
674
|
check Scan Next.js app for compatibility
|
|
@@ -664,15 +679,16 @@ function printHelp(cmd) {
|
|
|
664
679
|
--version Show version
|
|
665
680
|
|
|
666
681
|
Examples:
|
|
667
|
-
vinext dev
|
|
668
|
-
vinext dev -p 4000
|
|
669
|
-
vinext build
|
|
670
|
-
vinext typegen
|
|
671
|
-
vinext start
|
|
672
|
-
vinext
|
|
673
|
-
vinext
|
|
674
|
-
vinext
|
|
675
|
-
vinext
|
|
682
|
+
vinext dev Start dev server on port 3000
|
|
683
|
+
vinext dev -p 4000 Start dev server on port 4000
|
|
684
|
+
vinext build Build for production
|
|
685
|
+
vinext typegen Generate route helper types
|
|
686
|
+
vinext start Start production server
|
|
687
|
+
vinext init Migrate a Next.js project
|
|
688
|
+
vinext check Check compatibility
|
|
689
|
+
vinext lint Run linter
|
|
690
|
+
npx @vinext/cloudflare deploy Deploy to Cloudflare Workers
|
|
691
|
+
vp exec vinext-cloudflare deploy Deploy to Cloudflare Workers with Vite+
|
|
676
692
|
|
|
677
693
|
vinext is a drop-in replacement for the \`next\` CLI.
|
|
678
694
|
No vite.config.ts needed — just run \`vinext dev\` in your Next.js project.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReportedError, dismissOverlay } from "./dev-error-overlay-store.js";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/client/dev-error-overlay.d.ts
|
|
4
4
|
declare const DEV_ERROR_OVERLAY_HOST_ID = "__vinext_dev_error_overlay_root";
|
|
5
5
|
declare const DEV_ERROR_OVERLAY_MOUNT_ID = "__vinext_dev_error_overlay_mount";
|
|
6
6
|
declare function installDevErrorOverlay(): void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { VINEXT_DEV_ERROR_RECOVERY_EVENT } from "../utils/dev-error-recovery-event.js";
|
|
2
2
|
import { isNavigationSignalError } from "../utils/navigation-signal.js";
|
|
3
|
-
import { VINEXT_ORIGINAL_STACK_TRACE_ENDPOINT } from "
|
|
3
|
+
import { VINEXT_ORIGINAL_STACK_TRACE_ENDPOINT } from "../utils/dev-stack-sourcemap-endpoint.js";
|
|
4
4
|
import { dismissOverlay, expandOverlay, getOverlaySnapshot, minimizeOverlay, reportToOverlay, setOverlayIndex, subscribeOverlay, updateOverlayErrorStack } from "./dev-error-overlay-store.js";
|
|
5
5
|
import { Fragment, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { createRoot } from "react-dom/client";
|
|
8
|
-
//#region src/
|
|
8
|
+
//#region src/client/dev-error-overlay.tsx
|
|
9
9
|
const DEV_ERROR_OVERLAY_HOST_ID = "__vinext_dev_error_overlay_root";
|
|
10
10
|
const DEV_ERROR_OVERLAY_MOUNT_ID = "__vinext_dev_error_overlay_mount";
|
|
11
11
|
const VITE_ERROR_HANDLER_DATA_KEY = "__vinext_vite_error_handler__";
|
|
@@ -9,6 +9,8 @@ type NavigationRuntimeSnapshot = {
|
|
|
9
9
|
type NavigationRuntimeRscChunk = string | [3, string];
|
|
10
10
|
type NavigationRuntimeRscBootstrap = {
|
|
11
11
|
done?: boolean;
|
|
12
|
+
dynamicStaleTimeSeconds?: number;
|
|
13
|
+
initialCacheKind?: "dynamic" | "static";
|
|
12
14
|
nav?: NavigationRuntimeSnapshot;
|
|
13
15
|
params?: Record<string, string | string[]>;
|
|
14
16
|
rsc: NavigationRuntimeRscChunk[];
|
|
@@ -50,10 +50,12 @@ function isNavigationRuntimeParams(value) {
|
|
|
50
50
|
function isNavigationRuntimeRscBootstrap(value) {
|
|
51
51
|
if (!isUnknownRecord(value)) return false;
|
|
52
52
|
const done = Reflect.get(value, "done");
|
|
53
|
+
const dynamicStaleTimeSeconds = Reflect.get(value, "dynamicStaleTimeSeconds");
|
|
54
|
+
const initialCacheKind = Reflect.get(value, "initialCacheKind");
|
|
53
55
|
const nav = Reflect.get(value, "nav");
|
|
54
56
|
const params = Reflect.get(value, "params");
|
|
55
57
|
const rsc = Reflect.get(value, "rsc");
|
|
56
|
-
return (done === void 0 || typeof done === "boolean") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk);
|
|
58
|
+
return (done === void 0 || typeof done === "boolean") && (dynamicStaleTimeSeconds === void 0 || typeof dynamicStaleTimeSeconds === "number" && Number.isFinite(dynamicStaleTimeSeconds) && dynamicStaleTimeSeconds >= 0) && (initialCacheKind === void 0 || initialCacheKind === "dynamic" || initialCacheKind === "static") && (nav === void 0 || isNavigationRuntimeSnapshot(nav)) && (params === void 0 || isNavigationRuntimeParams(params)) && Array.isArray(rsc) && rsc.every(isNavigationRuntimeRscChunk);
|
|
57
59
|
}
|
|
58
60
|
function isReadonlyStringArray(value) {
|
|
59
61
|
return Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
@@ -6,6 +6,7 @@ type VinextLinkPrefetchRoute = {
|
|
|
6
6
|
documentOnly?: boolean;
|
|
7
7
|
isDynamic: boolean;
|
|
8
8
|
patternParts: string[];
|
|
9
|
+
requiresDynamicNavigationRequest?: boolean;
|
|
9
10
|
};
|
|
10
11
|
/**
|
|
11
12
|
* Pages Router route pattern exposed to the client so the App Router's
|
|
@@ -22,13 +23,15 @@ type VinextPagesLinkPrefetchRoute = {
|
|
|
22
23
|
documentOnly?: boolean;
|
|
23
24
|
isDynamic: boolean;
|
|
24
25
|
patternParts: string[];
|
|
26
|
+
requiresDynamicNavigationRequest?: boolean;
|
|
25
27
|
};
|
|
26
28
|
type VinextNextData = {
|
|
27
29
|
/** vinext-specific additions (not part of Next.js upstream). */__vinext?: {
|
|
28
30
|
/** Absolute URL of the page module for dynamic import. */pageModuleUrl?: string; /** Absolute URL of the `_app` module for dynamic import. */
|
|
29
31
|
appModuleUrl?: string; /** True when the Pages Router server has middleware/proxy configured. */
|
|
30
32
|
hasMiddleware?: boolean; /** True when build-time rewrites can affect the initial Pages Router ready state. */
|
|
31
|
-
hasRewrites?: boolean;
|
|
33
|
+
hasRewrites?: boolean; /** Server-resolved Pages route URL used to hydrate fallback shells behind rewrites. */
|
|
34
|
+
routeUrl?: string;
|
|
32
35
|
};
|
|
33
36
|
} & NEXT_DATA;
|
|
34
37
|
type BrowserVinextNextData = NonNullable<Window["__NEXT_DATA__"]> & VinextNextData;
|
|
@@ -97,7 +97,8 @@ type PagesRouterPublicInstance = {
|
|
|
97
97
|
* prefetch — App Router targets land here as `{ __appRouter: true }`.
|
|
98
98
|
* See: `packages/next/src/shared/lib/router/router.ts:2525`.
|
|
99
99
|
*/
|
|
100
|
-
components: Record<string, unknown>;
|
|
100
|
+
components: Record<string, unknown>; /** Persistent Pages Router static-data cache, matching Next.js `Router.sdc`. */
|
|
101
|
+
sdc: Record<string, Promise<Response>>;
|
|
101
102
|
};
|
|
102
103
|
declare global {
|
|
103
104
|
interface Window {
|