vinext 1.2.0 → 1.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 +1 -1
- package/dist/build/output-root-externals.d.ts +21 -0
- package/dist/build/output-root-externals.js +40 -0
- package/dist/build/prerender-paths.js +1 -1
- package/dist/build/prerender.js +1 -1
- package/dist/check.js +5 -6
- package/dist/cli-dev-config.js +3 -3
- package/dist/cli.js +1 -1
- package/dist/config/config-matchers.js +12 -7
- package/dist/index.js +113 -94
- package/dist/init.d.ts +1 -1
- package/dist/init.js +86 -6
- package/dist/plugins/ast-utils.d.ts +53 -2
- package/dist/plugins/ast-utils.js +90 -2
- package/dist/plugins/cloudflare-dev-module-urls.d.ts +41 -0
- package/dist/plugins/cloudflare-dev-module-urls.js +271 -0
- package/dist/plugins/commonjs-esm-facade.js +2 -2
- package/dist/plugins/css-module-imports.js +13 -20
- package/dist/plugins/dynamic-preload-metadata.js +2 -3
- package/dist/plugins/extensionless-dynamic-import.js +2 -3
- package/dist/plugins/fonts.d.ts +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.js +2 -3
- package/dist/plugins/import-meta-url.js +3 -4
- package/dist/plugins/instrumentation-client.js +3 -2
- package/dist/plugins/middleware-export-validation.js +2 -3
- package/dist/plugins/og-harfbuzz.js +2 -3
- package/dist/plugins/optimize-imports.js +3 -4
- package/dist/plugins/pages-node-externals.js +2 -3
- package/dist/plugins/remove-console.js +2 -18
- package/dist/plugins/require-condition-resolution.js +3 -3
- package/dist/plugins/require-context.js +2 -3
- package/dist/plugins/strip-server-exports.js +3 -4
- package/dist/plugins/styled-jsx.js +2 -3
- package/dist/plugins/use-cache-callable.d.ts +21 -2
- package/dist/plugins/use-cache-callable.js +76 -33
- package/dist/plugins/worker-image-imports.js +30 -33
- package/dist/plugins/worker-use-server.js +38 -14
- package/dist/server/api-handler.js +1 -1
- package/dist/server/app-action-forwarding.js +2 -2
- package/dist/server/app-browser-entry.js +3 -3
- package/dist/server/app-browser-interception-context.js +1 -1
- package/dist/server/app-browser-prefetch-response.js +2 -2
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-supplemental-refresh.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-render.js +1 -1
- package/dist/server/app-pages-bridge.js +1 -1
- package/dist/server/app-prerender-endpoints.js +1 -1
- package/dist/server/app-render-abort-error.d.ts +19 -0
- package/dist/server/app-render-abort-error.js +31 -1
- package/dist/server/app-request-stage-independent-entry.js +5 -5
- package/dist/server/app-response-stage-entry.js +2 -2
- package/dist/server/app-route-handler-runtime.js +1 -1
- package/dist/server/app-router-entry.js +5 -5
- package/dist/server/app-rsc-cache-busting.d.ts +16 -0
- package/dist/server/app-rsc-cache-busting.js +29 -12
- package/dist/server/app-rsc-handler.js +5 -5
- package/dist/server/app-rsc-request-normalization.js +3 -3
- package/dist/server/app-rsc-response-stage.js +2 -2
- package/dist/server/app-server-action-execution.js +1 -1
- package/dist/server/app-ssr-entry.js +5 -4
- package/dist/server/app-visited-response-cache.js +2 -2
- package/dist/server/config-headers.js +1 -1
- package/dist/server/defer-until-stream-consumed.d.ts +2 -1
- package/dist/server/defer-until-stream-consumed.js +3 -1
- package/dist/server/dev-server.js +1 -1
- package/dist/server/image-optimization.js +1 -0
- package/dist/server/metadata-route-response.js +2 -2
- package/dist/server/middleware-path-to-regexp.js +1 -1
- package/dist/server/middleware-runtime.js +5 -5
- package/dist/server/navigation-planner.js +1 -1
- package/dist/server/open-redirect.d.ts +11 -4
- package/dist/server/open-redirect.js +11 -4
- package/dist/server/pages-api-route.js +2 -2
- package/dist/server/pages-data-route.js +2 -1
- package/dist/server/pages-page-data.js +1 -1
- 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 +5 -5
- package/dist/server/pages-request-stage-entry.js +4 -4
- package/dist/server/pages-revalidate.js +2 -2
- package/dist/server/pages-router-entry.js +1 -1
- package/dist/server/prod-server.js +5 -5
- package/dist/server/rsc-stream-hints.d.ts +1 -1
- package/dist/server/rsc-stream-hints.js +21 -3
- package/dist/server/worker-image-optimization.js +19 -6
- package/dist/shims/head.js +1 -1
- package/dist/shims/headers.js +2 -2
- package/dist/shims/internal/hybrid-client-route-owner-direct.js +1 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +1 -0
- package/dist/shims/link-prefetch.js +5 -4
- package/dist/shims/link.js +2 -2
- package/dist/shims/navigation.js +4 -5
- package/dist/shims/router.js +9 -12
- package/dist/shims/server.d.ts +11 -4
- package/dist/shims/server.js +41 -5
- package/dist/shims/url-utils.d.ts +7 -0
- package/dist/shims/url-utils.js +12 -3
- package/dist/utils/domain-locale.js +1 -1
- package/dist/utils/plugin-rsc-version.d.ts +2 -0
- package/dist/utils/plugin-rsc-version.js +28 -2
- package/dist/utils/react-version.d.ts +7 -0
- package/dist/utils/react-version.js +39 -16
- package/package.json +6 -6
- package/dist/build/nitro-route-rules.d.ts +0 -47
- package/dist/build/nitro-route-rules.js +0 -79
- package/dist/plugins/cache-flight-codec.d.ts +0 -19
- package/dist/plugins/cache-flight-codec.js +0 -68
package/README.md
CHANGED
|
@@ -1048,7 +1048,7 @@ Or add it to your `package.json` as a file dependency:
|
|
|
1048
1048
|
}
|
|
1049
1049
|
```
|
|
1050
1050
|
|
|
1051
|
-
vinext has peer dependencies on `react ^19.
|
|
1051
|
+
vinext has peer dependencies on `react ^19.3.1`, `react-dom ^19.3.1`, `react-server-dom-webpack ^19.3.1`, and `vite ^8.0.0`. Then replace `next` with `vinext` in your scripts and run as normal.
|
|
1052
1052
|
|
|
1053
1053
|
## Contributing
|
|
1054
1054
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import MagicString from "magic-string";
|
|
2
|
+
//#region src/build/output-root-externals.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Rewrite external virtual ids into imports of files that live at a fixed
|
|
5
|
+
* place relative to the output root.
|
|
6
|
+
*
|
|
7
|
+
* Some server modules (the cacheability manifest, the pregenerated concrete
|
|
8
|
+
* paths, the Pages client assets) are written beside the server entry, and
|
|
9
|
+
* deploy steps can rewrite them after the build. Rolldown leaves a relative
|
|
10
|
+
* external specifier exactly as written, but it can move the importing module
|
|
11
|
+
* into any chunk, for example a shared chunk under `_next/static/` when the
|
|
12
|
+
* entry becomes a facade. Keeping the virtual id external and resolving it
|
|
13
|
+
* against each chunk's own location keeps the import pointing at the file.
|
|
14
|
+
*
|
|
15
|
+
* `targets` maps each external id to its file path relative to the output root.
|
|
16
|
+
*/
|
|
17
|
+
export declare function rewriteOutputRootExternals(code: string, chunkFileName: string, targets: ReadonlyMap<string, string>): {
|
|
18
|
+
code: string;
|
|
19
|
+
map: ReturnType<MagicString["generateMap"]>;
|
|
20
|
+
} | null;
|
|
21
|
+
//#endregion
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { escapeRegExp } from "../utils/regex.js";
|
|
3
|
+
import MagicString from "magic-string";
|
|
4
|
+
//#region src/build/output-root-externals.ts
|
|
5
|
+
/**
|
|
6
|
+
* Rewrite external virtual ids into imports of files that live at a fixed
|
|
7
|
+
* place relative to the output root.
|
|
8
|
+
*
|
|
9
|
+
* Some server modules (the cacheability manifest, the pregenerated concrete
|
|
10
|
+
* paths, the Pages client assets) are written beside the server entry, and
|
|
11
|
+
* deploy steps can rewrite them after the build. Rolldown leaves a relative
|
|
12
|
+
* external specifier exactly as written, but it can move the importing module
|
|
13
|
+
* into any chunk, for example a shared chunk under `_next/static/` when the
|
|
14
|
+
* entry becomes a facade. Keeping the virtual id external and resolving it
|
|
15
|
+
* against each chunk's own location keeps the import pointing at the file.
|
|
16
|
+
*
|
|
17
|
+
* `targets` maps each external id to its file path relative to the output root.
|
|
18
|
+
*/
|
|
19
|
+
function rewriteOutputRootExternals(code, chunkFileName, targets) {
|
|
20
|
+
let output = null;
|
|
21
|
+
const chunkDir = path.posix.dirname(chunkFileName);
|
|
22
|
+
for (const [id, target] of targets) {
|
|
23
|
+
if (!code.includes(id)) continue;
|
|
24
|
+
let specifier = path.posix.relative(chunkDir, target);
|
|
25
|
+
if (!specifier.startsWith(".")) specifier = `./${specifier}`;
|
|
26
|
+
const quotedId = new RegExp(`(["'])${escapeRegExp(id)}\\1`, "g");
|
|
27
|
+
for (const match of code.matchAll(quotedId)) {
|
|
28
|
+
output ??= new MagicString(code);
|
|
29
|
+
const quote = match[1];
|
|
30
|
+
output.overwrite(match.index, match.index + match[0].length, quote + specifier + quote);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (output === null) return null;
|
|
34
|
+
return {
|
|
35
|
+
code: output.toString(),
|
|
36
|
+
map: output.generateMap({ hires: "boundary" })
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { rewriteOutputRootExternals };
|
|
@@ -3,11 +3,11 @@ import { findDir } from "../utils/project.js";
|
|
|
3
3
|
import { BLOCKED_PAGES, PHASE_PRODUCTION_BUILD } from "../shims/constants.js";
|
|
4
4
|
import { VINEXT_PRERENDER_SECRET_HEADER } from "../utils/protocol-headers.js";
|
|
5
5
|
import { isExternalUrl } from "../utils/external-url.js";
|
|
6
|
+
import "../server/headers.js";
|
|
6
7
|
import { matchHeaders, matchesRewriteSource } from "../config/config-matchers.js";
|
|
7
8
|
import { loadNextConfig, resolveNextConfig } from "../config/next-config.js";
|
|
8
9
|
import { appRouteHasMainTreeLoadingBoundary, appRouter, matchAppRoute } from "../routing/app-router.js";
|
|
9
10
|
import { apiRouter, matchRoute, pagesRouter } from "../routing/pages-router.js";
|
|
10
|
-
import "../server/headers.js";
|
|
11
11
|
import { matchesMiddlewarePathname } from "../server/middleware-matcher.js";
|
|
12
12
|
import { extractLocaleFromUrl, normalizeDefaultLocalePathname } from "../server/pages-i18n.js";
|
|
13
13
|
import { classifyAppRoute, classifyAppRouteHandler, classifyPagesRoute, extractExportConstString, extractMiddlewareMatcherConfig, getAppRouteRenderEntryPath } from "./report.js";
|
package/dist/build/prerender.js
CHANGED
|
@@ -3,8 +3,8 @@ import { createValidFileMatcher, findFileWithExtensions } from "../routing/file-
|
|
|
3
3
|
import { isUnknownRecord } from "../utils/record.js";
|
|
4
4
|
import { BLOCKED_PAGES } from "../shims/constants.js";
|
|
5
5
|
import { VINEXT_PRERENDER_ROUTE_PARAMS_HEADER, VINEXT_PRERENDER_SECRET_HEADER, VINEXT_PRERENDER_SPECULATIVE_HEADER } from "../utils/protocol-headers.js";
|
|
6
|
-
import { appRouteLayoutStaticParamsGroups } from "../routing/app-router.js";
|
|
7
6
|
import { NEXT_CACHE_TAGS_HEADER, VINEXT_METADATA_ROUTE_CACHE_HEADER, VINEXT_PRERENDER_CACHE_LIFE_HEADER, VINEXT_PRERENDER_METADATA_ROUTES_PATH, VINEXT_PRERENDER_RENDER_ERROR_HEADER, VINEXT_PRERENDER_SPECIAL_ERROR_HEADER } from "../server/headers.js";
|
|
7
|
+
import { appRouteLayoutStaticParamsGroups } from "../routing/app-router.js";
|
|
8
8
|
import { extractLocaleFromUrl } from "../server/pages-i18n.js";
|
|
9
9
|
import { classifyAppRoute, classifyPagesRoute, getAppRouteRenderEntryPath } from "./report.js";
|
|
10
10
|
import { resolveClientStaleTimeSeconds } from "../utils/cache-control-metadata.js";
|
package/dist/check.js
CHANGED
|
@@ -3,10 +3,9 @@ import path from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
|
3
3
|
import { detectPackageManager, findDir, findViteConfigPath } from "./utils/project.js";
|
|
4
4
|
import { normalizePageExtensions } from "./routing/file-matcher.js";
|
|
5
5
|
import { POSTCSS_CONFIG_FILES } from "./plugins/postcss.js";
|
|
6
|
-
import { unwrapExpression } from "./plugins/ast-utils.js";
|
|
6
|
+
import { parseProgram, unwrapExpression } from "./plugins/ast-utils.js";
|
|
7
7
|
import { require_ignore } from "./deps/.pnpm/ignore@5.3.2/deps/ignore/index.js";
|
|
8
8
|
import fs from "node:fs";
|
|
9
|
-
import { parseAst } from "vite";
|
|
10
9
|
//#region src/check.ts
|
|
11
10
|
/**
|
|
12
11
|
* vinext check — compatibility scanner for Next.js apps
|
|
@@ -813,7 +812,7 @@ function propertyKeyName(prop) {
|
|
|
813
812
|
* object — top-level keys plus, for each object-valued property, its child keys
|
|
814
813
|
* (used for dot-notation options like `experimental.ppr`).
|
|
815
814
|
*
|
|
816
|
-
* Uses Vite's
|
|
815
|
+
* Uses Vite's bundled oxc parser instead of scanning text, so
|
|
817
816
|
* comments, string values, and other non-key mentions of an option name are
|
|
818
817
|
* never mistaken for a real config option. Returns empty sets if the file cannot
|
|
819
818
|
* be parsed — the check is advisory, so a parse failure simply reports nothing.
|
|
@@ -824,7 +823,7 @@ function collectConfigKeys(source) {
|
|
|
824
823
|
let pageExtensions;
|
|
825
824
|
let program;
|
|
826
825
|
try {
|
|
827
|
-
program =
|
|
826
|
+
program = parseProgram(source, { lang: "ts" });
|
|
828
827
|
} catch {
|
|
829
828
|
return {
|
|
830
829
|
top,
|
|
@@ -971,7 +970,7 @@ function isNextConfigWithCjsGlobals(rel, content) {
|
|
|
971
970
|
if (/^next\.config\.(?:ts|mts|cjs)$/.test(rel)) return true;
|
|
972
971
|
if (rel !== "next.config.js") return false;
|
|
973
972
|
try {
|
|
974
|
-
return !
|
|
973
|
+
return !parseProgram(content).body.some((node) => node.type === "ImportDeclaration" || node.type.startsWith("Export"));
|
|
975
974
|
} catch {
|
|
976
975
|
return false;
|
|
977
976
|
}
|
|
@@ -984,7 +983,7 @@ function isNextConfigWithCjsGlobals(rel, content) {
|
|
|
984
983
|
function exportsPostcssPluginsOnlyObject(content) {
|
|
985
984
|
let program;
|
|
986
985
|
try {
|
|
987
|
-
program =
|
|
986
|
+
program = parseProgram(content, { lang: "ts" });
|
|
988
987
|
} catch {
|
|
989
988
|
return false;
|
|
990
989
|
}
|
package/dist/cli-dev-config.js
CHANGED
|
@@ -28,7 +28,7 @@ function claimViteCliDevInvocation(root, isRestart = false, isReserved = false)
|
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
30
|
function applyDevServerDefaults(server, options) {
|
|
31
|
-
|
|
31
|
+
if (options.port !== void 0) server.port = options.port;
|
|
32
32
|
server.host = options.hostname ?? server.host ?? "localhost";
|
|
33
33
|
}
|
|
34
34
|
function createDevServerLifecyclePlugin(options, isEnabled) {
|
|
@@ -114,7 +114,7 @@ function configureDevServerLifecycle(server) {
|
|
|
114
114
|
const listenServer = server.listen.bind(server);
|
|
115
115
|
server.listen = async (port, isRestart) => {
|
|
116
116
|
if (server.config.server.middlewareMode || process.env.VINEXT_NO_DEV_LOCK === "1") return listenServer(port, isRestart);
|
|
117
|
-
const configuredPort = port ?? server.config.server.port
|
|
117
|
+
const configuredPort = port ?? server.config.server.port;
|
|
118
118
|
const hostname = normalizeDevServerHostname(server.config.server.host);
|
|
119
119
|
const displayHostname = hostname === "0.0.0.0" ? "localhost" : hostname;
|
|
120
120
|
const restartingLock = activeDevServerLocks.get(root);
|
|
@@ -155,7 +155,7 @@ function configureDevServerLifecycle(server) {
|
|
|
155
155
|
};
|
|
156
156
|
server.httpServer?.on("listening", () => {
|
|
157
157
|
if (!activeLock) return;
|
|
158
|
-
const port = server.config.server.port
|
|
158
|
+
const port = server.config.server.port;
|
|
159
159
|
const hostname = normalizeDevServerHostname(server.config.server.host);
|
|
160
160
|
const displayHostname = hostname === "0.0.0.0" ? "localhost" : hostname;
|
|
161
161
|
const lock = activeLock;
|
package/dist/cli.js
CHANGED
|
@@ -364,7 +364,7 @@ function printHelp(cmd) {
|
|
|
364
364
|
--version Show version
|
|
365
365
|
|
|
366
366
|
Examples:
|
|
367
|
-
vinext dev Start dev server
|
|
367
|
+
vinext dev Start dev server
|
|
368
368
|
vinext dev --port 4000 Start dev server on port 4000
|
|
369
369
|
vinext build Build for production
|
|
370
370
|
vinext typegen Generate route helper types
|
|
@@ -3,6 +3,7 @@ import { buildRequestHeadersFromMiddlewareResponse, getUnconsumedMiddlewareReque
|
|
|
3
3
|
import { analyzeRegexSafety } from "../utils/regex-safety.js";
|
|
4
4
|
import { normalizeHost, parseCookies, requestContextFromRequest } from "./request-context.js";
|
|
5
5
|
import { isExternalUrl } from "../utils/external-url.js";
|
|
6
|
+
import { attachRequestCfMetadata } from "../server/request-pipeline.js";
|
|
6
7
|
import { substituteDestinationParams, substituteRedirectDestinationQuery } from "./destination-params.js";
|
|
7
8
|
//#region src/config/config-matchers.ts
|
|
8
9
|
/**
|
|
@@ -296,13 +297,17 @@ function applyMiddlewareRequestHeaders(middlewareHeaders, request) {
|
|
|
296
297
|
const nextHeaders = buildRequestHeadersFromMiddlewareResponse(request.headers, middlewareHeaders);
|
|
297
298
|
const unconsumedRequestHeaders = getUnconsumedMiddlewareRequestHeaders(middlewareHeaders);
|
|
298
299
|
for (const key of Object.keys(middlewareHeaders)) if (key.startsWith("x-middleware-") && key !== "x-middleware-cache" && !unconsumedRequestHeaders.has(key)) delete middlewareHeaders[key];
|
|
299
|
-
if (nextHeaders)
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
300
|
+
if (nextHeaders) {
|
|
301
|
+
const source = request;
|
|
302
|
+
request = new Request(request.url, {
|
|
303
|
+
method: request.method,
|
|
304
|
+
headers: nextHeaders,
|
|
305
|
+
body: request.body,
|
|
306
|
+
signal: request.signal,
|
|
307
|
+
duplex: request.body ? "half" : void 0
|
|
308
|
+
});
|
|
309
|
+
attachRequestCfMetadata(request, source);
|
|
310
|
+
}
|
|
306
311
|
return {
|
|
307
312
|
request,
|
|
308
313
|
postMwReqCtx: requestContextFromRequest(request)
|