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/init-cloudflare.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import path from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { detectProject } from "./utils/project.js";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import fs from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
5
|
import MagicString from "magic-string";
|
|
6
6
|
//#region src/init-cloudflare.ts
|
|
7
7
|
const require = createRequire(import.meta.url);
|
package/dist/init-platform.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isAgent } from "./
|
|
1
|
+
import { n as isAgent } from "./deps/.pnpm/am-i-vibing@0.5.0/deps/am-i-vibing/dist/detector-1yx2Hoe0.js";
|
|
2
2
|
import { createInterface } from "node:readline/promises";
|
|
3
3
|
//#region src/init-platform.ts
|
|
4
4
|
const INIT_PLATFORMS = {
|
package/dist/init.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import path from "./deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { detectPackageManager, detectPackageManagerName, detectProject, ensureESModule, findViteConfigPath, hasViteConfig, renameCJSConfigs } from "./utils/project.js";
|
|
2
3
|
import { setupCloudflarePlatform, usesCommonJsViteConfig, validateCloudflarePlatformSetup } from "./init-cloudflare.js";
|
|
3
4
|
import { getReactUpgradeDeps } from "./utils/react-version.js";
|
|
4
5
|
import fs from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
6
|
import { spawn, spawnSync } from "node:child_process";
|
|
7
7
|
//#region src/init.ts
|
|
8
8
|
/**
|
|
@@ -215,7 +215,7 @@ function updateGitignore(root, platform = "node") {
|
|
|
215
215
|
const entries = [
|
|
216
216
|
{
|
|
217
217
|
entry: "/dist/",
|
|
218
|
-
coveredBy: new Set([
|
|
218
|
+
coveredBy: /* @__PURE__ */ new Set([
|
|
219
219
|
"/dist/",
|
|
220
220
|
"/dist",
|
|
221
221
|
"dist/",
|
|
@@ -224,7 +224,7 @@ function updateGitignore(root, platform = "node") {
|
|
|
224
224
|
},
|
|
225
225
|
{
|
|
226
226
|
entry: ".vinext/",
|
|
227
|
-
coveredBy: new Set([
|
|
227
|
+
coveredBy: /* @__PURE__ */ new Set([
|
|
228
228
|
"/.vinext/",
|
|
229
229
|
"/.vinext",
|
|
230
230
|
".vinext/",
|
|
@@ -233,7 +233,7 @@ function updateGitignore(root, platform = "node") {
|
|
|
233
233
|
},
|
|
234
234
|
...platform === "cloudflare" ? [{
|
|
235
235
|
entry: ".wrangler/",
|
|
236
|
-
coveredBy: new Set([
|
|
236
|
+
coveredBy: /* @__PURE__ */ new Set([
|
|
237
237
|
"/.wrangler/",
|
|
238
238
|
"/.wrangler",
|
|
239
239
|
".wrangler/",
|
|
@@ -447,7 +447,7 @@ ${nextSteps.map((step) => ` ${step}`).join("\n")}${nextSteps.length > 0 ? "\n
|
|
|
447
447
|
${deployCommandStep} ${pmName} run dev Start Next.js (still works as before)
|
|
448
448
|
`);
|
|
449
449
|
return {
|
|
450
|
-
installedDeps: [
|
|
450
|
+
installedDeps: [.../* @__PURE__ */ new Set([...dependencyEntriesAdded, ...devDependencyEntriesAdded])],
|
|
451
451
|
addedTypeModule,
|
|
452
452
|
renamedConfigs,
|
|
453
453
|
addedScripts,
|
|
@@ -27,7 +27,7 @@ const DYNAMIC_IMPORT_PRESCAN = /\bimport\s*[(/]/;
|
|
|
27
27
|
function mayContainDynamicImport(code) {
|
|
28
28
|
return DYNAMIC_IMPORT_PRESCAN.test(code);
|
|
29
29
|
}
|
|
30
|
-
const SKIP_CHILD_KEYS = new Set([
|
|
30
|
+
const SKIP_CHILD_KEYS = /* @__PURE__ */ new Set([
|
|
31
31
|
"type",
|
|
32
32
|
"parent",
|
|
33
33
|
"loc",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { isUnknownRecord } from "../utils/record.js";
|
|
2
3
|
import { hasTrailingComma } from "../utils/has-trailing-comma.js";
|
|
3
4
|
import { relativeWithinRoot, tryRealpathSync } from "../build/ssr-manifest.js";
|
|
4
|
-
import path from "node:path";
|
|
5
5
|
import { parseAst } from "vite";
|
|
6
6
|
import MagicString from "magic-string";
|
|
7
7
|
//#region src/plugins/dynamic-preload-metadata.ts
|
|
@@ -294,7 +294,7 @@ function insertSecondOptionsArgument(output, code, callNode, firstArg, optionsLi
|
|
|
294
294
|
function cleanResolvedId(id) {
|
|
295
295
|
let start = 0;
|
|
296
296
|
while (start < id.length && id.charCodeAt(start) === 0) start += 1;
|
|
297
|
-
return id.slice(start).replace(/^\/@fs\//, "/").split("?")[0]
|
|
297
|
+
return toSlash(id.slice(start).replace(/^\/@fs\//, "/").split("?")[0]);
|
|
298
298
|
}
|
|
299
299
|
const rootRealpathCache = /* @__PURE__ */ new Map();
|
|
300
300
|
function cachedRootRealpath(root) {
|
|
@@ -311,12 +311,12 @@ function formatNodeLocation(code, node) {
|
|
|
311
311
|
function toManifestModuleId(root, resolvedId) {
|
|
312
312
|
const cleaned = cleanResolvedId(resolvedId);
|
|
313
313
|
if (!path.isAbsolute(cleaned)) return cleaned.replace(/^\/+/, "");
|
|
314
|
-
const rootCandidates = new Set([root]);
|
|
314
|
+
const rootCandidates = /* @__PURE__ */ new Set([root]);
|
|
315
315
|
const realRoot = cachedRootRealpath(root);
|
|
316
|
-
if (realRoot) rootCandidates.add(realRoot);
|
|
317
|
-
const moduleCandidates = new Set([cleaned]);
|
|
316
|
+
if (realRoot) rootCandidates.add(toSlash(realRoot));
|
|
317
|
+
const moduleCandidates = /* @__PURE__ */ new Set([cleaned]);
|
|
318
318
|
const realCleaned = tryRealpathSync(cleaned);
|
|
319
|
-
if (realCleaned) moduleCandidates.add(realCleaned
|
|
319
|
+
if (realCleaned) moduleCandidates.add(toSlash(realCleaned));
|
|
320
320
|
for (const rootCandidate of rootCandidates) for (const moduleCandidate of moduleCandidates) {
|
|
321
321
|
const relative = relativeWithinRoot(rootCandidate, moduleCandidate);
|
|
322
322
|
if (relative) return relative;
|
|
@@ -383,7 +383,7 @@ async function transformNextDynamicPreloadMetadata(code, id, root, resolveDynami
|
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
function createDynamicPreloadMetadataPlugin() {
|
|
386
|
-
let root = process.cwd();
|
|
386
|
+
let root = toSlash(process.cwd());
|
|
387
387
|
return {
|
|
388
388
|
name: "vinext:dynamic-preload-metadata",
|
|
389
389
|
configResolved(config) {
|
package/dist/plugins/fonts.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { escapeRegExp } from "../utils/regex.js";
|
|
2
3
|
import { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
|
|
3
4
|
import { lastSignificantChar } from "../utils/has-trailing-comma.js";
|
|
@@ -8,7 +9,6 @@ import { buildGoogleFontsUrl } from "../build/google-fonts/build-url.js";
|
|
|
8
9
|
import { findFontFilesInCss } from "../build/google-fonts/find-font-files-in-css.js";
|
|
9
10
|
import { CONTENT_TYPES } from "../server/static-file-cache.js";
|
|
10
11
|
import fs from "node:fs";
|
|
11
|
-
import path from "node:path";
|
|
12
12
|
import { parseAst } from "vite";
|
|
13
13
|
import MagicString from "magic-string";
|
|
14
14
|
//#region src/plugins/fonts.ts
|
|
@@ -32,7 +32,7 @@ var GoogleFontsHttpError = class extends Error {
|
|
|
32
32
|
};
|
|
33
33
|
const VIRTUAL_GOOGLE_FONTS = "virtual:vinext-google-fonts";
|
|
34
34
|
const RESOLVED_VIRTUAL_GOOGLE_FONTS = "\0virtual:vinext-google-fonts";
|
|
35
|
-
const GOOGLE_FONT_UTILITY_EXPORTS = new Set([
|
|
35
|
+
const GOOGLE_FONT_UTILITY_EXPORTS = /* @__PURE__ */ new Set([
|
|
36
36
|
"buildGoogleFontsUrl",
|
|
37
37
|
"getSSRFontLinks",
|
|
38
38
|
"getSSRFontStyles",
|
|
@@ -311,7 +311,7 @@ async function fetchAndCacheFont(cssUrl, family, cacheDir) {
|
|
|
311
311
|
fs.writeFileSync(filePath, buffer);
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
css = css.split(fontUrl).join(filePath
|
|
314
|
+
css = css.split(fontUrl).join(filePath);
|
|
315
315
|
}
|
|
316
316
|
fs.writeFileSync(cachedCSSPath, css);
|
|
317
317
|
return css;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { DYNAMIC_IMPORT_PRESCAN, collectBindingNames, forEachAstChild, hasRange, isAstRecord, isIdentifierNamed, mayContainDynamicImport, nodeArray } from "./ast-utils.js";
|
|
2
3
|
import { collectDirectScopeBindings, collectLoopScopeBindings, collectSwitchScopeBindings, collectVarScopeBindings, hasAstBinding, isFunctionNode } from "./ast-scope.js";
|
|
3
|
-
import path from "node:path";
|
|
4
4
|
import { parseAst } from "vite";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import MagicString from "magic-string";
|
|
7
7
|
//#region src/plugins/ignore-dynamic-requests.ts
|
|
8
8
|
const DYNAMIC_REQUEST_ERROR = "Cannot find module as expression is too dynamic";
|
|
9
|
+
const REQUIRE_PRESCAN = /(?:\brequire\b|(?:r|\\u(?:0072|\{0*72\}))(?:e|\\u(?:0065|\{0*65\}))(?:q|\\u(?:0071|\{0*71\}))(?:u|\\u(?:0075|\{0*75\}))(?:i|\\u(?:0069|\{0*69\}))(?:r|\\u(?:0072|\{0*72\}))(?:e|\\u(?:0065|\{0*65\})))/i;
|
|
10
|
+
const DYNAMIC_REQUEST_PRESCAN = new RegExp(String.raw`(?:${REQUIRE_PRESCAN.source}|${DYNAMIC_IMPORT_PRESCAN.source})`, "i");
|
|
9
11
|
const MAX_CONSTANT_BINDING_DEPTH = 1500;
|
|
10
12
|
const VINEXT_SOURCE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
13
|
const PLUGIN_RSC_PATH = /[\\/]node_modules[\\/](?:\.pnpm[\\/][^/\\]+[\\/]node_modules[\\/])?@vitejs[\\/]plugin-rsc[\\/]/;
|
|
12
|
-
const TRANSFORMABLE_EXTENSIONS = new Set([
|
|
14
|
+
const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
13
15
|
".js",
|
|
14
16
|
".jsx",
|
|
15
17
|
".mjs",
|
|
@@ -19,7 +21,7 @@ const TRANSFORMABLE_EXTENSIONS = new Set([
|
|
|
19
21
|
".mts",
|
|
20
22
|
".cts"
|
|
21
23
|
]);
|
|
22
|
-
const TRANSPARENT_EXPRESSIONS = new Set([
|
|
24
|
+
const TRANSPARENT_EXPRESSIONS = /* @__PURE__ */ new Set([
|
|
23
25
|
"ChainExpression",
|
|
24
26
|
"ParenthesizedExpression",
|
|
25
27
|
"TSAsExpression",
|
|
@@ -382,7 +384,7 @@ function dynamicImportReplacement() {
|
|
|
382
384
|
return `Promise.resolve().then(() => { const error = new Error(${JSON.stringify(DYNAMIC_REQUEST_ERROR)}); error.code = "MODULE_NOT_FOUND"; throw error; })`;
|
|
383
385
|
}
|
|
384
386
|
function transformVeryDynamicRequests(code, id) {
|
|
385
|
-
if (!
|
|
387
|
+
if (!REQUIRE_PRESCAN.test(code) && !mayContainDynamicImport(code)) return null;
|
|
386
388
|
const extension = path.extname(id.split("?", 1)[0]);
|
|
387
389
|
const lang = extension === ".ts" || extension === ".mts" || extension === ".cts" ? "ts" : extension === ".tsx" ? "tsx" : extension === ".js" || extension === ".jsx" || extension === ".mjs" || extension === ".cjs" ? "jsx" : "js";
|
|
388
390
|
let ast;
|
|
@@ -507,13 +509,16 @@ function createIgnoreDynamicRequestsPlugin(getTranspiledPackages = () => []) {
|
|
|
507
509
|
name: "vinext:ignore-dynamic-requests",
|
|
508
510
|
enforce: "pre",
|
|
509
511
|
transform: {
|
|
510
|
-
filter: {
|
|
512
|
+
filter: {
|
|
513
|
+
id: { include: /\.(?:[cm]?[jt]s|[jt]sx)(?:\?.*)?$/ },
|
|
514
|
+
code: DYNAMIC_REQUEST_PRESCAN
|
|
515
|
+
},
|
|
511
516
|
handler(code, id) {
|
|
512
517
|
const cleanId = id.split("?", 1)[0];
|
|
513
518
|
if (!TRANSFORMABLE_EXTENSIONS.has(path.extname(cleanId))) return null;
|
|
514
519
|
if (!shouldTransformVeryDynamicRequests(this.environment, cleanId, getTranspiledPackages())) return null;
|
|
515
520
|
const absoluteId = path.resolve(cleanId);
|
|
516
|
-
if (absoluteId === VINEXT_SOURCE_ROOT || absoluteId.startsWith(`${VINEXT_SOURCE_ROOT}
|
|
521
|
+
if (absoluteId === VINEXT_SOURCE_ROOT || absoluteId.startsWith(`${VINEXT_SOURCE_ROOT}/`) || PLUGIN_RSC_PATH.test(absoluteId)) return null;
|
|
517
522
|
return transformVeryDynamicRequests(code, id);
|
|
518
523
|
}
|
|
519
524
|
}
|
|
@@ -521,7 +526,7 @@ function createIgnoreDynamicRequestsPlugin(getTranspiledPackages = () => []) {
|
|
|
521
526
|
}
|
|
522
527
|
function shouldTransformVeryDynamicRequests(environment, id, transpiledPackages) {
|
|
523
528
|
if (environment.config.consumer === "server") return true;
|
|
524
|
-
const normalizedId = id
|
|
529
|
+
const normalizedId = toSlash(id);
|
|
525
530
|
if (!normalizedId.includes("/node_modules/")) return false;
|
|
526
531
|
return !transpiledPackages.some((packageName) => normalizedId.includes(`/node_modules/${packageName}/`));
|
|
527
532
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { VIRTUAL_MODULE_ID_RE } from "../utils/virtual-module.js";
|
|
2
3
|
import { collectBindingNames, forEachAstChild, hasRange, isAstRecord, isIdentifierNamed, nodeArray } from "./ast-utils.js";
|
|
3
4
|
import { tryRealpathSync } from "../build/ssr-manifest.js";
|
|
4
|
-
import
|
|
5
|
-
import { normalizePath, parseAst } from "vite";
|
|
5
|
+
import { parseAst } from "vite";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import MagicString from "magic-string";
|
|
8
8
|
//#region src/plugins/import-meta-url.ts
|
|
9
|
-
const TRANSFORMABLE_SCRIPT_EXTENSIONS = new Set([
|
|
9
|
+
const TRANSFORMABLE_SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
10
10
|
".cjs",
|
|
11
11
|
".cts",
|
|
12
12
|
".js",
|
|
@@ -104,23 +104,21 @@ function cleanModuleId(id) {
|
|
|
104
104
|
}
|
|
105
105
|
function createRootPaths(root, options = {}) {
|
|
106
106
|
const canonicalRoot = canonicalizePath(root);
|
|
107
|
-
const normalizedRoot = normalizePath(canonicalRoot);
|
|
108
107
|
return {
|
|
109
108
|
root,
|
|
110
109
|
canonicalRoot,
|
|
111
|
-
|
|
112
|
-
excludedRelativePrefixes: excludedRelativePrefixes(canonicalRoot, normalizedRoot, options)
|
|
110
|
+
excludedRelativePrefixes: excludedRelativePrefixes(canonicalRoot, options)
|
|
113
111
|
};
|
|
114
112
|
}
|
|
115
113
|
function transformableModuleCanonicalId(id, rootPaths) {
|
|
116
114
|
if (!id || id.startsWith("\0")) return null;
|
|
117
115
|
if (!path.isAbsolute(id)) return null;
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
120
|
-
if (!TRANSFORMABLE_SCRIPT_EXTENSIONS.has(path.extname(
|
|
116
|
+
const slashedInputId = toSlash(id);
|
|
117
|
+
if (slashedInputId.includes("/node_modules/")) return null;
|
|
118
|
+
if (!TRANSFORMABLE_SCRIPT_EXTENSIONS.has(path.extname(slashedInputId))) return null;
|
|
121
119
|
const canonicalId = canonicalizePath(id);
|
|
122
|
-
if (!isPathWithin(
|
|
123
|
-
if (isExcludedRelativePath(
|
|
120
|
+
if (!isPathWithin(canonicalId, rootPaths.canonicalRoot)) return null;
|
|
121
|
+
if (isExcludedRelativePath(path.relative(rootPaths.canonicalRoot, canonicalId), rootPaths.excludedRelativePrefixes)) return null;
|
|
124
122
|
return canonicalId;
|
|
125
123
|
}
|
|
126
124
|
function mayContainImportMetaUrl(code) {
|
|
@@ -129,8 +127,8 @@ function mayContainImportMetaUrl(code) {
|
|
|
129
127
|
function mayContainServerCjsGlobal(code) {
|
|
130
128
|
return code.includes("__filename") || code.includes("__dirname");
|
|
131
129
|
}
|
|
132
|
-
function excludedRelativePrefixes(canonicalRoot,
|
|
133
|
-
const prefixes = new Set([
|
|
130
|
+
function excludedRelativePrefixes(canonicalRoot, options) {
|
|
131
|
+
const prefixes = /* @__PURE__ */ new Set([
|
|
134
132
|
".next",
|
|
135
133
|
".vinext",
|
|
136
134
|
".vinext-local-package",
|
|
@@ -139,8 +137,8 @@ function excludedRelativePrefixes(canonicalRoot, normalizedRoot, options) {
|
|
|
139
137
|
]);
|
|
140
138
|
for (const outputDir of options.outputDirs ?? []) {
|
|
141
139
|
const canonicalOutputDir = canonicalizePath(path.isAbsolute(outputDir) ? outputDir : path.resolve(canonicalRoot, outputDir));
|
|
142
|
-
if (!isPathWithin(
|
|
143
|
-
const relativePath =
|
|
140
|
+
if (!isPathWithin(canonicalOutputDir, canonicalRoot)) continue;
|
|
141
|
+
const relativePath = path.relative(canonicalRoot, canonicalOutputDir);
|
|
144
142
|
if (relativePath && relativePath !== ".") prefixes.add(relativePath);
|
|
145
143
|
}
|
|
146
144
|
return [...prefixes];
|
|
@@ -152,11 +150,12 @@ function isPathWithin(candidate, root) {
|
|
|
152
150
|
return candidate === root || candidate.startsWith(root.endsWith("/") ? root : `${root}/`);
|
|
153
151
|
}
|
|
154
152
|
function importMetaUrlValue(canonicalId, rootPaths, environment) {
|
|
155
|
-
if (environment === "client") return `file:///ROOT/${
|
|
153
|
+
if (environment === "client") return `file:///ROOT/${path.relative(rootPaths.canonicalRoot, canonicalId)}`;
|
|
156
154
|
return pathToFileURL(canonicalId).href;
|
|
157
155
|
}
|
|
158
156
|
function canonicalizePath(value) {
|
|
159
|
-
|
|
157
|
+
const real = tryRealpathSync(value);
|
|
158
|
+
return real === null ? path.resolve(value) : toSlash(real);
|
|
160
159
|
}
|
|
161
160
|
function collectImportMetaUrlRanges(ast) {
|
|
162
161
|
const ranges = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stripViteModuleQuery } from "../utils/path.js";
|
|
2
1
|
import { createMiddlewareMissingExportError } from "../server/middleware-runtime.js";
|
|
2
|
+
import { stripViteModuleQuery } from "../utils/path.js";
|
|
3
3
|
import { parseAst } from "vite";
|
|
4
4
|
//#region src/plugins/middleware-export-validation.ts
|
|
5
5
|
function parserLanguage(id) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
//#region src/plugins/middleware-server-only.ts
|
|
3
3
|
/**
|
|
4
4
|
* Allow `import 'server-only'` from neutral server targets (and any module
|
|
@@ -48,7 +48,7 @@ function createMiddlewareServerOnlyPlugin(options) {
|
|
|
48
48
|
const tainted = /* @__PURE__ */ new Set();
|
|
49
49
|
function canonicalizeId(id) {
|
|
50
50
|
const queryIndex = id.indexOf("?");
|
|
51
|
-
return
|
|
51
|
+
return toSlash(queryIndex === -1 ? id : id.slice(0, queryIndex));
|
|
52
52
|
}
|
|
53
53
|
function isTainted(id) {
|
|
54
54
|
if (!id) return false;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
4
|
//#region src/plugins/og-asset-ownership.ts
|
|
5
|
-
const
|
|
5
|
+
const promisifiedRealpathNative = promisify(fs.realpath.native);
|
|
6
|
+
const realpathNative = async (target) => toSlash(await promisifiedRealpathNative(target));
|
|
6
7
|
function isPathInside(root, target) {
|
|
7
8
|
const relative = path.relative(root, target);
|
|
8
|
-
return relative === "" || !path.isAbsolute(relative) && !relative.startsWith(
|
|
9
|
+
return relative === "" || !path.isAbsolute(relative) && !relative.startsWith("../") && relative !== "..";
|
|
9
10
|
}
|
|
10
11
|
async function findPackageRoot(moduleDir, expectedPackageName) {
|
|
11
12
|
let currentDir = moduleDir;
|
|
@@ -46,7 +47,7 @@ function getNodeModulesPackageRoot(logicalProjectRoot, logicalModulePath) {
|
|
|
46
47
|
const isProjectPath = isPathInside(logicalProjectRoot, logicalModulePath);
|
|
47
48
|
const parsedPath = path.parse(logicalModulePath);
|
|
48
49
|
const baseRoot = isProjectPath ? logicalProjectRoot : parsedPath.root;
|
|
49
|
-
const segments = (isProjectPath ? path.relative(logicalProjectRoot, logicalModulePath) : logicalModulePath.slice(parsedPath.root.length)).split(
|
|
50
|
+
const segments = (isProjectPath ? path.relative(logicalProjectRoot, logicalModulePath) : logicalModulePath.slice(parsedPath.root.length)).split("/");
|
|
50
51
|
const nodeModulesIndex = segments.lastIndexOf("node_modules");
|
|
51
52
|
if (nodeModulesIndex === -1) return null;
|
|
52
53
|
const packageSegment = segments[nodeModulesIndex + 1];
|
|
@@ -94,7 +95,7 @@ async function packageOwnsAliasDirectory(packageRoot, packageName, aliasDirector
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
var OgAssetOwnership = class {
|
|
97
|
-
projectRoot = process.cwd();
|
|
98
|
+
projectRoot = toSlash(process.cwd());
|
|
98
99
|
linkedPackageRoots = /* @__PURE__ */ new Set();
|
|
99
100
|
dependencyPackageNames = /* @__PURE__ */ new Map();
|
|
100
101
|
stringAliasesByFirstCharacter = /* @__PURE__ */ new Map();
|
|
@@ -187,7 +188,7 @@ var OgAssetOwnership = class {
|
|
|
187
188
|
const declaredPackageName = await readPackageName(logicalPackageRoot);
|
|
188
189
|
if (declaredPackageName === null) return null;
|
|
189
190
|
const logicalModuleRelativePath = path.relative(logicalPackageRoot, modulePath);
|
|
190
|
-
if (path.isAbsolute(logicalModuleRelativePath) || logicalModuleRelativePath === ".." || logicalModuleRelativePath.startsWith(
|
|
191
|
+
if (path.isAbsolute(logicalModuleRelativePath) || logicalModuleRelativePath === ".." || logicalModuleRelativePath.startsWith("../")) return null;
|
|
191
192
|
const canonicalPackageRoot = await findPackageRoot(moduleDir, declaredPackageName);
|
|
192
193
|
if (canonicalPackageRoot === null) return null;
|
|
193
194
|
if (path.relative(canonicalPackageRoot, realModulePath) !== logicalModuleRelativePath) return null;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { OgAssetOwnership } from "./og-asset-ownership.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
5
|
import MagicString from "magic-string";
|
|
7
6
|
//#region src/plugins/og-assets.ts
|
|
8
7
|
/**
|
|
@@ -113,7 +112,7 @@ function findEmittedWasmAsset(bundle, baseName) {
|
|
|
113
112
|
const re = new RegExp(`^${stem}(?:-[\\w-]+)?\\.wasm$`);
|
|
114
113
|
for (const output of Object.values(bundle)) {
|
|
115
114
|
if (output.type !== "asset") continue;
|
|
116
|
-
if (re.test(path.
|
|
115
|
+
if (re.test(path.basename(output.fileName))) return output.fileName;
|
|
117
116
|
}
|
|
118
117
|
return null;
|
|
119
118
|
}
|
|
@@ -182,8 +181,8 @@ function createOgAssetsPlugin() {
|
|
|
182
181
|
if (!emitted) continue;
|
|
183
182
|
for (const chunk of chunks) {
|
|
184
183
|
const re = fallbackUrlRegex(base);
|
|
185
|
-
const chunkDir = path.
|
|
186
|
-
const rel =
|
|
184
|
+
const chunkDir = path.dirname(chunk.fileName);
|
|
185
|
+
const rel = path.relative(chunkDir, emitted);
|
|
187
186
|
const ref = rel.startsWith(".") ? rel : `./${rel}`;
|
|
188
187
|
const s = new MagicString(chunk.code);
|
|
189
188
|
let edited = false;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { escapeRegExp } from "../utils/regex.js";
|
|
3
3
|
import { VIRTUAL_MODULE_ID_RE } from "../utils/virtual-module.js";
|
|
4
4
|
import { getAstName } from "./ast-utils.js";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
|
-
import path from "node:path";
|
|
7
6
|
import { parseAst } from "vite";
|
|
8
|
-
import
|
|
7
|
+
import fsp from "node:fs/promises";
|
|
9
8
|
import MagicString from "magic-string";
|
|
10
9
|
//#region src/plugins/optimize-imports.ts
|
|
11
10
|
/**
|
|
@@ -14,7 +13,7 @@ import MagicString from "magic-string";
|
|
|
14
13
|
*/
|
|
15
14
|
async function readFileSafe(filepath) {
|
|
16
15
|
try {
|
|
17
|
-
return await
|
|
16
|
+
return await fsp.readFile(filepath, "utf-8");
|
|
18
17
|
} catch {
|
|
19
18
|
return null;
|
|
20
19
|
}
|
|
@@ -151,7 +150,7 @@ async function resolvePackageInfo(packageName, projectRoot) {
|
|
|
151
150
|
const pkgJsonPath = req.resolve(`${packageName}/package.json`);
|
|
152
151
|
return {
|
|
153
152
|
pkgDir: path.dirname(pkgJsonPath),
|
|
154
|
-
pkgJson: JSON.parse(await
|
|
153
|
+
pkgJson: JSON.parse(await fsp.readFile(pkgJsonPath, "utf-8"))
|
|
155
154
|
};
|
|
156
155
|
} catch {
|
|
157
156
|
try {
|
|
@@ -160,7 +159,7 @@ async function resolvePackageInfo(packageName, projectRoot) {
|
|
|
160
159
|
for (let i = 0; i < 10; i++) {
|
|
161
160
|
const candidate = path.join(dir, "package.json");
|
|
162
161
|
try {
|
|
163
|
-
const parsed = JSON.parse(await
|
|
162
|
+
const parsed = JSON.parse(await fsp.readFile(candidate, "utf-8"));
|
|
164
163
|
if (parsed.name === packageName) return {
|
|
165
164
|
pkgDir: dir,
|
|
166
165
|
pkgJson: parsed
|
|
@@ -194,12 +193,12 @@ async function resolvePackageEntry(packageName, projectRoot, preferReactServer)
|
|
|
194
193
|
const dotExport = pkgJson.exports["."];
|
|
195
194
|
if (dotExport) {
|
|
196
195
|
const entryPath = resolveExportsValue(dotExport, preferReactServer);
|
|
197
|
-
if (entryPath) return
|
|
196
|
+
if (entryPath) return path.resolve(pkgDir, entryPath);
|
|
198
197
|
}
|
|
199
198
|
}
|
|
200
199
|
const entryField = pkgJson.module ?? pkgJson.main;
|
|
201
|
-
if (typeof entryField === "string") return
|
|
202
|
-
return
|
|
200
|
+
if (typeof entryField === "string") return path.resolve(pkgDir, entryField);
|
|
201
|
+
return toSlash(createRequire(path.join(projectRoot, "package.json")).resolve(packageName));
|
|
203
202
|
} catch {
|
|
204
203
|
return null;
|
|
205
204
|
}
|
|
@@ -237,14 +236,14 @@ async function buildExportMapFromFile(filePath, readFile, cache, visited, initia
|
|
|
237
236
|
const exportMap = /* @__PURE__ */ new Map();
|
|
238
237
|
const importBindings = /* @__PURE__ */ new Map();
|
|
239
238
|
const localDeclarations = /* @__PURE__ */ new Set();
|
|
240
|
-
const fileDir = path.
|
|
239
|
+
const fileDir = path.dirname(filePath);
|
|
241
240
|
/**
|
|
242
241
|
* Normalize a source specifier: resolve relative paths to absolute so that
|
|
243
242
|
* entries in the export map always store absolute paths for file references.
|
|
244
243
|
* Bare package specifiers (e.g. "@radix-ui/react-slot") are returned unchanged.
|
|
245
244
|
*/
|
|
246
245
|
function normalizeSource(source) {
|
|
247
|
-
return source.startsWith(".") ? path.
|
|
246
|
+
return source.startsWith(".") ? path.join(fileDir, source) : source;
|
|
248
247
|
}
|
|
249
248
|
function recordLocalDeclaration(node) {
|
|
250
249
|
if (!node) return;
|
|
@@ -306,7 +305,7 @@ async function buildExportMapFromFile(filePath, readFile, cache, visited, initia
|
|
|
306
305
|
isNamespace: true
|
|
307
306
|
});
|
|
308
307
|
} else if (rawSource.startsWith(".")) {
|
|
309
|
-
const subPath = path.
|
|
308
|
+
const subPath = path.join(fileDir, rawSource);
|
|
310
309
|
const candidates = [
|
|
311
310
|
subPath,
|
|
312
311
|
`${subPath}.js`,
|
|
@@ -431,7 +430,7 @@ function createOptimizeImportsPlugin(getNextConfig, getRoot) {
|
|
|
431
430
|
name: "vinext:optimize-imports",
|
|
432
431
|
buildStart() {
|
|
433
432
|
const nextConfig = getNextConfig();
|
|
434
|
-
optimizedPackages = new Set([...DEFAULT_OPTIMIZE_PACKAGES, ...nextConfig?.optimizePackageImports ?? []]);
|
|
433
|
+
optimizedPackages = /* @__PURE__ */ new Set([...DEFAULT_OPTIMIZE_PACKAGES, ...nextConfig?.optimizePackageImports ?? []]);
|
|
435
434
|
hasOptimizedImportSource = createOptimizedImportSourceMatcher(optimizedPackages);
|
|
436
435
|
entryPathCache.clear();
|
|
437
436
|
barrelCaches.exportMapCache.clear();
|
package/dist/plugins/postcss.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { importExportWithCommonJsFallback } from "../utils/commonjs-loader.js";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import fs from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
5
|
//#region src/plugins/postcss.ts
|
|
6
6
|
async function loadPluginExport(resolvedPath) {
|
|
7
7
|
return importExportWithCommonJsFallback(resolvedPath);
|
|
@@ -17,7 +17,7 @@ import MagicString from "magic-string";
|
|
|
17
17
|
* Uses Vite's `parseAst` (OXC/acorn) for parsing and `MagicString` for
|
|
18
18
|
* surgical source replacement. Returns `null` when no changes are made.
|
|
19
19
|
*/
|
|
20
|
-
const SCOPE_ENTERING_TYPES = new Set([
|
|
20
|
+
const SCOPE_ENTERING_TYPES = /* @__PURE__ */ new Set([
|
|
21
21
|
"FunctionDeclaration",
|
|
22
22
|
"FunctionExpression",
|
|
23
23
|
"ArrowFunctionExpression"
|
|
@@ -2,7 +2,7 @@ import { forEachAstChild, hasRange, isAstRecord, nodeArray } from "./ast-utils.j
|
|
|
2
2
|
import { parseAst } from "vite";
|
|
3
3
|
import MagicString from "magic-string";
|
|
4
4
|
//#region src/plugins/require-context.ts
|
|
5
|
-
const TRANSFORMABLE_EXTENSIONS = new Set([
|
|
5
|
+
const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6
6
|
".js",
|
|
7
7
|
".jsx",
|
|
8
8
|
".ts",
|
package/dist/plugins/sass.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { markCssUrlAssetReferences, rebaseCssUrlAssetReferences } from "../build/css-url-assets.js";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import fs from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
5
|
import { preprocessCSS } from "vite";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
//#region src/plugins/sass.ts
|
|
@@ -98,7 +98,7 @@ function sassStylesheetCandidates(importPath) {
|
|
|
98
98
|
return candidates;
|
|
99
99
|
}
|
|
100
100
|
function deriveSassNamespace(importUrl) {
|
|
101
|
-
const parts = importUrl
|
|
101
|
+
const parts = toSlash(importUrl).replace(/\/$/, "").split("/");
|
|
102
102
|
let basename = parts.pop() ?? "stylesheet";
|
|
103
103
|
basename = basename.replace(/^_/, "").replace(/\..*$/, "");
|
|
104
104
|
if (basename === "index" && parts.length > 0) basename = (parts.pop() ?? basename).replace(/^_/, "").replace(/\..*$/, "");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { builtinModules } from "node:module";
|
|
2
3
|
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
4
|
//#region src/plugins/server-externals-manifest.ts
|
|
5
5
|
const BUILTIN_MODULES = new Set(builtinModules.flatMap((name) => name.startsWith("node:") ? [name, name.slice(5)] : [name, `node:${name}`]));
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseAst } from "vite";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
3
|
//#region src/plugins/strip-server-exports.ts
|
|
4
|
-
const SERVER_EXPORTS = new Set([
|
|
4
|
+
const SERVER_EXPORTS = /* @__PURE__ */ new Set([
|
|
5
5
|
"getServerSideProps",
|
|
6
6
|
"getStaticProps",
|
|
7
7
|
"getStaticPaths",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
|
-
import path from "node:path";
|
|
3
3
|
import { parseAst } from "vite";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
//#region src/plugins/styled-jsx.ts
|
|
@@ -75,7 +75,8 @@ function createStyledJsxPlugin(initialProjectRoot, options = {}) {
|
|
|
75
75
|
if (!compilerPromise) {
|
|
76
76
|
const requireFromNext = getNextRequire();
|
|
77
77
|
if (!requireFromNext) throw new Error("[vinext] styled-jsx requires an installed next package so vinext can use its matching compiler.");
|
|
78
|
-
|
|
78
|
+
const compilerPath = requireFromNext.resolve("next/dist/build/swc");
|
|
79
|
+
compilerPromise = importModule(pathToFileURL(compilerPath).href).then(async (compiler) => {
|
|
79
80
|
await compiler.loadBindings();
|
|
80
81
|
return compiler;
|
|
81
82
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
1
2
|
import { collectBindingNames, forEachAstChild, hasRange, isAstRecord, isIdentifierNamed, nodeArray } from "./ast-utils.js";
|
|
2
3
|
import { collectDirectScopeBindings, collectLoopScopeBindings, collectSwitchScopeBindings, collectVarScopeBindings, createAstScope, hasAstBinding, isFunctionNode } from "./ast-scope.js";
|
|
3
|
-
import path from "node:path";
|
|
4
4
|
import { parseAst } from "vite";
|
|
5
5
|
import MagicString from "magic-string";
|
|
6
6
|
//#region src/plugins/typeof-window.ts
|
|
@@ -292,10 +292,6 @@ type RouteManifest = {
|
|
|
292
292
|
};
|
|
293
293
|
/**
|
|
294
294
|
* Build the App Router route graph by scanning `appDir`.
|
|
295
|
-
*
|
|
296
|
-
* `appDir` must be forward-slash. Every path in the graph is derived from it
|
|
297
|
-
* with `path.posix.*` and `findFile`, so a native appDir would produce mixed
|
|
298
|
-
* separators on Windows. Production callers normalize it at their entry.
|
|
299
295
|
*/
|
|
300
296
|
declare function buildAppRouteGraph(appDir: string, matcher: ValidFileMatcher): Promise<{
|
|
301
297
|
routes: AppRouteGraphRoute[];
|
|
@@ -314,12 +310,9 @@ declare function computeRootParamNames(routeSegments: readonly string[], layoutT
|
|
|
314
310
|
* no sibling pages at all (e.g. `deep/path/(...)target` with no
|
|
315
311
|
* `deep/path/page.tsx`).
|
|
316
312
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
* backslashes on Windows. Without normalizing, the `current === appDir`
|
|
321
|
-
* termination never fires there and the walk overshoots the app root.
|
|
322
|
-
* `routesByDir` keys must be forward-slash dirnames of the route file paths.
|
|
313
|
+
* Comparisons happen in forward-slash space — inputs go through `toSlash` so
|
|
314
|
+
* callers still holding native-separator paths hit the `current === appDir`
|
|
315
|
+
* termination instead of overshooting the app root.
|
|
323
316
|
*
|
|
324
317
|
* Exported for tests.
|
|
325
318
|
*/
|