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
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
|
+
import { safeJsonStringify } from "../server/html.js";
|
|
3
|
+
import { addClientActionReachability, buildActionOwnerManifest, collectRscActionReachability, resolveClientReferenceImportIds } from "../build/action-owner-manifest.js";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
//#region src/plugins/action-owner-manifest.ts
|
|
6
|
+
const ACTION_OWNER_MANIFEST_ID = "virtual:vinext-action-owner-manifest";
|
|
7
|
+
const RESOLVED_ACTION_OWNER_MANIFEST_ID = `\0${ACTION_OWNER_MANIFEST_ID}`;
|
|
8
|
+
const ACTION_OWNER_MANIFEST_FILE = "__vinext_action_owner_manifest.js";
|
|
9
|
+
function getModuleInfo(context, id) {
|
|
10
|
+
const info = context.getModuleInfo(id);
|
|
11
|
+
if (!info) return null;
|
|
12
|
+
return {
|
|
13
|
+
importedIds: info.importedIds,
|
|
14
|
+
dynamicallyImportedIds: info.dynamicallyImportedIds
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function createActionOwnerManifestPlugin(options) {
|
|
18
|
+
let config;
|
|
19
|
+
let routeReachability = /* @__PURE__ */ new Map();
|
|
20
|
+
let manifest = {};
|
|
21
|
+
return {
|
|
22
|
+
name: "vinext:action-owner-manifest",
|
|
23
|
+
configResolved(resolvedConfig) {
|
|
24
|
+
config = resolvedConfig;
|
|
25
|
+
},
|
|
26
|
+
resolveId(source) {
|
|
27
|
+
if (source !== "virtual:vinext-action-owner-manifest") return;
|
|
28
|
+
return this.environment.mode === "build" ? {
|
|
29
|
+
id: source,
|
|
30
|
+
external: true
|
|
31
|
+
} : RESOLVED_ACTION_OWNER_MANIFEST_ID;
|
|
32
|
+
},
|
|
33
|
+
load(id) {
|
|
34
|
+
if (id === RESOLVED_ACTION_OWNER_MANIFEST_ID) return "export default null";
|
|
35
|
+
},
|
|
36
|
+
async generateBundle() {
|
|
37
|
+
const manager = await options.getManager(config);
|
|
38
|
+
if (!manager) throw new Error("vinext: failed to access @vitejs/plugin-rsc through getPluginApi().");
|
|
39
|
+
if (manager.isScanBuild) return;
|
|
40
|
+
if (this.environment.name === "rsc") routeReachability = collectRscActionReachability({
|
|
41
|
+
canonicalizeModuleId: options.canonicalizeModuleId,
|
|
42
|
+
clientReferenceMetaMap: manager.clientReferenceMetaMap,
|
|
43
|
+
getModuleInfo: (id) => getModuleInfo(this, id),
|
|
44
|
+
routes: options.getRoutes(),
|
|
45
|
+
serverReferenceMetaMap: manager.serverReferences.metaMap,
|
|
46
|
+
sharedRoots: options.getSharedRoots()
|
|
47
|
+
});
|
|
48
|
+
else if (this.environment.name === "client") {
|
|
49
|
+
await resolveClientReferenceImportIds({
|
|
50
|
+
canonicalizeModuleId: options.canonicalizeModuleId,
|
|
51
|
+
resolveId: async (id) => (await this.resolve(id))?.id ?? null,
|
|
52
|
+
routeReachability
|
|
53
|
+
});
|
|
54
|
+
addClientActionReachability({
|
|
55
|
+
canonicalizeModuleId: options.canonicalizeModuleId,
|
|
56
|
+
clientReferenceMetaMap: manager.clientReferenceMetaMap,
|
|
57
|
+
getModuleInfo: (id) => getModuleInfo(this, id),
|
|
58
|
+
routeReachability,
|
|
59
|
+
serverReferenceMetaMap: manager.serverReferences.metaMap
|
|
60
|
+
});
|
|
61
|
+
manifest = buildActionOwnerManifest(routeReachability);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
renderChunk(code, chunk) {
|
|
65
|
+
if (!code.includes("virtual:vinext-action-owner-manifest")) return;
|
|
66
|
+
let relativePath = path.posix.relative(path.posix.dirname(chunk.fileName), ACTION_OWNER_MANIFEST_FILE);
|
|
67
|
+
if (!relativePath.startsWith(".")) relativePath = `./${relativePath}`;
|
|
68
|
+
return { code: code.replaceAll(ACTION_OWNER_MANIFEST_ID, relativePath) };
|
|
69
|
+
},
|
|
70
|
+
buildApp: {
|
|
71
|
+
order: "post",
|
|
72
|
+
async handler(builder) {
|
|
73
|
+
const outDir = builder.config.environments.rsc.build.outDir;
|
|
74
|
+
await fs.promises.mkdir(outDir, { recursive: true });
|
|
75
|
+
await fs.promises.writeFile(path.join(outDir, ACTION_OWNER_MANIFEST_FILE), `export default ${safeJsonStringify(manifest)};\n`);
|
|
76
|
+
routeReachability = /* @__PURE__ */ new Map();
|
|
77
|
+
manifest = {};
|
|
78
|
+
options.onComplete?.();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { ACTION_OWNER_MANIFEST_ID, createActionOwnerManifestPlugin };
|
|
@@ -9,6 +9,8 @@ type AstRange = AstRecord & {
|
|
|
9
9
|
start: number;
|
|
10
10
|
end: number;
|
|
11
11
|
};
|
|
12
|
+
type ScriptParserLanguage = "js" | "jsx" | "ts" | "tsx";
|
|
13
|
+
declare const SCRIPT_MODULE_ID_RE: RegExp;
|
|
12
14
|
/**
|
|
13
15
|
* Cheap pre-parse gate for plugins that only transform *dynamic* `import(...)`.
|
|
14
16
|
*
|
|
@@ -35,12 +37,39 @@ declare const DYNAMIC_IMPORT_PRESCAN: RegExp;
|
|
|
35
37
|
* gate used to avoid parsing static-import-only modules.
|
|
36
38
|
*/
|
|
37
39
|
declare function mayContainDynamicImport(code: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Select the OXC parser mode for a JavaScript/TypeScript module id.
|
|
42
|
+
*
|
|
43
|
+
* JavaScript-family files intentionally use the JSX parser. Next.js accepts
|
|
44
|
+
* JSX in `.js` files, and every caller using this helper runs before JSX has
|
|
45
|
+
* necessarily been lowered.
|
|
46
|
+
*/
|
|
47
|
+
declare function scriptParserLanguage(id: string): ScriptParserLanguage | null;
|
|
38
48
|
declare function isAstRecord(value: unknown): value is AstRecord;
|
|
39
49
|
declare function nodeArray(value: unknown): unknown[];
|
|
40
50
|
declare function hasRange(node: AstRecord | null): node is AstRange;
|
|
41
51
|
declare function isIdentifierNamed(value: unknown, name: string): boolean;
|
|
42
52
|
declare function getAstName(value: unknown): string | null;
|
|
53
|
+
/** Remove syntax-only wrappers while preserving the underlying expression. */
|
|
54
|
+
declare function unwrapExpression(value: unknown): AstRecord | null;
|
|
55
|
+
/** Return the value of a string literal node, without evaluating expressions. */
|
|
56
|
+
declare function stringLiteralValue(value: unknown): string | null;
|
|
57
|
+
/** Return the value of a boolean literal node, without evaluating expressions. */
|
|
58
|
+
declare function booleanLiteralValue(value: unknown): boolean | null;
|
|
59
|
+
/**
|
|
60
|
+
* Return a statically known string literal, including an interpolation-free
|
|
61
|
+
* template literal. This deliberately does not fold concatenations or other
|
|
62
|
+
* expressions.
|
|
63
|
+
*/
|
|
64
|
+
declare function staticStringValue(value: unknown): string | null;
|
|
43
65
|
declare function forEachAstChild(node: AstRecord, callback: (child: AstRecord) => void): void;
|
|
66
|
+
/**
|
|
67
|
+
* Visit an AST in depth-first order. Returning `false` prunes the current
|
|
68
|
+
* node's subtree, which is useful once a transform has claimed a complete
|
|
69
|
+
* expression. Parent links and source-location metadata are skipped by
|
|
70
|
+
* {@link forEachAstChild}, so OXC's cyclic `parent` references are safe.
|
|
71
|
+
*/
|
|
72
|
+
declare function walkAst(value: unknown, visitor: (node: AstRecord) => boolean | void): void;
|
|
44
73
|
declare function collectBindingNames(pattern: unknown, target: Set<string>): void;
|
|
45
74
|
//#endregion
|
|
46
|
-
export { AstRange, AstRecord, DYNAMIC_IMPORT_PRESCAN, collectBindingNames, forEachAstChild, getAstName, hasRange, isAstRecord, isIdentifierNamed, mayContainDynamicImport, nodeArray };
|
|
75
|
+
export { AstRange, AstRecord, DYNAMIC_IMPORT_PRESCAN, SCRIPT_MODULE_ID_RE, ScriptParserLanguage, booleanLiteralValue, collectBindingNames, forEachAstChild, getAstName, hasRange, isAstRecord, isIdentifierNamed, mayContainDynamicImport, nodeArray, scriptParserLanguage, staticStringValue, stringLiteralValue, unwrapExpression, walkAst };
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
//#region src/plugins/ast-utils.ts
|
|
2
|
+
const SCRIPT_MODULE_EXTENSION_RE = /^\.(?:[cm]?[jt]s|[jt]sx)$/i;
|
|
3
|
+
const SCRIPT_MODULE_ID_RE = /\.(?:[cm]?[jt]s|[jt]sx)(?:[?#].*)?$/i;
|
|
4
|
+
const TRANSPARENT_EXPRESSION_TYPES = /* @__PURE__ */ new Set([
|
|
5
|
+
"ChainExpression",
|
|
6
|
+
"ParenthesizedExpression",
|
|
7
|
+
"TSAsExpression",
|
|
8
|
+
"TSInstantiationExpression",
|
|
9
|
+
"TSNonNullExpression",
|
|
10
|
+
"TSSatisfiesExpression",
|
|
11
|
+
"TSTypeAssertion"
|
|
12
|
+
]);
|
|
2
13
|
/**
|
|
3
14
|
* Cheap pre-parse gate for plugins that only transform *dynamic* `import(...)`.
|
|
4
15
|
*
|
|
@@ -27,6 +38,23 @@ const DYNAMIC_IMPORT_PRESCAN = /\bimport\s*[(/]/;
|
|
|
27
38
|
function mayContainDynamicImport(code) {
|
|
28
39
|
return DYNAMIC_IMPORT_PRESCAN.test(code);
|
|
29
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Select the OXC parser mode for a JavaScript/TypeScript module id.
|
|
43
|
+
*
|
|
44
|
+
* JavaScript-family files intentionally use the JSX parser. Next.js accepts
|
|
45
|
+
* JSX in `.js` files, and every caller using this helper runs before JSX has
|
|
46
|
+
* necessarily been lowered.
|
|
47
|
+
*/
|
|
48
|
+
function scriptParserLanguage(id) {
|
|
49
|
+
const cleanId = id.split(/[?#]/, 1)[0];
|
|
50
|
+
const extensionIndex = cleanId.lastIndexOf(".");
|
|
51
|
+
if (extensionIndex === -1) return null;
|
|
52
|
+
const extension = cleanId.slice(extensionIndex).toLowerCase();
|
|
53
|
+
if (!SCRIPT_MODULE_EXTENSION_RE.test(extension)) return null;
|
|
54
|
+
if (extension === ".ts" || extension === ".mts" || extension === ".cts") return "ts";
|
|
55
|
+
if (extension === ".tsx") return "tsx";
|
|
56
|
+
return "jsx";
|
|
57
|
+
}
|
|
30
58
|
const SKIP_CHILD_KEYS = /* @__PURE__ */ new Set([
|
|
31
59
|
"type",
|
|
32
60
|
"parent",
|
|
@@ -60,6 +88,42 @@ function getAstName(value) {
|
|
|
60
88
|
if (typeof node.value === "string") return node.value;
|
|
61
89
|
return null;
|
|
62
90
|
}
|
|
91
|
+
/** Remove syntax-only wrappers while preserving the underlying expression. */
|
|
92
|
+
function unwrapExpression(value) {
|
|
93
|
+
const node = toAstRecord(value);
|
|
94
|
+
if (!node || !TRANSPARENT_EXPRESSION_TYPES.has(node.type)) return node;
|
|
95
|
+
return unwrapExpression(node.expression);
|
|
96
|
+
}
|
|
97
|
+
/** Return the value of a string literal node, without evaluating expressions. */
|
|
98
|
+
function stringLiteralValue(value) {
|
|
99
|
+
const node = toAstRecord(value);
|
|
100
|
+
if ((node?.type === "Literal" || node?.type === "StringLiteral") && typeof node.value === "string") return node.value;
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
/** Return the value of a boolean literal node, without evaluating expressions. */
|
|
104
|
+
function booleanLiteralValue(value) {
|
|
105
|
+
const node = toAstRecord(value);
|
|
106
|
+
return node?.type === "Literal" && typeof node.value === "boolean" ? node.value : null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Return a statically known string literal, including an interpolation-free
|
|
110
|
+
* template literal. This deliberately does not fold concatenations or other
|
|
111
|
+
* expressions.
|
|
112
|
+
*/
|
|
113
|
+
function staticStringValue(value) {
|
|
114
|
+
const node = toAstRecord(value);
|
|
115
|
+
if (!node) return null;
|
|
116
|
+
const literal = stringLiteralValue(node);
|
|
117
|
+
if (literal !== null) return literal;
|
|
118
|
+
if (node.type !== "TemplateLiteral" || nodeArray(node.expressions).length !== 0) return null;
|
|
119
|
+
const quasis = nodeArray(node.quasis);
|
|
120
|
+
if (quasis.length !== 1) return null;
|
|
121
|
+
const quasi = toAstRecord(quasis[0]);
|
|
122
|
+
if (quasi?.type !== "TemplateElement" || typeof quasi.value !== "object" || !quasi.value) return null;
|
|
123
|
+
const cooked = Reflect.get(quasi.value, "cooked");
|
|
124
|
+
const raw = Reflect.get(quasi.value, "raw");
|
|
125
|
+
return typeof cooked === "string" ? cooked : typeof raw === "string" ? raw : null;
|
|
126
|
+
}
|
|
63
127
|
function forEachAstChild(node, callback) {
|
|
64
128
|
for (const [key, value] of Object.entries(node)) {
|
|
65
129
|
if (SKIP_CHILD_KEYS.has(key)) continue;
|
|
@@ -74,6 +138,17 @@ function forEachAstChild(node, callback) {
|
|
|
74
138
|
}
|
|
75
139
|
}
|
|
76
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Visit an AST in depth-first order. Returning `false` prunes the current
|
|
143
|
+
* node's subtree, which is useful once a transform has claimed a complete
|
|
144
|
+
* expression. Parent links and source-location metadata are skipped by
|
|
145
|
+
* {@link forEachAstChild}, so OXC's cyclic `parent` references are safe.
|
|
146
|
+
*/
|
|
147
|
+
function walkAst(value, visitor) {
|
|
148
|
+
const node = toAstRecord(value);
|
|
149
|
+
if (!node || visitor(node) === false) return;
|
|
150
|
+
forEachAstChild(node, (child) => walkAst(child, visitor));
|
|
151
|
+
}
|
|
77
152
|
function collectBindingNames(pattern, target) {
|
|
78
153
|
const node = toAstRecord(pattern);
|
|
79
154
|
if (!node) return;
|
|
@@ -106,4 +181,4 @@ function collectBindingNames(pattern, target) {
|
|
|
106
181
|
}
|
|
107
182
|
}
|
|
108
183
|
//#endregion
|
|
109
|
-
export { DYNAMIC_IMPORT_PRESCAN, collectBindingNames, forEachAstChild, getAstName, hasRange, isAstRecord, isIdentifierNamed, mayContainDynamicImport, nodeArray };
|
|
184
|
+
export { DYNAMIC_IMPORT_PRESCAN, SCRIPT_MODULE_ID_RE, booleanLiteralValue, collectBindingNames, forEachAstChild, getAstName, hasRange, isAstRecord, isIdentifierNamed, mayContainDynamicImport, nodeArray, scriptParserLanguage, staticStringValue, stringLiteralValue, unwrapExpression, walkAst };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { ScriptParserLanguage } from "./ast-utils.js";
|
|
1
2
|
import { Plugin } from "vite";
|
|
2
3
|
import MagicString from "magic-string";
|
|
3
4
|
//#region src/plugins/css-module-imports.d.ts
|
|
4
|
-
|
|
5
|
-
declare function rewriteCssModuleNamespaceImports(code: string, lang?: ScriptLanguage): {
|
|
5
|
+
declare function rewriteCssModuleNamespaceImports(code: string, lang?: ScriptParserLanguage): {
|
|
6
6
|
code: string;
|
|
7
7
|
map: ReturnType<MagicString["generateMap"]>;
|
|
8
8
|
} | null;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
+
import { magicStringTransformResult } from "./transform-result.js";
|
|
2
|
+
import { SCRIPT_MODULE_ID_RE, scriptParserLanguage } from "./ast-utils.js";
|
|
1
3
|
import { parseAst } from "vite";
|
|
2
4
|
import MagicString from "magic-string";
|
|
3
5
|
//#region src/plugins/css-module-imports.ts
|
|
4
6
|
const CSS_MODULE_RE = /\.module\.(?:css|scss|sass)$/i;
|
|
5
7
|
const CSS_MODULE_HINT_RE = /\.module\.(?:css|scss|sass)/i;
|
|
6
|
-
const SCRIPT_RE = /\.(?:[cm]?[jt]sx?)(?:[?#].*)?$/i;
|
|
7
8
|
const MDX_RE = /\.mdx$/i;
|
|
8
|
-
function scriptLanguage(id) {
|
|
9
|
-
const cleanId = id.split("?", 1)[0].toLowerCase();
|
|
10
|
-
if (cleanId.endsWith(".tsx")) return "tsx";
|
|
11
|
-
if (cleanId.endsWith(".ts") || cleanId.endsWith(".mts") || cleanId.endsWith(".cts")) return "ts";
|
|
12
|
-
return "jsx";
|
|
13
|
-
}
|
|
14
9
|
function rewriteCssModuleNamespaceImports(code, lang = "js") {
|
|
15
10
|
let ast;
|
|
16
11
|
try {
|
|
@@ -34,13 +29,10 @@ function rewriteCssModuleNamespaceImports(code, lang = "js") {
|
|
|
34
29
|
output.overwrite(specifier.start, specifier.end, specifier.local.name);
|
|
35
30
|
}
|
|
36
31
|
if (!output) return null;
|
|
37
|
-
return {
|
|
38
|
-
code: output.toString(),
|
|
39
|
-
map: output.generateMap({ hires: true })
|
|
40
|
-
};
|
|
32
|
+
return magicStringTransformResult(output, { hires: true });
|
|
41
33
|
}
|
|
42
34
|
function createCssModuleImportCompatibilityPlugin(options = {}) {
|
|
43
|
-
const idFilter = options.compiledMdx ? MDX_RE :
|
|
35
|
+
const idFilter = options.compiledMdx ? MDX_RE : SCRIPT_MODULE_ID_RE;
|
|
44
36
|
return {
|
|
45
37
|
name: options.compiledMdx ? "vinext:css-module-import-compatibility-mdx" : "vinext:css-module-import-compatibility",
|
|
46
38
|
enforce: options.compiledMdx ? "post" : "pre",
|
|
@@ -50,7 +42,7 @@ function createCssModuleImportCompatibilityPlugin(options = {}) {
|
|
|
50
42
|
code: CSS_MODULE_HINT_RE
|
|
51
43
|
},
|
|
52
44
|
handler(code, id) {
|
|
53
|
-
return rewriteCssModuleNamespaceImports(code, options.compiledMdx ? "jsx" :
|
|
45
|
+
return rewriteCssModuleNamespaceImports(code, options.compiledMdx ? "jsx" : scriptParserLanguage(id) ?? "jsx");
|
|
54
46
|
}
|
|
55
47
|
}
|
|
56
48
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import path, { toSlash } from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
2
2
|
import { isUnknownRecord } from "../utils/record.js";
|
|
3
|
+
import { stripViteModuleQuery } from "../utils/path.js";
|
|
3
4
|
import { hasTrailingComma } from "../utils/has-trailing-comma.js";
|
|
5
|
+
import { magicStringTransformResult } from "./transform-result.js";
|
|
6
|
+
import { getAstName, stringLiteralValue, walkAst } from "./ast-utils.js";
|
|
4
7
|
import { relativeWithinRoot, tryRealpathSync } from "../build/ssr-manifest.js";
|
|
5
8
|
import { parseAst } from "vite";
|
|
6
9
|
import MagicString from "magic-string";
|
|
@@ -20,31 +23,10 @@ function getArray(node, key) {
|
|
|
20
23
|
function getBoolean(node, key) {
|
|
21
24
|
return node[key] === true;
|
|
22
25
|
}
|
|
23
|
-
function nodeName(node) {
|
|
24
|
-
if (!isUnknownRecord(node)) return null;
|
|
25
|
-
const name = node.name;
|
|
26
|
-
if (typeof name === "string") return name;
|
|
27
|
-
const value = node.value;
|
|
28
|
-
return typeof value === "string" ? value : null;
|
|
29
|
-
}
|
|
30
|
-
function nodeStringValue(node) {
|
|
31
|
-
if (!isUnknownRecord(node)) return null;
|
|
32
|
-
const value = node.value;
|
|
33
|
-
return typeof value === "string" ? value : null;
|
|
34
|
-
}
|
|
35
|
-
function walkAst(value, visitor) {
|
|
36
|
-
if (!isUnknownRecord(value)) return;
|
|
37
|
-
visitor(value);
|
|
38
|
-
for (const [key, child] of Object.entries(value)) {
|
|
39
|
-
if (key === "parent") continue;
|
|
40
|
-
if (Array.isArray(child)) for (const item of child) walkAst(item, visitor);
|
|
41
|
-
else if (isUnknownRecord(child)) walkAst(child, visitor);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
26
|
function importSource(node) {
|
|
45
27
|
const source = node.source;
|
|
46
28
|
if (!isUnknownRecord(source)) return null;
|
|
47
|
-
return
|
|
29
|
+
return stringLiteralValue(source);
|
|
48
30
|
}
|
|
49
31
|
function isNextDynamicSource(source) {
|
|
50
32
|
return source === "next/dynamic" || source === "next/dynamic.js";
|
|
@@ -59,7 +41,7 @@ function collectDynamicImportLocals(ast) {
|
|
|
59
41
|
for (const specifier of getArray(node, "specifiers")) {
|
|
60
42
|
if (!isUnknownRecord(specifier)) continue;
|
|
61
43
|
if (getString(specifier, "type") !== "ImportDefaultSpecifier") continue;
|
|
62
|
-
const local =
|
|
44
|
+
const local = getAstName(specifier.local);
|
|
63
45
|
if (local) locals.add(local);
|
|
64
46
|
}
|
|
65
47
|
}
|
|
@@ -119,7 +101,7 @@ function collectBlockScopedBindingNames(body) {
|
|
|
119
101
|
continue;
|
|
120
102
|
}
|
|
121
103
|
if (type === "FunctionDeclaration" || type === "ClassDeclaration") {
|
|
122
|
-
const name =
|
|
104
|
+
const name = getAstName(statement.id);
|
|
123
105
|
if (name) names.add(name);
|
|
124
106
|
}
|
|
125
107
|
}
|
|
@@ -147,7 +129,7 @@ function collectVarBindingNames(value, names) {
|
|
|
147
129
|
function collectFunctionScopeBindingNames(node) {
|
|
148
130
|
const names = /* @__PURE__ */ new Set();
|
|
149
131
|
if (getString(node, "type") === "FunctionExpression") {
|
|
150
|
-
const name =
|
|
132
|
+
const name = getAstName(node.id);
|
|
151
133
|
if (name) names.add(name);
|
|
152
134
|
}
|
|
153
135
|
for (const param of getArray(node, "params")) addBindingName(param, names);
|
|
@@ -202,7 +184,7 @@ function visitDynamicCalls(value, dynamicLocals, visitor) {
|
|
|
202
184
|
}
|
|
203
185
|
if (type === "ClassDeclaration" || type === "ClassExpression") {
|
|
204
186
|
const names = /* @__PURE__ */ new Set();
|
|
205
|
-
const name =
|
|
187
|
+
const name = getAstName(value.id);
|
|
206
188
|
if (name) names.add(name);
|
|
207
189
|
visitChildren(value, withoutBindings(dynamicLocals, names), visitor);
|
|
208
190
|
return;
|
|
@@ -225,7 +207,7 @@ function collectImportSpecifiers(node) {
|
|
|
225
207
|
const seen = /* @__PURE__ */ new Set();
|
|
226
208
|
walkAst(node, (item) => {
|
|
227
209
|
if (getString(item, "type") === "ImportExpression") {
|
|
228
|
-
const specifier =
|
|
210
|
+
const specifier = stringLiteralValue(item.source);
|
|
229
211
|
if (specifier && !seen.has(specifier)) {
|
|
230
212
|
seen.add(specifier);
|
|
231
213
|
specifiers.push(specifier);
|
|
@@ -236,7 +218,7 @@ function collectImportSpecifiers(node) {
|
|
|
236
218
|
const callee = item.callee;
|
|
237
219
|
if (!isUnknownRecord(callee) || getString(callee, "type") !== "Import") return;
|
|
238
220
|
const firstArg = getArray(item, "arguments")[0];
|
|
239
|
-
const specifier =
|
|
221
|
+
const specifier = stringLiteralValue(firstArg);
|
|
240
222
|
if (specifier && !seen.has(specifier)) {
|
|
241
223
|
seen.add(specifier);
|
|
242
224
|
specifiers.push(specifier);
|
|
@@ -247,7 +229,7 @@ function collectImportSpecifiers(node) {
|
|
|
247
229
|
function propertyKeyName(property) {
|
|
248
230
|
if (!isUnknownRecord(property)) return null;
|
|
249
231
|
if (getBoolean(property, "computed")) return null;
|
|
250
|
-
return
|
|
232
|
+
return getAstName(property.key);
|
|
251
233
|
}
|
|
252
234
|
function objectProperties(node) {
|
|
253
235
|
if (!isUnknownRecord(node) || getString(node, "type") !== "ObjectExpression") return [];
|
|
@@ -294,7 +276,7 @@ function insertSecondOptionsArgument(output, code, callNode, firstArg, optionsLi
|
|
|
294
276
|
function cleanResolvedId(id) {
|
|
295
277
|
let start = 0;
|
|
296
278
|
while (start < id.length && id.charCodeAt(start) === 0) start += 1;
|
|
297
|
-
return toSlash(id.slice(start).replace(/^\/@fs\//, "/")
|
|
279
|
+
return toSlash(stripViteModuleQuery(id.slice(start).replace(/^\/@fs\//, "/")));
|
|
298
280
|
}
|
|
299
281
|
const rootRealpathCache = /* @__PURE__ */ new Map();
|
|
300
282
|
function cachedRootRealpath(root) {
|
|
@@ -377,10 +359,7 @@ async function transformNextDynamicPreloadMetadata(code, id, root, resolveDynami
|
|
|
377
359
|
});
|
|
378
360
|
await Promise.all(pending);
|
|
379
361
|
if (!changed) return null;
|
|
380
|
-
return
|
|
381
|
-
code: output.toString(),
|
|
382
|
-
map: output.generateMap({ hires: "boundary" })
|
|
383
|
-
};
|
|
362
|
+
return magicStringTransformResult(output);
|
|
384
363
|
}
|
|
385
364
|
function createDynamicPreloadMetadataPlugin() {
|
|
386
365
|
let root = toSlash(process.cwd());
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/plugins/environment.d.ts
|
|
2
|
+
type PluginEnvironment = {
|
|
3
|
+
name: string;
|
|
4
|
+
config: {
|
|
5
|
+
consumer?: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
/** Whether a Vite environment produces server-consumed output. */
|
|
9
|
+
declare function isServerEnvironment(environment: PluginEnvironment): boolean;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isServerEnvironment };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/plugins/environment.ts
|
|
2
|
+
/** Whether a Vite environment produces server-consumed output. */
|
|
3
|
+
function isServerEnvironment(environment) {
|
|
4
|
+
return environment.name !== "client" && environment.config.consumer !== "client";
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isServerEnvironment };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
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 { isUnknownRecord } from "../utils/record.js";
|
|
4
|
-
import {
|
|
4
|
+
import { NODE_MODULES_PATH_RE } from "../utils/path.js";
|
|
5
|
+
import { magicStringTransformResult } from "./transform-result.js";
|
|
6
|
+
import { DYNAMIC_IMPORT_PRESCAN, SCRIPT_MODULE_ID_RE, hasRange, isAstRecord, nodeArray, scriptParserLanguage, walkAst } from "./ast-utils.js";
|
|
5
7
|
import { createTransformCache } from "./transform-cache.js";
|
|
6
8
|
import { createRequire } from "node:module";
|
|
7
9
|
import fs from "node:fs";
|
|
@@ -17,16 +19,6 @@ const MODULE_EXTENSIONS = [
|
|
|
17
19
|
".tsx",
|
|
18
20
|
".json"
|
|
19
21
|
];
|
|
20
|
-
const TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
21
|
-
".mjs",
|
|
22
|
-
".js",
|
|
23
|
-
".mts",
|
|
24
|
-
".ts",
|
|
25
|
-
".jsx",
|
|
26
|
-
".tsx",
|
|
27
|
-
".cjs",
|
|
28
|
-
".cts"
|
|
29
|
-
]);
|
|
30
22
|
function createExtensionlessDynamicImportPlugin() {
|
|
31
23
|
let transformConfig = {
|
|
32
24
|
aliases: [],
|
|
@@ -50,8 +42,8 @@ function createExtensionlessDynamicImportPlugin() {
|
|
|
50
42
|
transform: {
|
|
51
43
|
filter: {
|
|
52
44
|
id: {
|
|
53
|
-
include:
|
|
54
|
-
exclude:
|
|
45
|
+
include: SCRIPT_MODULE_ID_RE,
|
|
46
|
+
exclude: NODE_MODULES_PATH_RE
|
|
55
47
|
},
|
|
56
48
|
code: DYNAMIC_IMPORT_PRESCAN
|
|
57
49
|
},
|
|
@@ -68,7 +60,7 @@ function createExtensionlessDynamicImportPlugin() {
|
|
|
68
60
|
};
|
|
69
61
|
}
|
|
70
62
|
function transformExtensionlessImports(code, id, config) {
|
|
71
|
-
const lang =
|
|
63
|
+
const lang = scriptParserLanguage(id);
|
|
72
64
|
let ast;
|
|
73
65
|
try {
|
|
74
66
|
ast = parseAst(code, { lang });
|
|
@@ -82,33 +74,17 @@ function transformExtensionlessImports(code, id, config) {
|
|
|
82
74
|
const source = code.slice(dynamicImport.sourceStart, dynamicImport.sourceEnd);
|
|
83
75
|
output.overwrite(dynamicImport.start, dynamicImport.end, dynamicImport.kind === "package" ? buildPackageReplacement(source, dynamicImport.resolution) : buildReplacement(source, dynamicImport.globPattern, dynamicImport.moduleExtensions));
|
|
84
76
|
}
|
|
85
|
-
return
|
|
86
|
-
code: output.toString(),
|
|
87
|
-
map: output.generateMap({ hires: "boundary" })
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function langForId(id) {
|
|
91
|
-
const clean = id.split("?", 1)[0];
|
|
92
|
-
const dot = clean.lastIndexOf(".");
|
|
93
|
-
if (dot < 0) return null;
|
|
94
|
-
const ext = clean.slice(dot).toLowerCase();
|
|
95
|
-
if (!TRANSFORMABLE_EXTENSIONS.has(ext)) return null;
|
|
96
|
-
if (ext === ".ts" || ext === ".mts" || ext === ".cts") return "ts";
|
|
97
|
-
if (ext === ".tsx") return "tsx";
|
|
98
|
-
return "jsx";
|
|
77
|
+
return magicStringTransformResult(output);
|
|
99
78
|
}
|
|
100
79
|
function collectExtensionlessImports(ast, code, config, id) {
|
|
101
80
|
const imports = [];
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const parsed = parseExtensionlessImport(value, code, config, id);
|
|
81
|
+
walkAst(ast, (node) => {
|
|
82
|
+
const parsed = parseExtensionlessImport(node, code, config, id);
|
|
105
83
|
if (parsed) {
|
|
106
84
|
imports.push(parsed);
|
|
107
|
-
return;
|
|
85
|
+
return false;
|
|
108
86
|
}
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
visit(ast);
|
|
87
|
+
});
|
|
112
88
|
return imports;
|
|
113
89
|
}
|
|
114
90
|
function parseExtensionlessImport(node, code, config, id) {
|
package/dist/plugins/fonts.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import path from "../deps/.pnpm/pathslash@0.1.0/deps/pathslash/dist/index.js";
|
|
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 { ASSET_PREFIX_URL_DIR } from "../utils/asset-prefix.js";
|
|
4
4
|
import { lastSignificantChar } from "../utils/has-trailing-comma.js";
|
|
5
|
+
import { magicStringTransformResult } from "./transform-result.js";
|
|
5
6
|
import { buildFallbackFontFace, getFallbackFontOverrideMetrics } from "../build/google-fonts/fallback-metrics.js";
|
|
6
7
|
import { validateGoogleFontOptions } from "../build/google-fonts/validate.js";
|
|
7
8
|
import { getFontAxes } from "../build/google-fonts/get-axes.js";
|
|
@@ -95,9 +96,10 @@ function formatGoogleFontsErrorBody(body) {
|
|
|
95
96
|
* filesystems.
|
|
96
97
|
*/
|
|
97
98
|
function _rewriteCachedFontCssToServedUrls(css, cacheDir, assetsDir = DEFAULT_ASSETS_DIR) {
|
|
98
|
-
|
|
99
|
+
const normalizedCacheDir = toSlash(cacheDir);
|
|
100
|
+
if (!normalizedCacheDir || !css.includes(normalizedCacheDir)) return css;
|
|
99
101
|
const prefix = assetsDir || DEFAULT_ASSETS_DIR;
|
|
100
|
-
return css.split(
|
|
102
|
+
return css.split(normalizedCacheDir).join(`/${prefix}/${VINEXT_FONT_URL_NAMESPACE}`);
|
|
101
103
|
}
|
|
102
104
|
/**
|
|
103
105
|
* Default `build.assetsDir` — matches vinext's resolved default in
|
|
@@ -422,7 +424,7 @@ function createGoogleFontsPlugin(fontGoogleShimPath, shimsDir) {
|
|
|
422
424
|
name: "vinext:google-fonts",
|
|
423
425
|
enforce: "pre",
|
|
424
426
|
configResolved(config) {
|
|
425
|
-
cacheDir = path.join(config.root, ".vinext", "fonts");
|
|
427
|
+
cacheDir = path.join(toSlash(config.root), ".vinext", "fonts");
|
|
426
428
|
},
|
|
427
429
|
configureServer(server) {
|
|
428
430
|
if (!cacheDir) return;
|
|
@@ -592,10 +594,7 @@ function createGoogleFontsPlugin(fontGoogleShimPath, shimsDir) {
|
|
|
592
594
|
await injectSelfHostedCss(callStart, callEnd, optionsStr, propertyNameToGoogleFontFamily(propName), `${objectName}.${propName}`);
|
|
593
595
|
}
|
|
594
596
|
if (!hasChanges) return null;
|
|
595
|
-
return
|
|
596
|
-
code: s.toString(),
|
|
597
|
-
map: s.generateMap({ hires: "boundary" })
|
|
598
|
-
};
|
|
597
|
+
return magicStringTransformResult(s);
|
|
599
598
|
}
|
|
600
599
|
},
|
|
601
600
|
writeBundle: {
|
|
@@ -699,10 +698,7 @@ function createLocalFontsPlugin(shimsDir) {
|
|
|
699
698
|
}
|
|
700
699
|
if (!hasChanges) return null;
|
|
701
700
|
if (imports.length > 0) s.prepend(imports.join("\n") + "\n");
|
|
702
|
-
return
|
|
703
|
-
code: s.toString(),
|
|
704
|
-
map: s.generateMap({ hires: "boundary" })
|
|
705
|
-
};
|
|
701
|
+
return magicStringTransformResult(s);
|
|
706
702
|
}
|
|
707
703
|
}
|
|
708
704
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { MagicStringTransformResult } from "./transform-result.js";
|
|
1
2
|
import { Plugin } from "vite";
|
|
2
3
|
//#region src/plugins/ignore-dynamic-requests.d.ts
|
|
3
|
-
declare function transformVeryDynamicRequests(code: string, id: string):
|
|
4
|
-
code: string;
|
|
5
|
-
map: import("magic-string").SourceMap;
|
|
6
|
-
} | null;
|
|
4
|
+
declare function transformVeryDynamicRequests(code: string, id: string): MagicStringTransformResult | null;
|
|
7
5
|
declare function createIgnoreDynamicRequestsPlugin(getTranspiledPackages?: () => readonly string[]): Plugin;
|
|
8
6
|
declare const _transformVeryDynamicRequests: typeof transformVeryDynamicRequests;
|
|
9
7
|
//#endregion
|