vinext 1.0.0-beta.0 → 1.0.0-beta.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 +17 -1
- package/dist/build/assets-ignore.js +1 -1
- package/dist/build/clean-output.js +1 -1
- package/dist/build/client-build-config.js +6 -4
- package/dist/build/css-url-assets.js +3 -3
- package/dist/build/google-fonts/fallback-metrics.js +1 -1
- package/dist/build/google-fonts/font-metadata.js +1 -1
- package/dist/build/inject-pregenerated-paths.js +1 -1
- package/dist/build/inline-css.js +2 -5
- package/dist/build/module-dependency-cache.d.ts +4 -0
- package/dist/build/module-dependency-cache.js +13 -0
- package/dist/build/next-client-runtime-manifests.js +1 -1
- package/dist/build/pages-client-assets-module.js +1 -1
- package/dist/build/precompress.js +7 -7
- package/dist/build/prerender-paths.d.ts +2 -2
- package/dist/build/prerender-paths.js +10 -15
- package/dist/build/prerender-server-pool.js +2 -2
- package/dist/build/prerender.js +1 -1
- package/dist/build/preview-credentials.d.ts +11 -0
- package/dist/build/preview-credentials.js +19 -0
- package/dist/build/report.d.ts +0 -3
- package/dist/build/report.js +2 -4
- package/dist/build/run-prerender.d.ts +2 -11
- package/dist/build/run-prerender.js +2 -10
- package/dist/build/server-manifest.js +1 -1
- package/dist/build/ssr-manifest.d.ts +4 -0
- package/dist/build/ssr-manifest.js +10 -6
- package/dist/build/standalone.js +37 -37
- package/dist/cache/cache-adapters-virtual.d.ts +1 -17
- package/dist/cache/cache-adapters-virtual.js +20 -11
- package/dist/check.d.ts +0 -16
- package/dist/check.js +12 -34
- package/dist/cli.js +58 -53
- package/dist/client/instrumentation-client-inject.js +1 -1
- package/dist/client/pages-router-link-navigation.js +1 -1
- package/dist/config/config-matchers.js +2 -2
- package/dist/config/dotenv.js +1 -1
- package/dist/config/next-config.d.ts +4 -1
- package/dist/config/next-config.js +81 -14
- package/dist/config/prerender.d.ts +2 -2
- package/dist/config/prerender.js +7 -15
- package/dist/config/server-external-packages.js +1 -1
- package/dist/config/tsconfig-paths.js +2 -2
- package/dist/{node_modules/.pnpm/am-i-vibing@0.5.0/node_modules → deps/.pnpm/am-i-vibing@0.5.0/deps}/am-i-vibing/dist/detector-1yx2Hoe0.js +2 -2
- package/dist/deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js +50 -0
- package/dist/entries/app-rsc-entry.js +12 -5
- package/dist/entries/app-rsc-manifest.js +4 -4
- package/dist/entries/pages-client-entry.js +6 -5
- package/dist/entries/pages-server-entry.js +15 -26
- package/dist/entries/runtime-entry-module.js +2 -2
- package/dist/index.js +255 -195
- package/dist/init-cloudflare.js +1 -1
- package/dist/init-platform.js +1 -1
- package/dist/init.js +5 -5
- package/dist/plugins/ast-utils.js +1 -1
- package/dist/plugins/dynamic-preload-metadata.js +7 -7
- package/dist/plugins/extensionless-dynamic-import.js +1 -1
- package/dist/plugins/fonts.js +3 -3
- package/dist/plugins/ignore-dynamic-requests.js +13 -8
- package/dist/plugins/import-meta-url.js +16 -17
- package/dist/plugins/middleware-export-validation.js +1 -1
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +7 -6
- package/dist/plugins/og-assets.js +4 -5
- package/dist/plugins/optimize-imports.js +12 -13
- package/dist/plugins/postcss.js +1 -1
- package/dist/plugins/remove-console.js +1 -1
- package/dist/plugins/require-context.js +1 -1
- package/dist/plugins/sass.js +2 -2
- package/dist/plugins/server-externals-manifest.js +1 -1
- package/dist/plugins/strip-server-exports.js +1 -1
- package/dist/plugins/styled-jsx.js +3 -2
- package/dist/plugins/typeof-window.js +1 -1
- package/dist/routing/app-route-graph.d.ts +3 -10
- package/dist/routing/app-route-graph.js +28 -76
- package/dist/routing/app-router.d.ts +0 -5
- package/dist/routing/app-router.js +0 -5
- package/dist/routing/file-matcher.d.ts +2 -6
- package/dist/routing/file-matcher.js +10 -11
- package/dist/routing/pages-router.js +3 -3
- package/dist/server/api-handler.js +41 -33
- package/dist/server/app-browser-entry.js +17 -11
- package/dist/server/app-browser-navigation-controller.js +5 -3
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-browser-state.js +1 -1
- package/dist/server/app-browser-visible-commit.js +1 -1
- package/dist/server/app-elements-wire.d.ts +2 -1
- package/dist/server/app-fallback-renderer.d.ts +8 -0
- package/dist/server/app-fallback-renderer.js +13 -1
- package/dist/server/app-page-boundary-render.d.ts +14 -1
- package/dist/server/app-page-boundary-render.js +107 -54
- package/dist/server/app-page-dispatch.d.ts +1 -0
- package/dist/server/app-page-dispatch.js +26 -37
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +3 -3
- package/dist/server/app-page-execution.d.ts +3 -1
- package/dist/server/app-page-execution.js +31 -39
- package/dist/server/app-page-request.js +1 -1
- package/dist/server/app-page-route-wiring.js +1 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-route-tree-prefetch.js +1 -1
- package/dist/server/app-rsc-cache-busting.js +1 -1
- package/dist/server/app-rsc-handler.js +3 -3
- package/dist/server/app-rsc-redirect-flight.d.ts +66 -0
- package/dist/server/app-rsc-redirect-flight.js +71 -0
- package/dist/server/app-segment-config.js +2 -2
- package/dist/server/app-server-action-execution.js +1 -1
- package/dist/server/app-ssr-entry.js +6 -3
- package/dist/server/app-ssr-stream.d.ts +2 -1
- package/dist/server/app-ssr-stream.js +4 -1
- package/dist/server/cache-proof.js +1 -1
- package/dist/server/default-global-error-module.d.ts +3 -1
- package/dist/server/default-not-found-module.d.ts +3 -1
- package/dist/server/dev-lockfile.js +2 -3
- package/dist/server/dev-route-files.js +1 -1
- package/dist/server/dev-server.js +253 -161
- package/dist/server/dev-stack-sourcemap.js +4 -3
- package/dist/server/headers.d.ts +3 -1
- package/dist/server/headers.js +3 -1
- package/dist/server/image-optimization.js +2 -2
- package/dist/server/implicit-tags.js +2 -1
- package/dist/server/instrumentation.js +2 -2
- package/dist/server/isr-cache.js +1 -1
- package/dist/server/metadata-routes.js +4 -4
- package/dist/server/middleware-response-headers.js +1 -1
- package/dist/server/middleware-runtime.js +1 -1
- package/dist/server/middleware.d.ts +1 -0
- package/dist/server/middleware.js +1 -1
- package/dist/server/navigation-planner.d.ts +2 -0
- package/dist/server/navigation-planner.js +8 -2
- package/dist/server/next-error-digest.d.ts +9 -24
- package/dist/server/next-error-digest.js +23 -15
- package/dist/server/operation-token.js +1 -1
- package/dist/server/pages-body-parser-config.js +2 -1
- package/dist/server/pages-dev-hydration.d.ts +14 -0
- package/dist/server/pages-dev-hydration.js +83 -0
- package/dist/server/pages-dev-module-url.js +2 -2
- package/dist/server/pages-node-compat.d.ts +13 -6
- package/dist/server/pages-node-compat.js +44 -45
- package/dist/server/pages-page-data.d.ts +1 -1
- package/dist/server/pages-page-data.js +4 -3
- package/dist/server/pages-page-handler.js +61 -29
- package/dist/server/pages-page-response.d.ts +2 -2
- package/dist/server/pages-preview.d.ts +26 -0
- package/dist/server/pages-preview.js +165 -0
- package/dist/server/pages-readiness.d.ts +2 -1
- package/dist/server/pages-readiness.js +4 -2
- package/dist/server/prod-server.js +9 -8
- package/dist/server/request-pipeline.js +1 -1
- package/dist/server/seed-cache.js +1 -1
- package/dist/server/socket-error-backstop.js +1 -1
- package/dist/server/static-file-cache.js +7 -8
- package/dist/server/worker-utils.js +1 -1
- package/dist/shims/cache.js +2 -1
- package/dist/shims/constants.js +1 -1
- package/dist/shims/error-boundary.d.ts +4 -4
- package/dist/shims/error.d.ts +21 -5
- package/dist/shims/error.js +52 -14
- package/dist/shims/fetch-cache.js +1 -1
- package/dist/shims/font-utils.js +1 -1
- package/dist/shims/form.d.ts +1 -1
- package/dist/shims/head.js +3 -3
- package/dist/shims/headers.js +6 -4
- package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
- package/dist/shims/layout-segment-context.d.ts +1 -1
- package/dist/shims/link.d.ts +3 -1
- package/dist/shims/link.js +6 -3
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation-errors.js +9 -13
- package/dist/shims/navigation.d.ts +1 -1
- package/dist/shims/navigation.js +5 -5
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router.d.ts +2 -1
- package/dist/shims/router.js +18 -11
- package/dist/shims/script.js +1 -1
- package/dist/shims/server.js +2 -2
- package/dist/shims/slot.d.ts +1 -1
- package/dist/shims/thenable-params.js +1 -1
- package/dist/typegen.js +9 -11
- package/dist/utils/client-build-manifest.js +2 -2
- package/dist/utils/client-entry-manifest.js +1 -1
- package/dist/utils/client-runtime-metadata.js +1 -1
- package/dist/utils/commonjs-loader.js +3 -3
- package/dist/utils/mdx-scan.js +1 -1
- package/dist/utils/path.d.ts +1 -13
- package/dist/utils/path.js +1 -15
- package/dist/utils/plugin-options.d.ts +4 -0
- package/dist/utils/plugin-options.js +8 -0
- package/dist/utils/project.d.ts +0 -6
- package/dist/utils/project.js +2 -8
- package/dist/utils/public-routes.js +2 -2
- package/dist/utils/react-version.js +1 -1
- package/dist/utils/redirect-digest.d.ts +9 -0
- package/dist/utils/redirect-digest.js +25 -0
- package/dist/utils/vinext-root.js +1 -1
- package/dist/utils/vite-version.d.ts +5 -2
- package/dist/utils/vite-version.js +43 -17
- package/package.json +4 -3
- /package/dist/build/google-fonts/{fallback-metrics-data.js → fallback-metrics-data.json.js} +0 -0
- /package/dist/build/google-fonts/{font-data.js → font-data.json.js} +0 -0
- /package/dist/{node_modules/.pnpm/process-ancestry@0.1.0/node_modules → deps/.pnpm/process-ancestry@0.1.0/deps}/process-ancestry/dist/index.js +0 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import path, { toSlash } from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { detectPackageManager, formatMissingCloudflarePluginError, hasWranglerConfig } from "./utils/project.js";
|
|
2
|
-
import { normalizePathSeparators, stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
3
3
|
import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
|
|
4
|
-
import { escapeRegExp } from "./utils/regex.js";
|
|
5
4
|
import { buildViteResolveExtensions, createValidFileMatcher, findFileWithExts, normalizeViteResolveExtensions } from "./routing/file-matcher.js";
|
|
6
5
|
import { apiRouter, invalidateRouteCache, matchRoute, pagesRouter } from "./routing/pages-router.js";
|
|
7
6
|
import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
|
|
@@ -21,6 +20,7 @@ import { logRequest, now } from "./server/request-log.js";
|
|
|
21
20
|
import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
|
|
22
21
|
import { isNextDataPathname, normalizeNextDataPagePathname, parseNextDataPathname } from "./server/pages-data-route.js";
|
|
23
22
|
import { resolveAssetsDir } from "./utils/asset-prefix.js";
|
|
23
|
+
import { getPagesPreviewModeId } from "./server/pages-preview.js";
|
|
24
24
|
import { createSSRHandler } from "./server/dev-server.js";
|
|
25
25
|
import { handleApiRoute } from "./server/api-handler.js";
|
|
26
26
|
import { DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath, resolveDevImageRedirect } from "./server/image-optimization.js";
|
|
@@ -38,7 +38,7 @@ import { collectRouteClassificationManifest } from "./build/route-classification
|
|
|
38
38
|
import { planRouteClassificationInjection } from "./build/route-classification-injector.js";
|
|
39
39
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/constants.js";
|
|
40
40
|
import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
|
|
41
|
-
import { createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
41
|
+
import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
|
|
42
42
|
import { mergeServerExternalPackages } from "./config/server-external-packages.js";
|
|
43
43
|
import { precompressAssets } from "./build/precompress.js";
|
|
44
44
|
import { ensureAssetsIgnore } from "./build/assets-ignore.js";
|
|
@@ -59,6 +59,7 @@ import { createInstrumentationClientTransformPlugin } from "./plugins/instrument
|
|
|
59
59
|
import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
|
|
60
60
|
import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
|
|
61
61
|
import { createMiddlewareServerOnlyPlugin } from "./plugins/middleware-server-only.js";
|
|
62
|
+
import { stripJsExtension, stripViteModuleQuery } from "./utils/path.js";
|
|
62
63
|
import { validateMiddlewareModuleExports } from "./plugins/middleware-export-validation.js";
|
|
63
64
|
import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
|
|
64
65
|
import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
|
|
@@ -70,6 +71,8 @@ import { createServerExternalsManifestPlugin } from "./plugins/server-externals-
|
|
|
70
71
|
import { VINEXT_CLIENT_ENTRY_MANIFEST } from "./utils/client-entry-manifest.js";
|
|
71
72
|
import { computeClientRuntimeMetadata } from "./utils/client-runtime-metadata.js";
|
|
72
73
|
import { PAGES_CLIENT_ASSETS_MODULE, buildPagesClientAssetsModule, setPagesClientAssetsBuildMetadata, takePagesClientAssetsBuildMetadata, writePagesClientAssetsModuleIfMissing } from "./build/pages-client-assets-module.js";
|
|
74
|
+
import { createPreviewBuildCredentials, getPreviewBuildCredentials } from "./build/preview-credentials.js";
|
|
75
|
+
import { createModuleDependencyCache } from "./build/module-dependency-cache.js";
|
|
73
76
|
import { resolvePostcssStringPlugins } from "./plugins/postcss.js";
|
|
74
77
|
import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
|
|
75
78
|
import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter } from "./plugins/sass.js";
|
|
@@ -89,10 +92,9 @@ import { VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY, VINEXT_ROUTE_ROOT_CONFIG_PLUGI
|
|
|
89
92
|
import { staticExportApp, staticExportPages } from "./build/static-export.js";
|
|
90
93
|
import { createRequire } from "node:module";
|
|
91
94
|
import fs from "node:fs";
|
|
92
|
-
import path from "node:path";
|
|
93
95
|
import { createLogger, loadEnv, parseAst, transformWithOxc } from "vite";
|
|
94
96
|
import { pathToFileURL } from "node:url";
|
|
95
|
-
import { createHash, randomBytes
|
|
97
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
96
98
|
import commonjs from "vite-plugin-commonjs";
|
|
97
99
|
import MagicString from "magic-string";
|
|
98
100
|
//#region src/index.ts
|
|
@@ -109,10 +111,6 @@ const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-s
|
|
|
109
111
|
const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
|
|
110
112
|
const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
|
|
111
113
|
installSocketErrorBackstop();
|
|
112
|
-
function getCacheDirPrefix(cacheDir) {
|
|
113
|
-
const normalizedCacheDir = normalizePathSeparators(cacheDir);
|
|
114
|
-
return normalizedCacheDir.endsWith("/") ? normalizedCacheDir : `${normalizedCacheDir}/`;
|
|
115
|
-
}
|
|
116
114
|
function isInsideDirectory(dir, filePath) {
|
|
117
115
|
const relativePath = path.relative(dir, filePath);
|
|
118
116
|
return relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
|
|
@@ -165,21 +163,22 @@ function resolveShimModulePath(shimsDir, moduleName) {
|
|
|
165
163
|
".tsx",
|
|
166
164
|
".js"
|
|
167
165
|
]) {
|
|
168
|
-
const candidate = path.
|
|
166
|
+
const candidate = path.join(shimsDir, `${moduleName}${ext}`);
|
|
169
167
|
if (fs.existsSync(candidate)) return candidate;
|
|
170
168
|
}
|
|
171
|
-
return path.
|
|
169
|
+
return path.join(shimsDir, `${moduleName}.js`);
|
|
172
170
|
}
|
|
173
171
|
function isVercelOgImport(id) {
|
|
174
172
|
return id === "@vercel/og" || id === "@vercel/og.js";
|
|
175
173
|
}
|
|
176
174
|
function isVinextOgShimImporter(importer) {
|
|
177
175
|
if (!importer) return false;
|
|
178
|
-
const
|
|
176
|
+
const cleanImporter = (importer.startsWith("\0") ? importer.slice(1) : importer).split("?")[0];
|
|
177
|
+
const normalizedImporter = toSlash(cleanImporter);
|
|
179
178
|
return normalizedImporter.endsWith("/shims/og.tsx") || normalizedImporter.endsWith("/shims/og.js") || normalizedImporter.endsWith("/dist/shims/og.js");
|
|
180
179
|
}
|
|
181
180
|
function toRelativeFileEntry(root, absPath) {
|
|
182
|
-
return path.relative(root, absPath)
|
|
181
|
+
return path.relative(root, absPath);
|
|
183
182
|
}
|
|
184
183
|
const DEV_PAGES_CLIENT_ENTRY = "/@id/__x00__virtual:vinext-client-entry";
|
|
185
184
|
const STYLESHEET_IMPORT_RE = /\.(?:css|scss|sass)$/i;
|
|
@@ -243,7 +242,7 @@ function isScriptModuleId(id) {
|
|
|
243
242
|
return SCRIPT_IMPORT_RE.test(stripViteModuleQuery(id).toLowerCase());
|
|
244
243
|
}
|
|
245
244
|
function skipCommonjsForLocalCjs(id) {
|
|
246
|
-
const cleanId =
|
|
245
|
+
const cleanId = toSlash(stripViteModuleQuery(id));
|
|
247
246
|
return /\.c[jt]s$/i.test(cleanId) && !cleanId.includes("node_modules") ? false : void 0;
|
|
248
247
|
}
|
|
249
248
|
function hasOnlyTypeSpecifiers(statement) {
|
|
@@ -255,24 +254,37 @@ function resolvedStylesheetToDevManifestAsset(root, resolvedId) {
|
|
|
255
254
|
const rootForRelative = tryRealpathSync(root) ?? root;
|
|
256
255
|
const fileForRelative = tryRealpathSync(cleanId) ?? cleanId;
|
|
257
256
|
const relativePath = path.relative(rootForRelative, fileForRelative);
|
|
258
|
-
if (relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath)) return
|
|
259
|
-
return `@fs/${
|
|
257
|
+
if (relativePath !== "" && !relativePath.startsWith("..") && !path.isAbsolute(relativePath)) return relativePath;
|
|
258
|
+
return `@fs/${toSlash(cleanId).replace(/^\/+/, "")}`;
|
|
260
259
|
}
|
|
261
|
-
async function collectDevPagesAppStylesheetAssets(
|
|
260
|
+
async function collectDevPagesAppStylesheetAssets(appFilePath, getModuleDependencies) {
|
|
262
261
|
const stylesheetAssets = [];
|
|
263
262
|
const seenAssets = /* @__PURE__ */ new Set();
|
|
264
263
|
const seenModules = /* @__PURE__ */ new Set();
|
|
265
264
|
async function visitModule(modulePath) {
|
|
265
|
+
if (seenModules.has(modulePath)) return;
|
|
266
|
+
seenModules.add(modulePath);
|
|
267
|
+
for (const dependency of await getModuleDependencies(modulePath)) if (dependency.type === "stylesheet") {
|
|
268
|
+
if (seenAssets.has(dependency.asset)) continue;
|
|
269
|
+
seenAssets.add(dependency.asset);
|
|
270
|
+
stylesheetAssets.push(dependency.asset);
|
|
271
|
+
} else await visitModule(dependency.id);
|
|
272
|
+
}
|
|
273
|
+
await visitModule(appFilePath);
|
|
274
|
+
return stylesheetAssets;
|
|
275
|
+
}
|
|
276
|
+
function createDevPagesModuleDependencyReader(root, resolve) {
|
|
277
|
+
return createModuleDependencyCache(collectModuleDependencies);
|
|
278
|
+
async function collectModuleDependencies(modulePath) {
|
|
266
279
|
const cleanModulePath = stripViteModuleQuery(modulePath);
|
|
267
|
-
if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return;
|
|
268
|
-
if (seenModules.has(cleanModulePath)) return;
|
|
269
|
-
seenModules.add(cleanModulePath);
|
|
280
|
+
if (!path.isAbsolute(cleanModulePath) || !fs.existsSync(cleanModulePath)) return [];
|
|
270
281
|
let ast;
|
|
271
282
|
try {
|
|
272
283
|
ast = parseAst(fs.readFileSync(cleanModulePath, "utf-8"), { lang: parserLanguageForScript(cleanModulePath) });
|
|
273
284
|
} catch {
|
|
274
|
-
return;
|
|
285
|
+
return [];
|
|
275
286
|
}
|
|
287
|
+
const dependencies = [];
|
|
276
288
|
for (const statement of ast.body) {
|
|
277
289
|
if (statement.type !== "ImportDeclaration" && statement.type !== "ExportNamedDeclaration" && statement.type !== "ExportAllDeclaration") continue;
|
|
278
290
|
if (statement.importKind === "type") continue;
|
|
@@ -285,17 +297,17 @@ async function collectDevPagesAppStylesheetAssets(root, appFilePath, resolve) {
|
|
|
285
297
|
if (!resolved?.id) continue;
|
|
286
298
|
if (isStylesheetSpecifier(specifier)) {
|
|
287
299
|
const asset = resolvedStylesheetToDevManifestAsset(root, resolved.id);
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
300
|
+
if (asset) dependencies.push({
|
|
301
|
+
type: "stylesheet",
|
|
302
|
+
asset
|
|
303
|
+
});
|
|
304
|
+
} else if (!specifier.includes("?") && !specifier.includes("#") && isScriptModuleId(resolved.id)) dependencies.push({
|
|
305
|
+
type: "script",
|
|
306
|
+
id: resolved.id
|
|
307
|
+
});
|
|
295
308
|
}
|
|
309
|
+
return dependencies;
|
|
296
310
|
}
|
|
297
|
-
await visitModule(appFilePath);
|
|
298
|
-
return stylesheetAssets;
|
|
299
311
|
}
|
|
300
312
|
const TSCONFIG_FILES = ["tsconfig.json", "jsconfig.json"];
|
|
301
313
|
function resolveTsconfigPathCandidate(candidate) {
|
|
@@ -353,11 +365,11 @@ function materializeTsconfigPathAliases(pathsConfig, baseUrl, projectRoot) {
|
|
|
353
365
|
return aliases;
|
|
354
366
|
}
|
|
355
367
|
function toViteAliasReplacement(absolutePath, projectRoot) {
|
|
356
|
-
const normalizedPath = absolutePath
|
|
357
|
-
const rootCandidates = new Set([projectRoot]);
|
|
368
|
+
const normalizedPath = toSlash(absolutePath);
|
|
369
|
+
const rootCandidates = /* @__PURE__ */ new Set([projectRoot]);
|
|
358
370
|
const realRoot = tryRealpathSync(projectRoot);
|
|
359
371
|
if (realRoot) rootCandidates.add(realRoot);
|
|
360
|
-
const pathCandidates = new Set([absolutePath]);
|
|
372
|
+
const pathCandidates = /* @__PURE__ */ new Set([absolutePath]);
|
|
361
373
|
const realPath = tryRealpathSync(absolutePath);
|
|
362
374
|
if (realPath) pathCandidates.add(realPath);
|
|
363
375
|
for (const rootCandidate of rootCandidates) for (const pathCandidate of pathCandidates) {
|
|
@@ -378,7 +390,7 @@ function resolveSwcHelpersAlias(root) {
|
|
|
378
390
|
resolvers.push(rootRequire, createRequire(import.meta.url));
|
|
379
391
|
for (const resolver of resolvers) try {
|
|
380
392
|
const packageJsonPath = resolver.resolve("@swc/helpers/package.json");
|
|
381
|
-
return
|
|
393
|
+
return path.join(path.dirname(packageJsonPath), "_");
|
|
382
394
|
} catch {}
|
|
383
395
|
}
|
|
384
396
|
function loadTsconfigPathAliases(configPath, projectRoot, seen = /* @__PURE__ */ new Set()) {
|
|
@@ -432,7 +444,7 @@ function getVinextVersion() {
|
|
|
432
444
|
return _vinextVersionCache;
|
|
433
445
|
}
|
|
434
446
|
function mergeStringArrayValues(value, additions) {
|
|
435
|
-
return [
|
|
447
|
+
return [.../* @__PURE__ */ new Set([...value === void 0 ? [] : Array.isArray(value) ? value : [value], ...additions])];
|
|
436
448
|
}
|
|
437
449
|
function stripAnsi(value) {
|
|
438
450
|
return value.replace(ANSI_ESCAPE_RE, "");
|
|
@@ -579,14 +591,14 @@ function createStaticImageAsset(imagePath) {
|
|
|
579
591
|
};
|
|
580
592
|
}
|
|
581
593
|
/**
|
|
582
|
-
* Absolute path to vinext's shims directory, with a trailing slash.
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
594
|
+
* Absolute path to vinext's shims directory, with a trailing slash. Forward
|
|
595
|
+
* slashes are guaranteed by pathslash's `path.resolve`, matching the Vite
|
|
596
|
+
* module ids (always forward-slash) that the `id.startsWith(_shimsDir)`
|
|
597
|
+
* prefix checks in the font plugins and clientManualChunks compare against.
|
|
598
|
+
* The trailing "/" keeps those prefix checks directory-exact.
|
|
587
599
|
*/
|
|
588
|
-
const _shimsDir =
|
|
589
|
-
const _serverDir =
|
|
600
|
+
const _shimsDir = path.resolve(__dirname, "shims") + "/";
|
|
601
|
+
const _serverDir = path.resolve(__dirname, "server");
|
|
590
602
|
const _fontGoogleShimPath = resolveShimModulePath(_shimsDir, "font-google");
|
|
591
603
|
const _appBrowserServerActionClientPath = resolveShimModulePath(_serverDir, "app-browser-server-action-client");
|
|
592
604
|
const _appRscHandlerPath = resolveShimModulePath(_serverDir, "app-rsc-handler");
|
|
@@ -597,8 +609,8 @@ function isValidExportIdentifier(name) {
|
|
|
597
609
|
}
|
|
598
610
|
function isVirtualEntryFacade(id, virtualId) {
|
|
599
611
|
if (!id) return false;
|
|
600
|
-
const cleanId = id.startsWith("\0") ? id.slice(1) : id;
|
|
601
|
-
return cleanId === virtualId || cleanId.endsWith("/" + virtualId)
|
|
612
|
+
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
613
|
+
return cleanId === virtualId || cleanId.endsWith("/" + virtualId);
|
|
602
614
|
}
|
|
603
615
|
/**
|
|
604
616
|
* Returns the leading React `"use client"` or `"use server"` directive after
|
|
@@ -669,7 +681,7 @@ function generateRootParamsModule(rootParamNames) {
|
|
|
669
681
|
* 1. Create `<name>.react-server.ts` in src/shims/
|
|
670
682
|
* 2. Add entries here for each import specifier.
|
|
671
683
|
*/
|
|
672
|
-
const _reactServerShims = new Map([
|
|
684
|
+
const _reactServerShims = /* @__PURE__ */ new Map([
|
|
673
685
|
["next/navigation", "navigation"],
|
|
674
686
|
["next/navigation.js", "navigation"],
|
|
675
687
|
["next/dist/client/components/navigation", "navigation"],
|
|
@@ -687,7 +699,7 @@ function getClientOutputConfig(assetsDir, preserveAppRouteBoundaries = false) {
|
|
|
687
699
|
};
|
|
688
700
|
}
|
|
689
701
|
function vinext(options = {}) {
|
|
690
|
-
assertSupportedViteVersion();
|
|
702
|
+
const { supportsNativeTypeofWindowFolding: useNativeTypeofWindowFolding } = assertSupportedViteVersion();
|
|
691
703
|
const prerenderConfig = normalizeVinextPrerenderConfig(options.prerender);
|
|
692
704
|
let root;
|
|
693
705
|
let pagesDir;
|
|
@@ -706,17 +718,18 @@ function vinext(options = {}) {
|
|
|
706
718
|
let hasCloudflarePlugin = false;
|
|
707
719
|
let warnedInlineNextConfigOverride = false;
|
|
708
720
|
let hasNitroPlugin = false;
|
|
721
|
+
let nitroTraceDepsFromServerExternals = [];
|
|
709
722
|
let isServeCommand = false;
|
|
710
723
|
let pagesOptimizeEntries = [];
|
|
711
724
|
const pagesClientAssetsOutputDirs = /* @__PURE__ */ new Set();
|
|
712
725
|
let pagesClientAssetsModule = null;
|
|
713
726
|
let rscCompatibilityId;
|
|
714
|
-
|
|
727
|
+
let draftModeSecret = getPagesPreviewModeId();
|
|
728
|
+
let previewBuildCredentials;
|
|
715
729
|
const sassComposesLoader = createSassAwareFileSystemLoader();
|
|
716
|
-
const typeofWindowIdFilter = { exclude: /(?!)/ };
|
|
717
730
|
let rscClassificationManifest = null;
|
|
718
|
-
const shimsDir =
|
|
719
|
-
const canonicalize = (p) =>
|
|
731
|
+
const shimsDir = path.resolve(__dirname, "shims");
|
|
732
|
+
const canonicalize = (p) => toSlash(tryRealpathSync(p) ?? p);
|
|
720
733
|
const pageTransformCanonicalPaths = /* @__PURE__ */ new Map();
|
|
721
734
|
const canonicalizePageTransformPath = (modulePath) => {
|
|
722
735
|
const cached = pageTransformCanonicalPaths.get(modulePath);
|
|
@@ -801,11 +814,32 @@ function vinext(options = {}) {
|
|
|
801
814
|
if (!pluginApi || pluginApi.manager.isScanBuild) return true;
|
|
802
815
|
return Object.keys(pluginApi.manager.serverReferenceMetaMap).length > 0;
|
|
803
816
|
}
|
|
804
|
-
const
|
|
817
|
+
const configuredReactOptions = options.react && options.react !== true ? options.react : void 0;
|
|
818
|
+
const reactOptions = configuredReactOptions;
|
|
805
819
|
let reactPluginPromise = null;
|
|
806
820
|
if (options.react !== false) {
|
|
807
821
|
if (!resolvedReactPath) throw new Error("vinext: @vitejs/plugin-react is not installed.\nRun: " + detectPackageManager(process.cwd()) + " @vitejs/plugin-react");
|
|
808
|
-
reactPluginPromise = import(pathToFileURL(resolvedReactPath).href).then((mod) =>
|
|
822
|
+
reactPluginPromise = import(pathToFileURL(resolvedReactPath).href).then((mod) => {
|
|
823
|
+
const react = mod.default;
|
|
824
|
+
const limitToCommand = (plugin, command) => {
|
|
825
|
+
const originalApply = plugin.apply;
|
|
826
|
+
return {
|
|
827
|
+
...plugin,
|
|
828
|
+
apply(config, env) {
|
|
829
|
+
if (env.command !== command) return false;
|
|
830
|
+
if (!originalApply) return true;
|
|
831
|
+
if (typeof originalApply === "function") return originalApply(config, env);
|
|
832
|
+
return originalApply === env.command;
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
};
|
|
836
|
+
const buildPlugins = react(reactOptions).map((plugin) => limitToCommand(plugin, "build"));
|
|
837
|
+
const servePlugins = react(configuredReactOptions !== void 0 && Object.prototype.hasOwnProperty.call(configuredReactOptions, "include") ? reactOptions : {
|
|
838
|
+
...reactOptions,
|
|
839
|
+
include: /\.(?:[tj]sx?|mdx)$/i
|
|
840
|
+
}).map((plugin) => limitToCommand(plugin, "serve"));
|
|
841
|
+
return [...buildPlugins, ...servePlugins];
|
|
842
|
+
}).catch((cause) => {
|
|
809
843
|
throw new Error("vinext: Failed to load @vitejs/plugin-react.", { cause });
|
|
810
844
|
});
|
|
811
845
|
}
|
|
@@ -845,8 +879,36 @@ function vinext(options = {}) {
|
|
|
845
879
|
})();
|
|
846
880
|
return mdxDelegatePromise;
|
|
847
881
|
}
|
|
882
|
+
const mdxProxyPlugin = {
|
|
883
|
+
name: "vinext:mdx",
|
|
884
|
+
enforce: "pre",
|
|
885
|
+
transform: {
|
|
886
|
+
filter: { id: {
|
|
887
|
+
include: /\.mdx$/i,
|
|
888
|
+
exclude: /\?/
|
|
889
|
+
} },
|
|
890
|
+
async handler(code, id, options) {
|
|
891
|
+
const delegate = mdxDelegate ?? await ensureMdxDelegate("on-demand");
|
|
892
|
+
if (delegate?.transform) {
|
|
893
|
+
const hook = delegate.transform;
|
|
894
|
+
return (typeof hook === "function" ? hook : hook.handler).call(this, code, id, options);
|
|
895
|
+
}
|
|
896
|
+
if (!hasUserMdxPlugin) throw new Error(`[vinext] Encountered MDX module ${id} but no MDX plugin is configured. Install @mdx-js/rollup or register an MDX plugin manually.`);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
const mdxConfigProxyPlugin = {
|
|
901
|
+
name: "vinext:mdx-config",
|
|
902
|
+
enforce: "pre",
|
|
903
|
+
config(config, env) {
|
|
904
|
+
if (!mdxDelegate?.config) return;
|
|
905
|
+
const hook = mdxDelegate.config;
|
|
906
|
+
return (typeof hook === "function" ? hook : hook.handler).call(this, config, env);
|
|
907
|
+
}
|
|
908
|
+
};
|
|
848
909
|
const plugins = [
|
|
849
910
|
createStyledJsxPlugin(earlyBaseDir),
|
|
911
|
+
mdxProxyPlugin,
|
|
850
912
|
reactPluginPromise,
|
|
851
913
|
createIgnoreDynamicRequestsPlugin(() => nextConfig?.turbopackTranspilePackages ?? []),
|
|
852
914
|
commonjs({ filter: skipCommonjsForLocalCjs }),
|
|
@@ -860,7 +922,7 @@ function vinext(options = {}) {
|
|
|
860
922
|
code: /\.(?:css|scss|sass)['"]/
|
|
861
923
|
},
|
|
862
924
|
handler(code, id) {
|
|
863
|
-
const cleanId =
|
|
925
|
+
const cleanId = toSlash(stripViteModuleQuery(id));
|
|
864
926
|
if (!globalNotFoundCssIsolationPath || canonicalize(cleanId) !== canonicalize(globalNotFoundCssIsolationPath)) return null;
|
|
865
927
|
return isolateGlobalNotFoundStylesheetImports(code, cleanId);
|
|
866
928
|
}
|
|
@@ -905,6 +967,7 @@ function vinext(options = {}) {
|
|
|
905
967
|
name: "vinext:config",
|
|
906
968
|
enforce: "pre",
|
|
907
969
|
[VINEXT_PRERENDER_CONFIG_PLUGIN_PROPERTY]: prerenderConfig,
|
|
970
|
+
[VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY]: options.nextConfig ?? null,
|
|
908
971
|
[VINEXT_ROUTE_ROOT_CONFIG_PLUGIN_PROPERTY]: {
|
|
909
972
|
appDir: options.appDir,
|
|
910
973
|
disableAppRouter: options.disableAppRouter,
|
|
@@ -914,7 +977,7 @@ function vinext(options = {}) {
|
|
|
914
977
|
[VINEXT_CACHE_CONFIG_PLUGIN_PROPERTY]: options.cache ?? null,
|
|
915
978
|
async config(config, env) {
|
|
916
979
|
isServeCommand = env.command === "serve";
|
|
917
|
-
root =
|
|
980
|
+
root = toSlash(config.root ?? process.cwd());
|
|
918
981
|
const shouldEnableNativeTsconfigPaths = config.resolve?.tsconfigPaths === void 0;
|
|
919
982
|
const tsconfigPathAliases = resolveTsconfigAliases(root);
|
|
920
983
|
const swcHelpersAlias = resolveSwcHelpersAlias(root);
|
|
@@ -927,20 +990,22 @@ function vinext(options = {}) {
|
|
|
927
990
|
else if (env?.command === "build" || env?.isPreview === true) resolvedNodeEnv = "production";
|
|
928
991
|
else resolvedNodeEnv = "development";
|
|
929
992
|
if (process.env.NODE_ENV !== resolvedNodeEnv) process.env.NODE_ENV = resolvedNodeEnv;
|
|
993
|
+
if (env?.command === "build") previewBuildCredentials = getPreviewBuildCredentials() ?? createPreviewBuildCredentials();
|
|
994
|
+
draftModeSecret = previewBuildCredentials?.id ?? getPagesPreviewModeId();
|
|
930
995
|
let baseDir;
|
|
931
|
-
if (options.appDir) baseDir =
|
|
996
|
+
if (options.appDir) baseDir = toSlash(path.isAbsolute(options.appDir) ? options.appDir : path.resolve(root, options.appDir));
|
|
932
997
|
else {
|
|
933
|
-
const hasRootApp = fs.existsSync(path.
|
|
934
|
-
const hasRootPages = fs.existsSync(path.
|
|
935
|
-
const hasSrcApp = fs.existsSync(path.
|
|
936
|
-
const hasSrcPages = fs.existsSync(path.
|
|
998
|
+
const hasRootApp = fs.existsSync(path.join(root, "app"));
|
|
999
|
+
const hasRootPages = fs.existsSync(path.join(root, "pages"));
|
|
1000
|
+
const hasSrcApp = fs.existsSync(path.join(root, "src", "app"));
|
|
1001
|
+
const hasSrcPages = fs.existsSync(path.join(root, "src", "pages"));
|
|
937
1002
|
if (hasRootApp || hasRootPages) baseDir = root;
|
|
938
|
-
else if (hasSrcApp || hasSrcPages) baseDir = path.
|
|
1003
|
+
else if (hasSrcApp || hasSrcPages) baseDir = path.join(root, "src");
|
|
939
1004
|
else baseDir = root;
|
|
940
1005
|
}
|
|
941
|
-
pagesDir = path.
|
|
1006
|
+
pagesDir = path.join(baseDir, "pages");
|
|
942
1007
|
canonicalPagesDir = canonicalize(pagesDir);
|
|
943
|
-
appDir = path.
|
|
1008
|
+
appDir = path.join(baseDir, "app");
|
|
944
1009
|
hasPagesDir = fs.existsSync(pagesDir);
|
|
945
1010
|
hasAppDir = !options.disableAppRouter && fs.existsSync(appDir);
|
|
946
1011
|
if (!nextConfig) {
|
|
@@ -969,7 +1034,7 @@ function vinext(options = {}) {
|
|
|
969
1034
|
globalNotFoundCssIsolationPath = env?.command === "build" && nextConfig.globalNotFound ? findFileWithExts(appDir, "global-not-found", fileMatcher) : null;
|
|
970
1035
|
instrumentationPath = findInstrumentationFile(root, fileMatcher);
|
|
971
1036
|
instrumentationClientPath = findInstrumentationClientFile(root, fileMatcher);
|
|
972
|
-
const middlewareConventionDir = canonicalize(baseDir) === canonicalize(path.
|
|
1037
|
+
const middlewareConventionDir = canonicalize(baseDir) === canonicalize(path.join(root, "src")) ? path.join(root, "src") : root;
|
|
973
1038
|
middlewarePath = findMiddlewareFile(root, fileMatcher, middlewareConventionDir);
|
|
974
1039
|
const instrumentationClientInjects = nextConfig.instrumentationClientInject.map((spec) => spec.startsWith("./") || spec.startsWith("../") ? path.resolve(root, spec) : spec);
|
|
975
1040
|
clientInjectModule = instrumentationClientInjects.length ? generateInstrumentationClientInjectModule(instrumentationClientInjects, instrumentationClientPath, INSTRUMENTATION_CLIENT_EMPTY_MODULE) : null;
|
|
@@ -1036,55 +1101,55 @@ function vinext(options = {}) {
|
|
|
1036
1101
|
}
|
|
1037
1102
|
for (const key of Object.keys(nextConfig.compilerDefineServer)) if (key in defines) throw new Error(`The \`compiler.defineServer\` option is configured to replace the \`${key}\` variable. This variable is either part of a built-in or is already configured.`);
|
|
1038
1103
|
nextShimMap = Object.fromEntries(Object.entries({
|
|
1039
|
-
"next/link": path.
|
|
1040
|
-
"next/head": path.
|
|
1041
|
-
"next/router": path.
|
|
1042
|
-
"next/compat/router": path.
|
|
1043
|
-
"next/image": path.
|
|
1044
|
-
"next/legacy/image": path.
|
|
1045
|
-
"next/dynamic": path.
|
|
1046
|
-
"next/app": path.
|
|
1047
|
-
"next/document": path.
|
|
1048
|
-
"next/config": path.
|
|
1049
|
-
"next/script": path.
|
|
1050
|
-
"next/server": path.
|
|
1051
|
-
"next/headers": path.
|
|
1052
|
-
"next/font/google": path.
|
|
1053
|
-
"next/font/local": path.
|
|
1054
|
-
"next/cache": path.
|
|
1055
|
-
"next/form": path.
|
|
1056
|
-
"next/og": path.
|
|
1057
|
-
"next/web-vitals": path.
|
|
1058
|
-
"next/amp": path.
|
|
1059
|
-
"next/offline": path.
|
|
1060
|
-
"next/constants": path.
|
|
1061
|
-
"next/dist/shared/lib/app-router-context.shared-runtime": path.
|
|
1062
|
-
"next/dist/shared/lib/app-router-context": path.
|
|
1063
|
-
"next/dist/shared/lib/router-context.shared-runtime": path.
|
|
1064
|
-
"next/dist/shared/lib/utils": path.
|
|
1065
|
-
"next/dist/server/api-utils": path.
|
|
1066
|
-
"next/dist/server/web/spec-extension/cookies": path.
|
|
1067
|
-
"next/dist/compiled/@edge-runtime/cookies": path.
|
|
1068
|
-
"next/dist/server/app-render/work-unit-async-storage.external": path.
|
|
1069
|
-
"next/dist/client/components/work-unit-async-storage.external": path.
|
|
1070
|
-
"next/dist/client/components/request-async-storage.external": path.
|
|
1071
|
-
"next/dist/client/components/request-async-storage": path.
|
|
1072
|
-
"next/dist/server/request/root-params": path.
|
|
1073
|
-
"next/dist/server/config-shared": path.
|
|
1074
|
-
"server-only": path.
|
|
1075
|
-
"client-only": path.
|
|
1076
|
-
"vinext/error-boundary": path.
|
|
1077
|
-
"vinext/layout-segment-context": path.
|
|
1078
|
-
"vinext/metadata": path.
|
|
1079
|
-
"vinext/fetch-cache": path.
|
|
1080
|
-
"vinext/cache-runtime": path.
|
|
1081
|
-
"vinext/navigation-state": path.
|
|
1082
|
-
"vinext/unified-request-context": path.
|
|
1083
|
-
"vinext/pages-router-runtime": path.
|
|
1084
|
-
"vinext/router-state": path.
|
|
1085
|
-
"vinext/head-state": path.
|
|
1086
|
-
"vinext/i18n-state": path.
|
|
1087
|
-
"vinext/i18n-context": path.
|
|
1104
|
+
"next/link": path.join(shimsDir, "link"),
|
|
1105
|
+
"next/head": path.join(shimsDir, "head"),
|
|
1106
|
+
"next/router": path.join(shimsDir, "router"),
|
|
1107
|
+
"next/compat/router": path.join(shimsDir, "compat-router"),
|
|
1108
|
+
"next/image": path.join(shimsDir, "image"),
|
|
1109
|
+
"next/legacy/image": path.join(shimsDir, "legacy-image"),
|
|
1110
|
+
"next/dynamic": path.join(shimsDir, "dynamic"),
|
|
1111
|
+
"next/app": path.join(shimsDir, "app"),
|
|
1112
|
+
"next/document": path.join(shimsDir, "document"),
|
|
1113
|
+
"next/config": path.join(shimsDir, "config"),
|
|
1114
|
+
"next/script": path.join(shimsDir, "script"),
|
|
1115
|
+
"next/server": path.join(shimsDir, "server"),
|
|
1116
|
+
"next/headers": path.join(shimsDir, "headers"),
|
|
1117
|
+
"next/font/google": path.join(shimsDir, "font-google"),
|
|
1118
|
+
"next/font/local": path.join(shimsDir, "font-local"),
|
|
1119
|
+
"next/cache": path.join(shimsDir, "cache"),
|
|
1120
|
+
"next/form": path.join(shimsDir, "form"),
|
|
1121
|
+
"next/og": path.join(shimsDir, "og"),
|
|
1122
|
+
"next/web-vitals": path.join(shimsDir, "web-vitals"),
|
|
1123
|
+
"next/amp": path.join(shimsDir, "amp"),
|
|
1124
|
+
"next/offline": path.join(shimsDir, "offline"),
|
|
1125
|
+
"next/constants": path.join(shimsDir, "constants"),
|
|
1126
|
+
"next/dist/shared/lib/app-router-context.shared-runtime": path.join(shimsDir, "internal", "app-router-context"),
|
|
1127
|
+
"next/dist/shared/lib/app-router-context": path.join(shimsDir, "internal", "app-router-context"),
|
|
1128
|
+
"next/dist/shared/lib/router-context.shared-runtime": path.join(shimsDir, "internal", "router-context"),
|
|
1129
|
+
"next/dist/shared/lib/utils": path.join(shimsDir, "internal", "utils"),
|
|
1130
|
+
"next/dist/server/api-utils": path.join(shimsDir, "internal", "api-utils"),
|
|
1131
|
+
"next/dist/server/web/spec-extension/cookies": path.join(shimsDir, "internal", "cookies"),
|
|
1132
|
+
"next/dist/compiled/@edge-runtime/cookies": path.join(shimsDir, "internal", "cookies"),
|
|
1133
|
+
"next/dist/server/app-render/work-unit-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
1134
|
+
"next/dist/client/components/work-unit-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
1135
|
+
"next/dist/client/components/request-async-storage.external": path.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
1136
|
+
"next/dist/client/components/request-async-storage": path.join(shimsDir, "internal", "work-unit-async-storage"),
|
|
1137
|
+
"next/dist/server/request/root-params": path.join(shimsDir, "root-params"),
|
|
1138
|
+
"next/dist/server/config-shared": path.join(shimsDir, "internal", "utils"),
|
|
1139
|
+
"server-only": path.join(shimsDir, "server-only"),
|
|
1140
|
+
"client-only": path.join(shimsDir, "client-only"),
|
|
1141
|
+
"vinext/error-boundary": path.join(shimsDir, "error-boundary"),
|
|
1142
|
+
"vinext/layout-segment-context": path.join(shimsDir, "layout-segment-context"),
|
|
1143
|
+
"vinext/metadata": path.join(shimsDir, "metadata"),
|
|
1144
|
+
"vinext/fetch-cache": path.join(shimsDir, "fetch-cache"),
|
|
1145
|
+
"vinext/cache-runtime": path.join(shimsDir, "cache-runtime"),
|
|
1146
|
+
"vinext/navigation-state": path.join(shimsDir, "navigation-state"),
|
|
1147
|
+
"vinext/unified-request-context": path.join(shimsDir, "unified-request-context"),
|
|
1148
|
+
"vinext/pages-router-runtime": path.join(shimsDir, "pages-router-runtime"),
|
|
1149
|
+
"vinext/router-state": path.join(shimsDir, "router-state"),
|
|
1150
|
+
"vinext/head-state": path.join(shimsDir, "head-state"),
|
|
1151
|
+
"vinext/i18n-state": path.join(shimsDir, "i18n-state"),
|
|
1152
|
+
"vinext/i18n-context": path.join(shimsDir, "i18n-context"),
|
|
1088
1153
|
"vinext/cache": path.resolve(__dirname, "cache"),
|
|
1089
1154
|
"vinext/instrumentation": path.resolve(__dirname, "server", "instrumentation"),
|
|
1090
1155
|
"vinext/instrumentation-client": path.resolve(__dirname, "client", "instrumentation-client"),
|
|
@@ -1108,6 +1173,7 @@ function vinext(options = {}) {
|
|
|
1108
1173
|
const isSSR = !!config.build?.ssr;
|
|
1109
1174
|
const serverTranspilePackages = [...nextConfig?.turbopackTranspilePackages ?? [], ...nextConfig?.optimizePackageImports ?? []];
|
|
1110
1175
|
const nextServerExternal = mergeServerExternalPackages(nextConfig?.serverExternalPackages, serverTranspilePackages);
|
|
1176
|
+
nitroTraceDepsFromServerExternals = nextServerExternal;
|
|
1111
1177
|
const isMultiEnv = hasAppDir || hasCloudflarePlugin || hasNitroPlugin;
|
|
1112
1178
|
const hasBuildInput = getBuildBundlerOptions(config.build)?.input !== void 0;
|
|
1113
1179
|
const shouldInjectPlainPagesEnvironments = !hasAppDir && !hasCloudflarePlugin && !isSSR && !hasBuildInput;
|
|
@@ -1245,7 +1311,7 @@ function vinext(options = {}) {
|
|
|
1245
1311
|
if (hasAppDir) {
|
|
1246
1312
|
const appEntries = [`${path.relative(root, appDir)}/**/*.{tsx,ts,jsx,js}`];
|
|
1247
1313
|
const explicitInstrumentationEntries = [instrumentationPath, instrumentationClientPath].flatMap((entry) => entry ? [toRelativeFileEntry(root, entry)] : []);
|
|
1248
|
-
const optimizeEntries = [
|
|
1314
|
+
const optimizeEntries = [.../* @__PURE__ */ new Set([...appEntries, ...explicitInstrumentationEntries])];
|
|
1249
1315
|
const appClientInput = { index: VIRTUAL_APP_BROWSER_ENTRY };
|
|
1250
1316
|
if (hasPagesDir) appClientInput["vinext-client-entry"] = VIRTUAL_CLIENT_ENTRY;
|
|
1251
1317
|
viteConfig.environments = {
|
|
@@ -1263,7 +1329,7 @@ function vinext(options = {}) {
|
|
|
1263
1329
|
optimizeDeps: {
|
|
1264
1330
|
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE),
|
|
1265
1331
|
entries: optimizeEntries,
|
|
1266
|
-
include: [
|
|
1332
|
+
include: [.../* @__PURE__ */ new Set([...incomingInclude, "react-server-dom-webpack/static.edge"])],
|
|
1267
1333
|
...depOptimizeNodeEnvOptions
|
|
1268
1334
|
},
|
|
1269
1335
|
build: {
|
|
@@ -1298,7 +1364,7 @@ function vinext(options = {}) {
|
|
|
1298
1364
|
optimizeDeps: {
|
|
1299
1365
|
exclude: mergeOptimizeDepsExclude(incomingExclude, VINEXT_OPTIMIZE_DEPS_EXCLUDE, nextServerExternal),
|
|
1300
1366
|
entries: optimizeEntries,
|
|
1301
|
-
include: [
|
|
1367
|
+
include: [.../* @__PURE__ */ new Set([
|
|
1302
1368
|
...incomingInclude,
|
|
1303
1369
|
"react",
|
|
1304
1370
|
"react-dom",
|
|
@@ -1400,8 +1466,6 @@ function vinext(options = {}) {
|
|
|
1400
1466
|
return null;
|
|
1401
1467
|
},
|
|
1402
1468
|
async configResolved(config) {
|
|
1403
|
-
const cacheDirPrefix = getCacheDirPrefix(config.cacheDir);
|
|
1404
|
-
typeofWindowIdFilter.exclude = new RegExp(`^${escapeRegExp(cacheDirPrefix)}`);
|
|
1405
1469
|
if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir) suppressOptionalOptimizeDepsWarnings(config.logger);
|
|
1406
1470
|
sassComposesLoader.setResolvedConfig(config);
|
|
1407
1471
|
if (config.command === "build" && hasAppDir && hasPagesDir) {
|
|
@@ -1441,7 +1505,7 @@ function vinext(options = {}) {
|
|
|
1441
1505
|
resolveId: {
|
|
1442
1506
|
filter: { id: /(?:next\/|vinext\/(?:shims\/|server\/app-rsc-handler)|virtual:vinext-|@vercel\/og(?:\.js)?$)/ },
|
|
1443
1507
|
handler(id, importer) {
|
|
1444
|
-
const cleanId =
|
|
1508
|
+
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
1445
1509
|
if (cleanId === "vinext/server/app-rsc-handler") {
|
|
1446
1510
|
if (_canExternalizeAppRscHandler && this.environment?.name === "rsc" && this.environment.config?.command === "serve") return {
|
|
1447
1511
|
id: _appRscHandlerPath,
|
|
@@ -1473,7 +1537,10 @@ function vinext(options = {}) {
|
|
|
1473
1537
|
return RESOLVED_VIRTUAL_GOOGLE_FONTS + cleanId.slice(queryIndex + VIRTUAL_GOOGLE_FONTS.length);
|
|
1474
1538
|
}
|
|
1475
1539
|
const reactServerShim = _reactServerShims.get(cleanId);
|
|
1476
|
-
if (reactServerShim !== void 0)
|
|
1540
|
+
if (reactServerShim !== void 0) {
|
|
1541
|
+
const shimName = this.environment?.name === "rsc" ? `${reactServerShim}.react-server` : reactServerShim;
|
|
1542
|
+
return resolveShimModulePath(_shimsDir, shimName);
|
|
1543
|
+
}
|
|
1477
1544
|
}
|
|
1478
1545
|
},
|
|
1479
1546
|
load: {
|
|
@@ -1488,9 +1555,10 @@ function vinext(options = {}) {
|
|
|
1488
1555
|
const appFilePath = findFileWithExts(pagesDir, "_app", fileMatcher);
|
|
1489
1556
|
const pagesRoutes = await pagesRouter(pagesDir, nextConfig?.pageExtensions, fileMatcher);
|
|
1490
1557
|
const moduleFilePaths = [...appFilePath ? [appFilePath] : [], ...pagesRoutes.map((route) => route.filePath)];
|
|
1558
|
+
const getModuleDependencies = createDevPagesModuleDependencyReader(root, this.resolve.bind(this));
|
|
1491
1559
|
for (const moduleFilePath of moduleFilePaths) {
|
|
1492
|
-
const stylesheetAssets = await collectDevPagesAppStylesheetAssets(
|
|
1493
|
-
if (stylesheetAssets.length > 0) ssrManifest[
|
|
1560
|
+
const stylesheetAssets = await collectDevPagesAppStylesheetAssets(moduleFilePath, getModuleDependencies);
|
|
1561
|
+
if (stylesheetAssets.length > 0) ssrManifest[toSlash(moduleFilePath)] = stylesheetAssets;
|
|
1494
1562
|
}
|
|
1495
1563
|
if (Object.keys(ssrManifest).length > 0) metadata.ssrManifest = ssrManifest;
|
|
1496
1564
|
return `export default ${JSON.stringify(metadata)};`;
|
|
@@ -1606,13 +1674,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1606
1674
|
resolveId: {
|
|
1607
1675
|
filter: { id: /virtual:vinext-pages-client-assets$/ },
|
|
1608
1676
|
handler(id) {
|
|
1609
|
-
const cleanId =
|
|
1677
|
+
const cleanId = toSlash(id.startsWith("\0") ? id.slice(1) : id);
|
|
1610
1678
|
if (cleanId !== VIRTUAL_PAGES_CLIENT_ASSETS && !cleanId.endsWith("/virtual:vinext-pages-client-assets")) return;
|
|
1611
1679
|
if (this.environment?.config.command !== "build") return RESOLVED_PAGES_CLIENT_ASSETS;
|
|
1612
1680
|
const buildRoot = this.environment.config.root ?? process.cwd();
|
|
1613
1681
|
const environmentOutDir = path.resolve(buildRoot, this.environment.config.build.outDir);
|
|
1614
1682
|
const sidecarDir = !hasAppDir && this.environment.name === "ssr" ? path.dirname(environmentOutDir) : environmentOutDir;
|
|
1615
|
-
let externalId =
|
|
1683
|
+
let externalId = path.relative(environmentOutDir, path.join(sidecarDir, PAGES_CLIENT_ASSETS_MODULE));
|
|
1616
1684
|
if (!externalId.startsWith(".")) externalId = `./${externalId}`;
|
|
1617
1685
|
pagesClientAssetsOutputDirs.add(sidecarDir);
|
|
1618
1686
|
return {
|
|
@@ -1715,29 +1783,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1715
1783
|
}
|
|
1716
1784
|
},
|
|
1717
1785
|
...options.experimental?.clientReferenceDedup ? [clientReferenceDedupPlugin()] : [],
|
|
1718
|
-
|
|
1719
|
-
name: "vinext:mdx",
|
|
1720
|
-
enforce: "pre",
|
|
1721
|
-
config(config, env) {
|
|
1722
|
-
if (!mdxDelegate?.config) return;
|
|
1723
|
-
const hook = mdxDelegate.config;
|
|
1724
|
-
return (typeof hook === "function" ? hook : hook.handler).call(this, config, env);
|
|
1725
|
-
},
|
|
1726
|
-
transform: {
|
|
1727
|
-
filter: { id: {
|
|
1728
|
-
include: /\.mdx$/i,
|
|
1729
|
-
exclude: /\?/
|
|
1730
|
-
} },
|
|
1731
|
-
async handler(code, id, options) {
|
|
1732
|
-
const delegate = mdxDelegate ?? await ensureMdxDelegate("on-demand");
|
|
1733
|
-
if (delegate?.transform) {
|
|
1734
|
-
const hook = delegate.transform;
|
|
1735
|
-
return (typeof hook === "function" ? hook : hook.handler).call(this, code, id, options);
|
|
1736
|
-
}
|
|
1737
|
-
if (!hasUserMdxPlugin) throw new Error(`[vinext] Encountered MDX module ${id} but no MDX plugin is configured. Install @mdx-js/rollup or register an MDX plugin manually.`);
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
},
|
|
1786
|
+
mdxConfigProxyPlugin,
|
|
1741
1787
|
createCssModuleImportCompatibilityPlugin({ compiledMdx: true }),
|
|
1742
1788
|
{
|
|
1743
1789
|
name: "vinext:react-canary",
|
|
@@ -1778,36 +1824,35 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1778
1824
|
},
|
|
1779
1825
|
{
|
|
1780
1826
|
name: "vinext:pages-router",
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
const
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
return [];
|
|
1827
|
+
// @vitejs/plugin-react to handle normal module updates. Next.js preserves
|
|
1828
|
+
hotUpdate: {
|
|
1829
|
+
order: "post",
|
|
1830
|
+
handler(options) {
|
|
1831
|
+
if (!hasPagesDir) return;
|
|
1832
|
+
const isPagesAppFile = (filePath) => {
|
|
1833
|
+
const relativePath = path.relative(pagesDir, filePath);
|
|
1834
|
+
return !relativePath.includes("/") && relativePath.startsWith("_app.") && fileMatcher.extensionRegex.test(filePath);
|
|
1835
|
+
};
|
|
1836
|
+
const isPotentialPagesAssetGraphScript = (filePath) => {
|
|
1837
|
+
const cleanPath = stripViteModuleQuery(filePath);
|
|
1838
|
+
if (!path.isAbsolute(cleanPath)) return false;
|
|
1839
|
+
if (!isScriptModuleId(cleanPath) || cleanPath.endsWith(".d.ts")) return false;
|
|
1840
|
+
const relativeRootPath = path.relative(root, cleanPath);
|
|
1841
|
+
if (relativeRootPath.startsWith("..") || path.isAbsolute(relativeRootPath)) return false;
|
|
1842
|
+
if (relativeRootPath.includes("/node_modules/") || relativeRootPath.startsWith("node_modules/")) return false;
|
|
1843
|
+
const relativeAppPath = path.relative(appDir, cleanPath);
|
|
1844
|
+
return relativeAppPath.startsWith("..") || path.isAbsolute(relativeAppPath);
|
|
1845
|
+
};
|
|
1846
|
+
const pagesAppChanged = isPagesAppFile(options.file);
|
|
1847
|
+
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(options.file);
|
|
1848
|
+
if (pagesAppChanged || STYLESHEET_FILE_RE.test(options.file) || pagesAssetGraphScriptChanged) for (const env of Object.values(options.server.environments)) {
|
|
1849
|
+
const mod = env.moduleGraph.getModuleById(RESOLVED_PAGES_CLIENT_ASSETS);
|
|
1850
|
+
if (mod) env.moduleGraph.invalidateModule(mod);
|
|
1851
|
+
}
|
|
1852
|
+
if (this.environment?.name === "ssr" && pagesAssetGraphScriptChanged) {
|
|
1853
|
+
for (const mod of options.modules) this.environment.moduleGraph.invalidateModule(mod, /* @__PURE__ */ new Set(), options.timestamp, true);
|
|
1854
|
+
return [];
|
|
1855
|
+
}
|
|
1811
1856
|
}
|
|
1812
1857
|
},
|
|
1813
1858
|
configureServer(server) {
|
|
@@ -1857,13 +1902,12 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1857
1902
|
}
|
|
1858
1903
|
pagesRunner?.clearCache();
|
|
1859
1904
|
}
|
|
1860
|
-
function invalidatePagesClientAssetsModule(
|
|
1905
|
+
function invalidatePagesClientAssetsModule() {
|
|
1861
1906
|
for (const env of Object.values(server.environments)) {
|
|
1862
1907
|
const mod = env.moduleGraph.getModuleById(RESOLVED_PAGES_CLIENT_ASSETS);
|
|
1863
1908
|
if (mod) env.moduleGraph.invalidateModule(mod);
|
|
1864
1909
|
}
|
|
1865
1910
|
pagesRunner?.clearCache();
|
|
1866
|
-
if (reloadDocument) server.ws.send({ type: "full-reload" });
|
|
1867
1911
|
}
|
|
1868
1912
|
function invalidateAppRoutingModules() {
|
|
1869
1913
|
invalidateAppRouteCache();
|
|
@@ -1913,17 +1957,17 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1913
1957
|
let appRouteTypeGeneration = null;
|
|
1914
1958
|
let appRouteTypeGenerationPending = false;
|
|
1915
1959
|
function isPagesAppFile(filePath) {
|
|
1916
|
-
const relativePath =
|
|
1960
|
+
const relativePath = path.relative(pagesDir, filePath);
|
|
1917
1961
|
return !relativePath.includes("/") && relativePath.startsWith("_app.") && fileMatcher.extensionRegex.test(filePath);
|
|
1918
1962
|
}
|
|
1919
1963
|
function isPotentialPagesAssetGraphScript(filePath) {
|
|
1920
1964
|
const cleanPath = stripViteModuleQuery(filePath);
|
|
1921
1965
|
if (!path.isAbsolute(cleanPath)) return false;
|
|
1922
1966
|
if (!isScriptModuleId(cleanPath) || cleanPath.endsWith(".d.ts")) return false;
|
|
1923
|
-
const relativeRootPath =
|
|
1967
|
+
const relativeRootPath = path.relative(root, cleanPath);
|
|
1924
1968
|
if (relativeRootPath.startsWith("..") || path.isAbsolute(relativeRootPath)) return false;
|
|
1925
1969
|
if (relativeRootPath.includes("/node_modules/") || relativeRootPath.startsWith("node_modules/")) return false;
|
|
1926
|
-
const relativeAppPath =
|
|
1970
|
+
const relativeAppPath = path.relative(appDir, cleanPath);
|
|
1927
1971
|
return relativeAppPath.startsWith("..") || path.isAbsolute(relativeAppPath);
|
|
1928
1972
|
}
|
|
1929
1973
|
function warnRouteTypeGenerationFailure(error) {
|
|
@@ -1956,8 +2000,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1956
2000
|
let routeChanged = false;
|
|
1957
2001
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
1958
2002
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
1959
|
-
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule(
|
|
1960
|
-
if (hasPagesDir && filePath.startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2003
|
+
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2004
|
+
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
1961
2005
|
invalidateRouteCache(pagesDir);
|
|
1962
2006
|
routeChanged = true;
|
|
1963
2007
|
}
|
|
@@ -1968,6 +2012,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1968
2012
|
}
|
|
1969
2013
|
if (routeChanged) {
|
|
1970
2014
|
invalidatePagesServerEntry();
|
|
2015
|
+
if (!hasAppDir) server.ws.send({ type: "full-reload" });
|
|
1971
2016
|
invalidateHybridClientEntries();
|
|
1972
2017
|
revalidateHybridRoutes();
|
|
1973
2018
|
}
|
|
@@ -1975,14 +2020,14 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1975
2020
|
server.watcher.on("change", (filePath) => {
|
|
1976
2021
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
1977
2022
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
1978
|
-
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule(
|
|
2023
|
+
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
1979
2024
|
});
|
|
1980
2025
|
server.watcher.on("unlink", (filePath) => {
|
|
1981
2026
|
let routeChanged = false;
|
|
1982
2027
|
const pagesAppChanged = isPagesAppFile(filePath);
|
|
1983
2028
|
const pagesAssetGraphScriptChanged = isPotentialPagesAssetGraphScript(filePath);
|
|
1984
|
-
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule(
|
|
1985
|
-
if (hasPagesDir && filePath.startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
2029
|
+
if (hasPagesDir && (pagesAppChanged || STYLESHEET_FILE_RE.test(filePath) || pagesAssetGraphScriptChanged)) invalidatePagesClientAssetsModule();
|
|
2030
|
+
if (hasPagesDir && toSlash(filePath).startsWith(pagesDir) && pageExtensions.test(filePath)) {
|
|
1986
2031
|
invalidateRouteCache(pagesDir);
|
|
1987
2032
|
routeChanged = true;
|
|
1988
2033
|
}
|
|
@@ -1993,6 +2038,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
1993
2038
|
}
|
|
1994
2039
|
if (routeChanged) {
|
|
1995
2040
|
invalidatePagesServerEntry();
|
|
2041
|
+
if (!hasAppDir) server.ws.send({ type: "full-reload" });
|
|
1996
2042
|
invalidateHybridClientEntries();
|
|
1997
2043
|
revalidateHybridRoutes();
|
|
1998
2044
|
}
|
|
@@ -2474,15 +2520,23 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2474
2520
|
},
|
|
2475
2521
|
{
|
|
2476
2522
|
name: "vinext:typeof-window",
|
|
2523
|
+
configEnvironment(_name, environment) {
|
|
2524
|
+
if (!useNativeTypeofWindowFolding) return null;
|
|
2525
|
+
return { define: { "typeof window": environment.consumer === "client" ? "\"object\"" : "\"undefined\"" } };
|
|
2526
|
+
}
|
|
2527
|
+
},
|
|
2528
|
+
{
|
|
2529
|
+
name: "vinext:typeof-window-scan",
|
|
2530
|
+
apply(_config, environment) {
|
|
2531
|
+
return !useNativeTypeofWindowFolding || environment.command === "build";
|
|
2532
|
+
},
|
|
2477
2533
|
enforce: "post",
|
|
2478
2534
|
transform: {
|
|
2479
|
-
filter: {
|
|
2480
|
-
id: typeofWindowIdFilter,
|
|
2481
|
-
code: /typeof\s+window/
|
|
2482
|
-
},
|
|
2535
|
+
filter: { code: /\btypeof\s+window\b/ },
|
|
2483
2536
|
handler(code, id) {
|
|
2484
|
-
|
|
2485
|
-
|
|
2537
|
+
if (useNativeTypeofWindowFolding && this.environment.config.build.write !== false) return null;
|
|
2538
|
+
const cacheDir = `${toSlash(this.environment.config.cacheDir).replace(/\/$/, "")}/`;
|
|
2539
|
+
if (toSlash(id).startsWith(cacheDir)) return null;
|
|
2486
2540
|
return replaceTypeofWindow(code, getTypeofWindowReplacement(this.environment), id);
|
|
2487
2541
|
}
|
|
2488
2542
|
}
|
|
@@ -2495,6 +2549,11 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2495
2549
|
serverDefines["process.env.NEXT_RUNTIME"] = JSON.stringify("nodejs");
|
|
2496
2550
|
const sharedRevalidateSecret = process.env.__VINEXT_SHARED_REVALIDATE_SECRET;
|
|
2497
2551
|
if (sharedRevalidateSecret) serverDefines["process.env.__VINEXT_REVALIDATE_SECRET"] = JSON.stringify(sharedRevalidateSecret);
|
|
2552
|
+
if (previewBuildCredentials) {
|
|
2553
|
+
serverDefines["process.env.__VINEXT_PREVIEW_MODE_ID"] = JSON.stringify(previewBuildCredentials.id);
|
|
2554
|
+
serverDefines["process.env.__VINEXT_PREVIEW_MODE_SIGNING_KEY"] = JSON.stringify(previewBuildCredentials.signingKey);
|
|
2555
|
+
serverDefines["process.env.__VINEXT_PREVIEW_MODE_ENCRYPTION_KEY"] = JSON.stringify(previewBuildCredentials.encryptionKey);
|
|
2556
|
+
}
|
|
2498
2557
|
return { define: serverDefines };
|
|
2499
2558
|
}
|
|
2500
2559
|
},
|
|
@@ -2519,7 +2578,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2519
2578
|
staticImageAssets.clear();
|
|
2520
2579
|
},
|
|
2521
2580
|
watchChange(id) {
|
|
2522
|
-
const key =
|
|
2581
|
+
const key = toSlash(id);
|
|
2523
2582
|
imageImportDimCache.delete(key);
|
|
2524
2583
|
staticImageAssets.delete(key);
|
|
2525
2584
|
staticImageImportsByModule.delete(key);
|
|
@@ -2597,7 +2656,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2597
2656
|
const dir = path.dirname(id);
|
|
2598
2657
|
const resolvedImage = importPath.startsWith(".") ? path.resolve(dir, importPath) : (await this.resolve(importPath, id, { skipSelf: true }))?.id;
|
|
2599
2658
|
if (!resolvedImage) continue;
|
|
2600
|
-
const absImagePath =
|
|
2659
|
+
const absImagePath = toSlash(resolvedImage.split("?", 1)[0]);
|
|
2601
2660
|
if (!fs.existsSync(absImagePath)) continue;
|
|
2602
2661
|
imageImports.add(absImagePath);
|
|
2603
2662
|
const urlVar = `__vinext_img_url_${varName}`;
|
|
@@ -2800,9 +2859,10 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
|
|
|
2800
2859
|
{
|
|
2801
2860
|
name: "vinext:nitro-route-rules",
|
|
2802
2861
|
nitro: { setup: async (nitro) => {
|
|
2803
|
-
if (nitro.options.dev) return;
|
|
2804
2862
|
if (!nextConfig) return;
|
|
2805
2863
|
if (!hasAppDir && !hasPagesDir) return;
|
|
2864
|
+
if (nitroTraceDepsFromServerExternals.length > 0) nitro.options.traceDeps = [.../* @__PURE__ */ new Set([...nitro.options.traceDeps ?? [], ...nitroTraceDepsFromServerExternals])];
|
|
2865
|
+
if (nitro.options.dev) return;
|
|
2806
2866
|
const { collectNitroRouteRules, mergeNitroRouteRules } = await import("./build/nitro-route-rules.js");
|
|
2807
2867
|
const generatedRouteRules = await collectNitroRouteRules({
|
|
2808
2868
|
appDir: hasAppDir ? appDir : null,
|