vinext 1.0.0-beta.6 → 1.0.0-beta.7
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 +20 -3
- package/dist/build/action-owner-manifest.d.ts +42 -0
- package/dist/build/action-owner-manifest.js +110 -0
- package/dist/build/clean-output.js +1 -4
- package/dist/build/client-build-config.js +10 -11
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +12 -6
- package/dist/build/report.d.ts +1 -1
- package/dist/build/route-classification-manifest.d.ts +1 -1
- package/dist/build/static-export.d.ts +1 -1
- package/dist/client/app-nav-failure-handler.js +1 -0
- package/dist/client/navigation-runtime.d.ts +5 -3
- package/dist/client/navigation-runtime.js +4 -8
- package/dist/entries/app-browser-entry.d.ts +1 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +111 -8
- package/dist/entries/pages-client-entry.d.ts +1 -1
- package/dist/entries/pages-server-entry.d.ts +1 -1
- package/dist/index.js +108 -22
- package/dist/plugins/action-owner-manifest.d.ts +14 -0
- package/dist/plugins/action-owner-manifest.js +84 -0
- package/dist/plugins/ast-utils.d.ts +30 -1
- package/dist/plugins/ast-utils.js +76 -1
- package/dist/plugins/css-module-imports.d.ts +2 -2
- package/dist/plugins/css-module-imports.js +5 -13
- package/dist/plugins/dynamic-preload-metadata.js +13 -34
- package/dist/plugins/environment.d.ts +11 -0
- package/dist/plugins/environment.js +7 -0
- package/dist/plugins/extensionless-dynamic-import.js +11 -35
- package/dist/plugins/fonts.js +8 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
- package/dist/plugins/ignore-dynamic-requests.js +29 -59
- package/dist/plugins/import-meta-url.d.ts +15 -9
- package/dist/plugins/import-meta-url.js +309 -85
- package/dist/plugins/instrumentation-client.js +4 -5
- package/dist/plugins/middleware-export-validation.js +5 -17
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +18 -26
- package/dist/plugins/og-assets.js +2 -4
- package/dist/plugins/optimize-imports.js +2 -4
- package/dist/plugins/pages-node-externals.js +13 -40
- package/dist/plugins/remove-console.js +2 -4
- package/dist/plugins/require-condition-resolution.d.ts +16 -0
- package/dist/plugins/require-condition-resolution.js +167 -0
- package/dist/plugins/require-context.js +11 -46
- package/dist/plugins/sass.js +1 -1
- package/dist/plugins/server-externals-manifest.js +1 -23
- package/dist/plugins/strip-server-exports.js +13 -19
- package/dist/plugins/styled-jsx.js +17 -19
- package/dist/plugins/transform-result.d.ts +10 -0
- package/dist/plugins/transform-result.js +10 -0
- package/dist/plugins/transitive-externals.js +7 -21
- package/dist/plugins/typeof-window.d.ts +3 -8
- package/dist/plugins/typeof-window.js +5 -15
- package/dist/plugins/use-cache-callable.js +12 -22
- package/dist/plugins/wasm-module-import.js +1 -1
- package/dist/plugins/worker-image-imports.d.ts +12 -0
- package/dist/plugins/worker-image-imports.js +136 -0
- package/dist/routing/app-route-graph.d.ts +3 -2
- package/dist/routing/app-route-graph.js +1 -1
- package/dist/routing/route-pattern.d.ts +8 -1
- package/dist/routing/route-pattern.js +28 -1
- package/dist/routing/route-validation.js +7 -1
- package/dist/server/accept-encoding.d.ts +1 -2
- package/dist/server/accept-encoding.js +1 -4
- package/dist/server/app-action-forwarding.d.ts +18 -0
- package/dist/server/app-action-forwarding.js +140 -0
- package/dist/server/app-browser-entry.js +231 -50
- package/dist/server/app-browser-error.d.ts +1 -2
- package/dist/server/app-browser-error.js +1 -5
- package/dist/server/app-browser-history-controller.d.ts +16 -1
- package/dist/server/app-browser-history-controller.js +135 -18
- package/dist/server/app-browser-navigation-abort.d.ts +16 -0
- package/dist/server/app-browser-navigation-abort.js +29 -0
- package/dist/server/app-browser-navigation-controller.d.ts +4 -0
- package/dist/server/app-browser-navigation-controller.js +22 -6
- package/dist/server/app-browser-navigation-response.d.ts +11 -0
- package/dist/server/app-browser-navigation-response.js +8 -0
- package/dist/server/app-browser-popstate.d.ts +6 -1
- package/dist/server/app-browser-popstate.js +6 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +3 -3
- package/dist/server/app-browser-stream.d.ts +0 -2
- package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
- package/dist/server/app-browser-supplemental-refresh.js +190 -0
- package/dist/server/app-browser-visible-commit.js +23 -12
- package/dist/server/app-elements-wire.d.ts +2 -0
- package/dist/server/app-elements-wire.js +7 -0
- package/dist/server/app-history-state.d.ts +22 -1
- package/dist/server/app-history-state.js +93 -9
- package/dist/server/app-optimistic-routing.d.ts +22 -1
- package/dist/server/app-optimistic-routing.js +137 -12
- package/dist/server/app-page-cache-finalizer.d.ts +3 -1
- package/dist/server/app-page-cache-finalizer.js +6 -6
- package/dist/server/app-page-cache.d.ts +2 -1
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +4 -1
- package/dist/server/app-page-dispatch.js +10 -1
- package/dist/server/app-page-element-builder.d.ts +1 -0
- package/dist/server/app-page-element-builder.js +1 -0
- package/dist/server/app-page-ppr-runtime.js +3 -2
- package/dist/server/app-page-render.d.ts +2 -1
- package/dist/server/app-page-render.js +6 -3
- package/dist/server/app-page-request.d.ts +2 -33
- package/dist/server/app-page-request.js +1 -27
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +4 -0
- package/dist/server/app-page-segment-state.d.ts +2 -2
- package/dist/server/app-page-segment-state.js +14 -8
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
- package/dist/server/app-ppr-fallback-shell.js +3 -6
- package/dist/server/app-route-handler-dispatch.js +4 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +34 -8
- package/dist/server/app-rsc-handler.d.ts +4 -2
- package/dist/server/app-rsc-handler.js +57 -9
- package/dist/server/app-rsc-request-normalization.d.ts +2 -0
- package/dist/server/app-rsc-request-normalization.js +5 -1
- package/dist/server/app-rsc-route-matching.d.ts +4 -3
- package/dist/server/app-rsc-route-matching.js +14 -42
- package/dist/server/app-server-action-execution.d.ts +3 -0
- package/dist/server/app-server-action-execution.js +77 -2
- package/dist/server/app-ssr-entry.js +6 -6
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js +2 -2
- package/dist/server/app-visited-response-cache.d.ts +6 -1
- package/dist/server/app-visited-response-cache.js +18 -2
- package/dist/server/dev-route-files.js +2 -5
- package/dist/server/dev-server.d.ts +5 -13
- package/dist/server/dev-server.js +22 -22
- package/dist/server/dev-stack-sourcemap.d.ts +1 -2
- package/dist/server/dev-stack-sourcemap.js +1 -4
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/isr-cache.d.ts +6 -14
- package/dist/server/isr-cache.js +6 -27
- package/dist/server/middleware.d.ts +3 -16
- package/dist/server/middleware.js +2 -19
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +57 -9
- package/dist/server/navigation-trace.d.ts +1 -0
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/pages-data-route.d.ts +1 -10
- package/dist/server/pages-data-route.js +1 -12
- package/dist/server/pages-node-compat.d.ts +1 -4
- package/dist/server/pages-node-compat.js +1 -7
- package/dist/server/pages-readiness.js +4 -4
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prerender-route-params.js +1 -4
- package/dist/server/prod-server.js +3 -1
- package/dist/shims/cache-runtime.js +39 -22
- package/dist/shims/cache.d.ts +1 -1
- package/dist/shims/dynamic.d.ts +3 -3
- package/dist/shims/dynamic.js +4 -6
- package/dist/shims/error.js +1 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +23 -4
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +6 -7
- package/dist/shims/internal/app-route-prefetch-policy.js +5 -4
- package/dist/shims/link.js +1 -1
- package/dist/shims/navigation.d.ts +12 -3
- package/dist/shims/navigation.js +46 -11
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router.js +75 -4
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/built-asset-url.d.ts +1 -1
- package/dist/utils/built-asset-url.js +4 -2
- package/dist/utils/package-name.d.ts +11 -0
- package/dist/utils/package-name.js +18 -0
- package/dist/utils/path.d.ts +8 -1
- package/dist/utils/path.js +21 -1
- package/package.json +2 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { stripViteModuleQuery } from "../utils/path.js";
|
|
3
|
+
import { magicStringTransformResult } from "./transform-result.js";
|
|
4
|
+
import { DYNAMIC_IMPORT_PRESCAN, SCRIPT_MODULE_ID_RE, collectBindingNames, forEachAstChild, hasRange, isAstRecord, isIdentifierNamed, mayContainDynamicImport, nodeArray, scriptParserLanguage, stringLiteralValue, unwrapExpression } from "./ast-utils.js";
|
|
4
5
|
import { collectDirectScopeBindings, collectLoopScopeBindings, collectSwitchScopeBindings, collectVarScopeBindings, hasAstBinding, isFunctionNode } from "./ast-scope.js";
|
|
6
|
+
import { createTransformCache } from "./transform-cache.js";
|
|
5
7
|
import { parseAst } from "vite";
|
|
6
8
|
import { fileURLToPath } from "node:url";
|
|
7
9
|
import MagicString from "magic-string";
|
|
@@ -12,37 +14,9 @@ const DYNAMIC_REQUEST_PRESCAN = new RegExp(String.raw`(?:${REQUIRE_PRESCAN.sourc
|
|
|
12
14
|
const MAX_CONSTANT_BINDING_DEPTH = 1500;
|
|
13
15
|
const VINEXT_SOURCE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
14
16
|
const PLUGIN_RSC_PATH = /[\\/]node_modules[\\/](?:\.pnpm[\\/][^/\\]+[\\/]node_modules[\\/])?@vitejs[\\/]plugin-rsc[\\/]/;
|
|
15
|
-
const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
16
|
-
".js",
|
|
17
|
-
".jsx",
|
|
18
|
-
".mjs",
|
|
19
|
-
".cjs",
|
|
20
|
-
".ts",
|
|
21
|
-
".tsx",
|
|
22
|
-
".mts",
|
|
23
|
-
".cts"
|
|
24
|
-
]);
|
|
25
|
-
const TRANSPARENT_EXPRESSIONS = /* @__PURE__ */ new Set([
|
|
26
|
-
"ChainExpression",
|
|
27
|
-
"ParenthesizedExpression",
|
|
28
|
-
"TSAsExpression",
|
|
29
|
-
"TSInstantiationExpression",
|
|
30
|
-
"TSNonNullExpression",
|
|
31
|
-
"TSSatisfiesExpression",
|
|
32
|
-
"TSTypeAssertion"
|
|
33
|
-
]);
|
|
34
17
|
function astNode(value) {
|
|
35
18
|
return isAstRecord(value) ? value : null;
|
|
36
19
|
}
|
|
37
|
-
function unwrapExpression(value) {
|
|
38
|
-
const node = astNode(value);
|
|
39
|
-
if (!node || !TRANSPARENT_EXPRESSIONS.has(node.type)) return node;
|
|
40
|
-
return unwrapExpression(node.expression);
|
|
41
|
-
}
|
|
42
|
-
function stringValue(node) {
|
|
43
|
-
if ((node.type === "Literal" || node.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
20
|
function stringFromCharCodeValue(value, scope) {
|
|
47
21
|
const node = unwrapExpression(value);
|
|
48
22
|
if (node?.type !== "CallExpression") return null;
|
|
@@ -61,10 +35,10 @@ function stringFromCharCodeValue(value, scope) {
|
|
|
61
35
|
function isUnboundNumericGlobal(node, scope) {
|
|
62
36
|
return node.type === "Identifier" && typeof node.name === "string" && !hasAstBinding(scope, node.name) && (isIdentifierNamed(node, "NaN") || isIdentifierNamed(node, "Infinity"));
|
|
63
37
|
}
|
|
64
|
-
function
|
|
38
|
+
function evaluateStaticString(value, scope, resolution) {
|
|
65
39
|
const node = unwrapExpression(value);
|
|
66
40
|
if (!node) return null;
|
|
67
|
-
const valueString =
|
|
41
|
+
const valueString = stringLiteralValue(node);
|
|
68
42
|
if (valueString !== null) return valueString;
|
|
69
43
|
if (node.type === "TemplateLiteral" && nodeArray(node.expressions).length === 0) {
|
|
70
44
|
const quasiValue = astNode(nodeArray(node.quasis)[0])?.value;
|
|
@@ -73,19 +47,19 @@ function staticStringValue(value, scope, resolution) {
|
|
|
73
47
|
return typeof cooked === "string" ? cooked : typeof raw === "string" ? raw : null;
|
|
74
48
|
}
|
|
75
49
|
if (node.type === "BinaryExpression" && node.operator === "+") {
|
|
76
|
-
const left =
|
|
77
|
-
const right =
|
|
50
|
+
const left = evaluateStaticString(node.left, scope, resolution);
|
|
51
|
+
const right = evaluateStaticString(node.right, scope, resolution);
|
|
78
52
|
return left === null || right === null ? null : left + right;
|
|
79
53
|
}
|
|
80
54
|
if (node.type === "ConditionalExpression") {
|
|
81
55
|
const truthiness = staticTruthiness(node.test, scope, resolution);
|
|
82
|
-
if (truthiness !== null) return
|
|
83
|
-
const consequent =
|
|
84
|
-
const alternate =
|
|
56
|
+
if (truthiness !== null) return evaluateStaticString(truthiness ? node.consequent : node.alternate, scope, resolution);
|
|
57
|
+
const consequent = evaluateStaticString(node.consequent, scope, resolution);
|
|
58
|
+
const alternate = evaluateStaticString(node.alternate, scope, resolution);
|
|
85
59
|
return consequent !== null && consequent === alternate ? consequent : null;
|
|
86
60
|
}
|
|
87
|
-
if (node.type === "SequenceExpression") return
|
|
88
|
-
if (node.type === "Identifier" && typeof node.name === "string") return resolveConstantBinding(scope, node.name, resolution, null,
|
|
61
|
+
if (node.type === "SequenceExpression") return evaluateStaticString(nodeArray(node.expressions).at(-1), scope, resolution);
|
|
62
|
+
if (node.type === "Identifier" && typeof node.name === "string") return resolveConstantBinding(scope, node.name, resolution, null, evaluateStaticString);
|
|
89
63
|
return null;
|
|
90
64
|
}
|
|
91
65
|
function hasSignificantPathPart(value) {
|
|
@@ -196,7 +170,7 @@ function templateTruthiness(node, scope, resolution, useRaw = false) {
|
|
|
196
170
|
if (nodeArray(node.quasis).filter(isAstRecord).some((quasi) => templateElementValue(quasi, useRaw) !== "")) return true;
|
|
197
171
|
let hasUnknownExpression = false;
|
|
198
172
|
for (const expression of nodeArray(node.expressions)) {
|
|
199
|
-
const string =
|
|
173
|
+
const string = evaluateStaticString(expression, scope, resolution);
|
|
200
174
|
if (string !== null) {
|
|
201
175
|
if (string !== "") return true;
|
|
202
176
|
continue;
|
|
@@ -218,7 +192,7 @@ function staticTruthiness(value, scope, resolution = createConstantResolution())
|
|
|
218
192
|
return quasi?.type === "TemplateLiteral" ? templateTruthiness(quasi, scope, resolution, true) : null;
|
|
219
193
|
}
|
|
220
194
|
if (node.type === "BinaryExpression" && node.operator === "+") {
|
|
221
|
-
const string =
|
|
195
|
+
const string = evaluateStaticString(node, scope, resolution);
|
|
222
196
|
return string === null ? null : Boolean(string);
|
|
223
197
|
}
|
|
224
198
|
if (isIdentifierNamed(node, "undefined") && !hasAstBinding(scope, "undefined")) return false;
|
|
@@ -272,7 +246,7 @@ function stringConcatHasStaticPart(node, scope, resolution) {
|
|
|
272
246
|
if (node.type !== "CallExpression") return null;
|
|
273
247
|
const callee = unwrapExpression(node.callee);
|
|
274
248
|
const property = callee?.type === "MemberExpression" ? unwrapExpression(callee.property) : null;
|
|
275
|
-
if (callee?.type !== "MemberExpression" || (callee.computed === true ? property === null ||
|
|
249
|
+
if (callee?.type !== "MemberExpression" || (callee.computed === true ? property === null || evaluateStaticString(property, scope, resolution) !== "concat" : !isIdentifierNamed(property, "concat"))) return null;
|
|
276
250
|
const receiver = unwrapExpression(callee.object);
|
|
277
251
|
if (!receiver || !isStaticStringExpression(receiver, scope, resolution)) return null;
|
|
278
252
|
if (requestHasStaticPart(receiver, scope, resolution)) return true;
|
|
@@ -284,7 +258,7 @@ function stringConcatHasStaticPart(node, scope, resolution) {
|
|
|
284
258
|
function isStaticStringExpression(value, scope, resolution) {
|
|
285
259
|
const node = unwrapExpression(value);
|
|
286
260
|
if (!node) return false;
|
|
287
|
-
if (
|
|
261
|
+
if (stringLiteralValue(node) !== null || node.type === "TemplateLiteral") return true;
|
|
288
262
|
if (node.type === "Identifier" && typeof node.name === "string") return resolveConstantBinding(scope, node.name, resolution, false, isStaticStringExpression);
|
|
289
263
|
if (node.type === "BinaryExpression" && node.operator === "+") return additionContainsString(node, scope, resolution);
|
|
290
264
|
if (node.type === "ConditionalExpression") return isStaticStringExpression(node.consequent, scope, resolution) && isStaticStringExpression(node.alternate, scope, resolution);
|
|
@@ -295,7 +269,7 @@ function isStaticStringExpression(value, scope, resolution) {
|
|
|
295
269
|
function additionContainsString(value, scope, resolution) {
|
|
296
270
|
const node = unwrapExpression(value);
|
|
297
271
|
if (!node) return false;
|
|
298
|
-
if (
|
|
272
|
+
if (stringLiteralValue(node) !== null || node.type === "TemplateLiteral") return true;
|
|
299
273
|
if (node.type === "Identifier" && typeof node.name === "string") return resolveConstantBinding(scope, node.name, resolution, false, additionContainsString);
|
|
300
274
|
if (node.type === "BinaryExpression" && node.operator === "+") return additionContainsString(node.left, scope, resolution) || additionContainsString(node.right, scope, resolution);
|
|
301
275
|
if (node.type === "ConditionalExpression") return additionContainsString(node.consequent, scope, resolution) && additionContainsString(node.alternate, scope, resolution);
|
|
@@ -305,7 +279,7 @@ function additionContainsString(value, scope, resolution) {
|
|
|
305
279
|
function requestHasStaticPart(value, scope, resolution = createConstantResolution()) {
|
|
306
280
|
const node = unwrapExpression(value);
|
|
307
281
|
if (!node) return false;
|
|
308
|
-
const constantString =
|
|
282
|
+
const constantString = stringLiteralValue(node);
|
|
309
283
|
if (constantString !== null) return constantString.replaceAll("\\", "/") !== "/";
|
|
310
284
|
if (node.type === "Literal") return true;
|
|
311
285
|
if (isUnboundNumericGlobal(node, scope)) return true;
|
|
@@ -325,8 +299,8 @@ function requestHasStaticPart(value, scope, resolution = createConstantResolutio
|
|
|
325
299
|
if (!additionContainsString(node, scope, resolution)) return false;
|
|
326
300
|
const left = unwrapExpression(node.left);
|
|
327
301
|
const right = unwrapExpression(node.right);
|
|
328
|
-
const leftString = left ?
|
|
329
|
-
const rightString = right ?
|
|
302
|
+
const leftString = left ? stringLiteralValue(left) : null;
|
|
303
|
+
const rightString = right ? stringLiteralValue(right) : null;
|
|
330
304
|
return leftString !== null && hasSignificantPathPart(leftString) || rightString !== null && hasSignificantPathPart(rightString) || leftString === null && requestHasStaticPart(left, scope, resolution) || rightString === null && requestHasStaticPart(right, scope, resolution);
|
|
331
305
|
}
|
|
332
306
|
if (node.type === "ConditionalExpression") {
|
|
@@ -401,8 +375,7 @@ function dynamicImportReplacement() {
|
|
|
401
375
|
}
|
|
402
376
|
function transformVeryDynamicRequests(code, id) {
|
|
403
377
|
if (!REQUIRE_PRESCAN.test(code) && !mayContainDynamicImport(code)) return null;
|
|
404
|
-
const
|
|
405
|
-
const lang = extension === ".ts" || extension === ".mts" || extension === ".cts" ? "ts" : extension === ".tsx" ? "tsx" : extension === ".js" || extension === ".jsx" || extension === ".mjs" || extension === ".cjs" ? "jsx" : "js";
|
|
378
|
+
const lang = scriptParserLanguage(id) ?? "js";
|
|
406
379
|
let ast;
|
|
407
380
|
try {
|
|
408
381
|
ast = parseAst(code, { lang });
|
|
@@ -521,13 +494,10 @@ function transformVeryDynamicRequests(code, id) {
|
|
|
521
494
|
}
|
|
522
495
|
for (const statement of nodeArray(root.body)) if (isAstRecord(statement)) visit(statement, rootScope);
|
|
523
496
|
if (!changed) return null;
|
|
524
|
-
return {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
source: id
|
|
529
|
-
})
|
|
530
|
-
};
|
|
497
|
+
return magicStringTransformResult(output, {
|
|
498
|
+
hires: "boundary",
|
|
499
|
+
source: id
|
|
500
|
+
});
|
|
531
501
|
}
|
|
532
502
|
function createIgnoreDynamicRequestsPlugin(getTranspiledPackages = () => []) {
|
|
533
503
|
const cached = createTransformCache();
|
|
@@ -536,12 +506,12 @@ function createIgnoreDynamicRequestsPlugin(getTranspiledPackages = () => []) {
|
|
|
536
506
|
enforce: "pre",
|
|
537
507
|
transform: {
|
|
538
508
|
filter: {
|
|
539
|
-
id: { include:
|
|
509
|
+
id: { include: SCRIPT_MODULE_ID_RE },
|
|
540
510
|
code: DYNAMIC_REQUEST_PRESCAN
|
|
541
511
|
},
|
|
542
512
|
handler(code, id) {
|
|
543
|
-
const cleanId = id
|
|
544
|
-
if (
|
|
513
|
+
const cleanId = stripViteModuleQuery(id);
|
|
514
|
+
if (scriptParserLanguage(cleanId) === null) return null;
|
|
545
515
|
if (!shouldTransformVeryDynamicRequests(this.environment, cleanId, getTranspiledPackages())) return null;
|
|
546
516
|
const absoluteId = path.resolve(cleanId);
|
|
547
517
|
if (absoluteId === VINEXT_SOURCE_ROOT || absoluteId.startsWith(`${VINEXT_SOURCE_ROOT}/`) || PLUGIN_RSC_PATH.test(absoluteId)) return null;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { MagicStringTransformResult } from "./transform-result.js";
|
|
2
|
+
import { Plugin, ResolvedConfig } from "vite";
|
|
3
3
|
//#region src/plugins/import-meta-url.d.ts
|
|
4
4
|
type ImportMetaUrlEnvironment = "client" | "server";
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type ImportMetaUrlCapability = {
|
|
6
|
+
/** The Vite app plugin. Owns project, dependency, and emitted-chunk identity. */
|
|
7
|
+
vitePlugin: Plugin;
|
|
8
|
+
/** Thin adapter for Vite's independent dependency-optimizer Rolldown pipeline. */
|
|
9
|
+
optimizeDepsPlugin: Plugin;
|
|
10
|
+
/** Cached dependency identity/format classifier shared by both plugin pipelines. */
|
|
11
|
+
isBundledCommonJsDependencyId: (id: string) => boolean;
|
|
8
12
|
};
|
|
13
|
+
type EmittedModuleFileNameResolver = (environmentName: string | undefined, fileName: string) => string;
|
|
9
14
|
declare function createImportMetaUrlPlugin(options: {
|
|
10
15
|
getRoot: () => string | undefined;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare function
|
|
16
|
+
createEmittedModuleFileNameResolver?: (config: ResolvedConfig) => EmittedModuleFileNameResolver | undefined;
|
|
17
|
+
}): ImportMetaUrlCapability;
|
|
18
|
+
declare function rewriteImportMetaUrl(code: string, id: string, root: string, environment: ImportMetaUrlEnvironment): MagicStringTransformResult | null;
|
|
19
|
+
declare function rewriteServerCjsGlobals(code: string, id: string, root: string): MagicStringTransformResult | null;
|
|
14
20
|
//#endregion
|
|
15
|
-
export { createImportMetaUrlPlugin, rewriteImportMetaUrl, rewriteServerCjsGlobals };
|
|
21
|
+
export { EmittedModuleFileNameResolver, ImportMetaUrlCapability, createImportMetaUrlPlugin, rewriteImportMetaUrl, rewriteServerCjsGlobals };
|