vinext 1.0.0-beta.0 → 1.0.0-beta.2
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 +21 -2
- package/dist/build/assets-ignore.js +1 -1
- package/dist/build/clean-output.js +1 -1
- package/dist/build/client-build-config.js +7 -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 +8 -4
- package/dist/build/report.js +14 -6
- 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 +27 -36
- package/dist/cli.js +61 -55
- package/dist/client/instrumentation-client-inject.js +1 -1
- package/dist/client/pages-router-link-navigation.js +1 -1
- package/dist/config/config-matchers.d.ts +13 -37
- package/dist/config/config-matchers.js +33 -123
- package/dist/config/dotenv.js +1 -1
- package/dist/config/next-config.d.ts +7 -3
- package/dist/config/next-config.js +84 -15
- package/dist/config/prerender.d.ts +2 -2
- package/dist/config/prerender.js +7 -15
- package/dist/config/request-context.d.ts +14 -0
- package/dist/config/request-context.js +26 -0
- 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 +39 -14
- package/dist/entries/app-rsc-manifest.js +21 -4
- package/dist/entries/pages-client-entry.js +6 -5
- package/dist/entries/pages-server-entry.js +18 -28
- package/dist/entries/runtime-entry-module.js +2 -2
- package/dist/index.js +314 -230
- package/dist/init-cloudflare.js +1 -1
- package/dist/init-platform.js +1 -1
- package/dist/init.d.ts +6 -4
- package/dist/init.js +25 -27
- 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 +5 -6
- 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 +16 -15
- package/dist/routing/app-route-graph.js +86 -88
- package/dist/routing/app-router.d.ts +0 -5
- package/dist/routing/app-router.js +12 -11
- package/dist/routing/file-matcher.d.ts +13 -28
- package/dist/routing/file-matcher.js +31 -44
- package/dist/routing/pages-router.js +26 -32
- package/dist/routing/route-matching.d.ts +14 -1
- package/dist/routing/route-matching.js +13 -1
- package/dist/routing/route-pattern.d.ts +2 -1
- package/dist/routing/route-pattern.js +7 -4
- package/dist/routing/route-trie.d.ts +5 -1
- package/dist/routing/route-trie.js +5 -2
- package/dist/server/api-handler.js +41 -33
- package/dist/server/app-browser-entry.js +18 -11
- package/dist/server/app-browser-history-controller.d.ts +1 -1
- package/dist/server/app-browser-history-controller.js +3 -3
- package/dist/server/app-browser-navigation-controller.js +4 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-elements-wire.d.ts +2 -1
- package/dist/server/app-fallback-renderer.d.ts +11 -0
- package/dist/server/app-fallback-renderer.js +16 -2
- package/dist/server/app-middleware.js +2 -1
- package/dist/server/app-page-boundary-render.d.ts +26 -2
- package/dist/server/app-page-boundary-render.js +190 -55
- package/dist/server/app-page-cache-finalizer.d.ts +1 -1
- package/dist/server/app-page-cache.d.ts +1 -1
- package/dist/server/app-page-dispatch.d.ts +12 -2
- package/dist/server/app-page-dispatch.js +37 -51
- package/dist/server/app-page-element-builder.d.ts +8 -2
- package/dist/server/app-page-element-builder.js +112 -27
- package/dist/server/app-page-execution.d.ts +3 -1
- package/dist/server/app-page-execution.js +31 -39
- package/dist/server/app-page-head.d.ts +54 -2
- package/dist/server/app-page-head.js +164 -78
- package/dist/server/app-page-http-access-fallback-metadata.d.ts +29 -0
- package/dist/server/app-page-http-access-fallback-metadata.js +106 -0
- package/dist/server/app-page-render.d.ts +2 -2
- package/dist/server/app-page-render.js +1 -1
- package/dist/server/app-page-request.d.ts +12 -0
- package/dist/server/app-page-request.js +134 -14
- package/dist/server/app-page-route-wiring.d.ts +9 -0
- package/dist/server/app-page-route-wiring.js +44 -4
- package/dist/server/app-post-middleware-context.d.ts +1 -1
- package/dist/server/app-post-middleware-context.js +1 -1
- package/dist/server/app-route-handler-dispatch.js +31 -17
- package/dist/server/app-route-handler-execution.d.ts +6 -1
- package/dist/server/app-route-handler-execution.js +41 -15
- package/dist/server/app-route-handler-policy.d.ts +2 -0
- package/dist/server/app-route-handler-policy.js +3 -3
- package/dist/server/app-route-module-loader.d.ts +3 -1
- package/dist/server/app-route-module-loader.js +1 -0
- package/dist/server/app-route-tree-prefetch.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +1 -1
- package/dist/server/app-rsc-cache-busting.js +1 -1
- package/dist/server/app-rsc-errors.d.ts +1 -1
- package/dist/server/app-rsc-errors.js +12 -2
- package/dist/server/app-rsc-handler.d.ts +10 -5
- package/dist/server/app-rsc-handler.js +51 -23
- 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-rsc-request-normalization.d.ts +3 -2
- package/dist/server/app-rsc-request-normalization.js +8 -2
- package/dist/server/app-rsc-response-finalizer.d.ts +2 -2
- package/dist/server/app-rsc-response-finalizer.js +5 -11
- package/dist/server/app-rsc-route-matching.d.ts +20 -0
- package/dist/server/app-rsc-route-matching.js +87 -11
- package/dist/server/app-segment-config.js +15 -5
- package/dist/server/app-server-action-execution.d.ts +3 -1
- package/dist/server/app-server-action-execution.js +8 -6
- package/dist/server/app-ssr-entry.js +4 -1
- package/dist/server/app-ssr-stream.d.ts +2 -7
- package/dist/server/app-ssr-stream.js +5 -10
- package/dist/server/cache-proof.js +1 -1
- package/dist/server/config-headers.d.ts +24 -0
- package/dist/server/config-headers.js +52 -0
- 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-initial-server-error.d.ts +1 -1
- package/dist/server/dev-lockfile.js +2 -3
- package/dist/server/dev-route-files.js +1 -1
- package/dist/server/dev-server.js +281 -173
- 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.d.ts +1 -1
- package/dist/server/isr-cache.js +1 -1
- package/dist/server/metadata-routes.js +4 -4
- package/dist/server/middleware-matcher-pattern.d.ts +22 -0
- package/dist/server/middleware-matcher-pattern.js +219 -0
- package/dist/server/middleware-matcher.d.ts +2 -7
- package/dist/server/middleware-matcher.js +13 -60
- package/dist/server/middleware-path-to-regexp.d.ts +14 -0
- package/dist/server/middleware-path-to-regexp.js +228 -0
- package/dist/server/middleware-response-headers.js +1 -1
- package/dist/server/middleware-runtime.js +5 -4
- package/dist/server/middleware.d.ts +2 -1
- package/dist/server/middleware.js +3 -2
- 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-data-route.d.ts +11 -1
- package/dist/server/pages-data-route.js +16 -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-get-initial-props.d.ts +15 -2
- package/dist/server/pages-get-initial-props.js +16 -6
- 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 +4 -2
- package/dist/server/pages-page-data.js +20 -10
- package/dist/server/pages-page-handler.d.ts +4 -2
- package/dist/server/pages-page-handler.js +74 -43
- package/dist/server/pages-page-response.d.ts +2 -2
- package/dist/server/pages-page-response.js +1 -1
- package/dist/server/pages-preview.d.ts +26 -0
- package/dist/server/pages-preview.js +165 -0
- package/dist/server/pages-readiness.d.ts +5 -4
- package/dist/server/pages-readiness.js +4 -2
- package/dist/server/pages-request-pipeline.d.ts +1 -0
- package/dist/server/pages-request-pipeline.js +25 -11
- package/dist/server/pages-router-entry.js +6 -0
- package/dist/server/prerender-route-params.js +2 -2
- package/dist/server/prod-server.d.ts +1 -4
- package/dist/server/prod-server.js +44 -30
- package/dist/server/request-pipeline.d.ts +15 -29
- package/dist/server/request-pipeline.js +25 -60
- package/dist/server/rsc-stream-hints.js +122 -18
- 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/app.d.ts +1 -1
- package/dist/shims/cache-request-state.d.ts +27 -1
- package/dist/shims/cache-request-state.js +60 -1
- package/dist/shims/cache-runtime.d.ts +12 -1
- package/dist/shims/cache-runtime.js +22 -7
- package/dist/shims/cache.d.ts +5 -5
- package/dist/shims/cache.js +28 -11
- package/dist/shims/constants.js +1 -1
- package/dist/shims/document.d.ts +42 -83
- package/dist/shims/document.js +62 -53
- package/dist/shims/dynamic.d.ts +5 -25
- package/dist/shims/dynamic.js +29 -8
- package/dist/shims/error-boundary.d.ts +4 -4
- package/dist/shims/error.d.ts +22 -6
- package/dist/shims/error.js +53 -15
- package/dist/shims/fetch-cache.js +13 -4
- package/dist/shims/font-google-base.d.ts +11 -4
- package/dist/shims/font-local.d.ts +10 -3
- package/dist/shims/font-utils.js +1 -1
- package/dist/shims/form.d.ts +1 -1
- package/dist/shims/head.d.ts +13 -2
- package/dist/shims/head.js +6 -6
- package/dist/shims/headers.d.ts +28 -31
- package/dist/shims/headers.js +115 -53
- package/dist/shims/image.d.ts +27 -37
- package/dist/shims/image.js +21 -14
- package/dist/shims/internal/cookie-serialize.d.ts +3 -1
- package/dist/shims/internal/cookie-serialize.js +3 -1
- package/dist/shims/internal/hybrid-client-route-owner.js +3 -1
- package/dist/shims/internal/pages-data-fetch-dedup.js +5 -3
- package/dist/shims/internal/utils.d.ts +3 -3
- package/dist/shims/layout-segment-context.d.ts +1 -1
- package/dist/shims/legacy-image.d.ts +3 -37
- package/dist/shims/legacy-image.js +6 -16
- package/dist/shims/link.d.ts +16 -21
- package/dist/shims/link.js +25 -13
- package/dist/shims/navigation-context-state.d.ts +1 -1
- package/dist/shims/navigation-errors.d.ts +2 -1
- package/dist/shims/navigation-errors.js +9 -13
- package/dist/shims/navigation.d.ts +8 -4
- package/dist/shims/navigation.js +29 -18
- package/dist/shims/next-shims-augmentations.d.ts +1 -0
- package/dist/shims/next-shims-public.d.ts +1 -0
- package/dist/shims/public-shim-map.json.js +103 -0
- package/dist/shims/readonly-url-search-params.d.ts +3 -3
- package/dist/shims/readonly-url-search-params.js +3 -3
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router.d.ts +57 -22
- package/dist/shims/router.js +178 -46
- package/dist/shims/script.d.ts +6 -10
- package/dist/shims/script.js +7 -4
- package/dist/shims/server.d.ts +45 -22
- package/dist/shims/server.js +46 -7
- package/dist/shims/slot.d.ts +1 -1
- package/dist/shims/thenable-params.js +1 -1
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +2 -0
- package/dist/shims/url-safety.d.ts +1 -1
- package/dist/shims/url-safety.js +2 -2
- package/dist/typegen.d.ts +8 -2
- package/dist/typegen.js +84 -25
- 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/domain-locale.d.ts +2 -2
- package/dist/utils/external-url.d.ts +5 -0
- package/dist/utils/external-url.js +7 -0
- 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/regex-safety.d.ts +8 -0
- package/dist/utils/regex-safety.js +737 -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 +16 -4
- /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.d.ts
CHANGED
|
@@ -3,14 +3,15 @@ import { getReactUpgradeDeps } from "./utils/react-version.js";
|
|
|
3
3
|
|
|
4
4
|
//#region src/init.d.ts
|
|
5
5
|
type InitOptions = {
|
|
6
|
-
/** Project root directory */root: string; /** Dev server port (default: 3001) */
|
|
7
|
-
port?: number; /** Skip the compatibility check step */
|
|
6
|
+
/** Project root directory */root: string; /** Dev server port (default: 3001), or false to omit the port flag. */
|
|
7
|
+
port?: number | false; /** Skip the compatibility check step */
|
|
8
8
|
skipCheck?: boolean; /** Force overwrite even if vite.config.ts exists */
|
|
9
9
|
force?: boolean; /** Deployment target selected by the user */
|
|
10
10
|
platform?: InitPlatform; /** Configure build-time pre-rendering for all discovered static routes */
|
|
11
11
|
prerender?: boolean; /** Cloudflare cache and image choices. */
|
|
12
12
|
cloudflare?: CloudflareInitOptions; /** Install missing dependencies with the detected package manager (default: true). */
|
|
13
|
-
install?: boolean; /**
|
|
13
|
+
install?: boolean; /** Script naming style (default: namespaced, e.g. dev:vinext). */
|
|
14
|
+
scriptNames?: "namespaced" | "standard"; /** @internal — override exec for testing (avoids ESM spy issues) */
|
|
14
15
|
_exec?: (cmd: string, opts: {
|
|
15
16
|
cwd: string;
|
|
16
17
|
stdio: string;
|
|
@@ -34,8 +35,9 @@ declare function generateViteConfig(_isAppRouter: boolean, prerender?: boolean):
|
|
|
34
35
|
* Add vinext scripts to package.json without overwriting existing scripts.
|
|
35
36
|
* Returns the list of script names that were added.
|
|
36
37
|
*/
|
|
37
|
-
declare function addScripts(root: string, port: number, platform?: InitPlatform, options?: {
|
|
38
|
+
declare function addScripts(root: string, port: number | false, platform?: InitPlatform, options?: {
|
|
38
39
|
warmCdnCache?: boolean;
|
|
40
|
+
scriptNames?: "namespaced" | "standard";
|
|
39
41
|
}): string[];
|
|
40
42
|
type InitDependencyGroups = {
|
|
41
43
|
dependencies: string[];
|
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
|
/**
|
|
@@ -78,22 +78,16 @@ function addScripts(root, port, platform = "node", options = {}) {
|
|
|
78
78
|
const pkg = JSON.parse(raw);
|
|
79
79
|
if (!pkg.scripts) pkg.scripts = {};
|
|
80
80
|
const added = [];
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
added.push("start:vinext");
|
|
92
|
-
}
|
|
93
|
-
if (platform === "cloudflare" && !pkg.scripts["deploy:vinext"]) {
|
|
94
|
-
pkg.scripts["deploy:vinext"] = options.warmCdnCache ? "vinext-cloudflare deploy --config dist/server/wrangler.json --experimental-warm-cdn-cache" : "vinext-cloudflare deploy --config dist/server/wrangler.json";
|
|
95
|
-
added.push("deploy:vinext");
|
|
96
|
-
}
|
|
81
|
+
const addScript = (name, command) => {
|
|
82
|
+
const scriptName = options.scriptNames === "standard" ? name : `${name}:vinext`;
|
|
83
|
+
if (pkg.scripts[scriptName]) return;
|
|
84
|
+
pkg.scripts[scriptName] = command;
|
|
85
|
+
added.push(scriptName);
|
|
86
|
+
};
|
|
87
|
+
addScript("dev", port === false ? "vinext dev" : `vinext dev --port ${port}`);
|
|
88
|
+
addScript("build", "vinext build");
|
|
89
|
+
addScript("start", platform === "cloudflare" ? "wrangler dev --config dist/server/wrangler.json" : "vinext start");
|
|
90
|
+
if (platform === "cloudflare") addScript("deploy", options.warmCdnCache ? "vinext-cloudflare deploy --config dist/server/wrangler.json --experimental-warm-cdn-cache" : "vinext-cloudflare deploy --config dist/server/wrangler.json");
|
|
97
91
|
if (added.length > 0) fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
98
92
|
return added;
|
|
99
93
|
} catch {
|
|
@@ -215,7 +209,7 @@ function updateGitignore(root, platform = "node") {
|
|
|
215
209
|
const entries = [
|
|
216
210
|
{
|
|
217
211
|
entry: "/dist/",
|
|
218
|
-
coveredBy: new Set([
|
|
212
|
+
coveredBy: /* @__PURE__ */ new Set([
|
|
219
213
|
"/dist/",
|
|
220
214
|
"/dist",
|
|
221
215
|
"dist/",
|
|
@@ -224,7 +218,7 @@ function updateGitignore(root, platform = "node") {
|
|
|
224
218
|
},
|
|
225
219
|
{
|
|
226
220
|
entry: ".vinext/",
|
|
227
|
-
coveredBy: new Set([
|
|
221
|
+
coveredBy: /* @__PURE__ */ new Set([
|
|
228
222
|
"/.vinext/",
|
|
229
223
|
"/.vinext",
|
|
230
224
|
".vinext/",
|
|
@@ -233,7 +227,7 @@ function updateGitignore(root, platform = "node") {
|
|
|
233
227
|
},
|
|
234
228
|
...platform === "cloudflare" ? [{
|
|
235
229
|
entry: ".wrangler/",
|
|
236
|
-
coveredBy: new Set([
|
|
230
|
+
coveredBy: /* @__PURE__ */ new Set([
|
|
237
231
|
"/.wrangler/",
|
|
238
232
|
"/.wrangler",
|
|
239
233
|
".wrangler/",
|
|
@@ -342,7 +336,10 @@ async function init(options) {
|
|
|
342
336
|
existingViteConfigPath = renamedPath;
|
|
343
337
|
}
|
|
344
338
|
const addedTypeModule = ensureESModule(root);
|
|
345
|
-
const addedScripts = addScripts(root, port, platform, {
|
|
339
|
+
const addedScripts = addScripts(root, port, platform, {
|
|
340
|
+
warmCdnCache: options.cloudflare?.warmCdnCache ?? false,
|
|
341
|
+
scriptNames: options.scriptNames
|
|
342
|
+
});
|
|
346
343
|
const setupContext = {
|
|
347
344
|
root,
|
|
348
345
|
isAppRouter: isApp,
|
|
@@ -436,18 +433,19 @@ async function init(options) {
|
|
|
436
433
|
if (updatedGitignore) console.log(` ${terminalStyle.green("✓")} Added vinext output directories to .gitignore`);
|
|
437
434
|
const nextSteps = [...platformSetup.nextSteps];
|
|
438
435
|
if (dependencyInstallNeedsApproval) nextSteps.push("Dependency installation is incomplete because pnpm blocked dependency build scripts:", "1. Review and approve the required build scripts:", " pnpm approve-builds", "2. Finish installing dependencies:", " pnpm install");
|
|
439
|
-
const
|
|
436
|
+
const scriptName = (name) => options.scriptNames === "standard" ? name : `${name}:vinext`;
|
|
437
|
+
const deployCommandStep = platform === "cloudflare" ? ` ${pmName} run ${scriptName("deploy")} Deploy to Cloudflare Workers\n` : "";
|
|
440
438
|
const startCommandDescription = platform === "cloudflare" ? "Start the built Worker locally with Wrangler" : "Start vinext production server";
|
|
441
439
|
console.log(`
|
|
442
440
|
${terminalStyle.cyan(terminalStyle.bold("Next steps:"))}
|
|
443
441
|
${nextSteps.map((step) => ` ${step}`).join("\n")}${nextSteps.length > 0 ? "\n" : ""}
|
|
444
|
-
${pmName} run dev
|
|
445
|
-
${pmName} run build
|
|
446
|
-
${pmName} run start
|
|
447
|
-
${deployCommandStep} ${pmName} run dev Start Next.js (still works as before)
|
|
442
|
+
${pmName} run ${scriptName("dev")} Start the vinext dev server
|
|
443
|
+
${pmName} run ${scriptName("build")} Build production output
|
|
444
|
+
${pmName} run ${scriptName("start")} ${startCommandDescription}
|
|
445
|
+
${deployCommandStep}${options.scriptNames === "standard" ? "" : ` ${pmName} run dev Start Next.js (still works as before)\n`}
|
|
448
446
|
`);
|
|
449
447
|
return {
|
|
450
|
-
installedDeps: [
|
|
448
|
+
installedDeps: [.../* @__PURE__ */ new Set([...dependencyEntriesAdded, ...devDependencyEntriesAdded])],
|
|
451
449
|
addedTypeModule,
|
|
452
450
|
renamedConfigs,
|
|
453
451
|
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
|
/**
|
|
@@ -110,10 +109,10 @@ const OG_WASM_ASSETS = ["resvg.wasm", "yoga.wasm"];
|
|
|
110
109
|
*/
|
|
111
110
|
function findEmittedWasmAsset(bundle, baseName) {
|
|
112
111
|
const stem = baseName.replace(/\.wasm$/, "");
|
|
113
|
-
const re = new RegExp(`^${stem}(
|
|
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",
|