@vizejs/vite-plugin 0.481.0 → 0.483.0
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/dist/index.mjs +2 -2
- package/dist/{plugin-BJpHdKQz.mjs → plugin-BvYQcGKz.mjs} +212 -115
- package/dist/plugin-t5V0g-uQ.mjs +2 -0
- package/dist/vite-plus.mjs +2 -2
- package/dist/{vue-version-DGtIj1Bv.mjs → vue-version-C75M7lgZ.mjs} +1 -1
- package/dist/{vue-version-BUu5UzZ5.mjs → vue-version-JgVRwvCy.mjs} +19 -1
- package/package.json +4 -4
- package/dist/plugin-C1ZHQliC.mjs +0 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as vize } from "./plugin-
|
|
2
|
-
import {
|
|
1
|
+
import { t as vize } from "./plugin-BvYQcGKz.mjs";
|
|
2
|
+
import { u as rewriteStaticAssetUrls } from "./vue-version-JgVRwvCy.mjs";
|
|
3
3
|
import { a as resolveViteConfigExport, i as resolveConfigExport, n as defineConfig, o as vizeConfigStore, r as loadConfig, t as VIZE_CONFIG_FILE_ENV } from "./config-DE1fZbgD.mjs";
|
|
4
4
|
//#region src/index.ts
|
|
5
5
|
const __internal = { rewriteStaticAssetUrls };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as removeHostVueSfcCompilers, c as rewriteDynamicTemplateImports, d as shouldApplyDefineInVirtualModule, i as isLegacyVueVersion, l as rewriteImportMetaGlobBase, o as applyDefineReplacements, r as isLegacyVueCompatibilityMode, s as createLogger, t as createLegacyVueCompatibilityPlugin, u as rewriteStaticAssetUrls } from "./vue-version-JgVRwvCy.mjs";
|
|
2
2
|
import { a as resolveViteConfigExport, i as resolveConfigExport, o as vizeConfigStore, r as loadConfig } from "./config-DE1fZbgD.mjs";
|
|
3
3
|
import { n as registerResolvedVizeConfig, r as unregisterResolvedVizeConfig } from "./config-bridge-Dv6U7_RC.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
@@ -2071,6 +2071,133 @@ function isOptimizedVueDependency(state, id) {
|
|
|
2071
2071
|
return normalized.includes("/node_modules/.vite/deps/vue.");
|
|
2072
2072
|
}
|
|
2073
2073
|
//#endregion
|
|
2074
|
+
//#region src/plugin/ssr-modules.ts
|
|
2075
|
+
/**
|
|
2076
|
+
* Point a compiled SSR module at the `vue/server-renderer` subpath.
|
|
2077
|
+
*
|
|
2078
|
+
* The compiler emits `@vue/server-renderer`, which is not a dependency every
|
|
2079
|
+
* app declares; the subpath re-export always resolves alongside `vue` itself.
|
|
2080
|
+
*/
|
|
2081
|
+
function normalizeVueServerRendererImport(code) {
|
|
2082
|
+
return code.replace(/\bfrom\s+(['"])@vue\/server-renderer\1/g, "from \"vue/server-renderer\"");
|
|
2083
|
+
}
|
|
2084
|
+
/**
|
|
2085
|
+
* Marks a module whose registration has already been appended.
|
|
2086
|
+
*
|
|
2087
|
+
* Idempotency cannot key on the helper identifiers: an SFC is free to declare
|
|
2088
|
+
* `__vize_useSSRContext` itself, and skipping registration for it would cost it
|
|
2089
|
+
* its initial stylesheet.
|
|
2090
|
+
*/
|
|
2091
|
+
const REGISTRATION_MARKER = "/* @vize-ssr-modules-registered */";
|
|
2092
|
+
/**
|
|
2093
|
+
* Matches the `_sfc_main` component declaration the emitted module carries.
|
|
2094
|
+
*
|
|
2095
|
+
* A bare `\b_sfc_main\b` also matches the identifier inside a string literal or
|
|
2096
|
+
* a comment, and wrapping a component that was never declared is a
|
|
2097
|
+
* `ReferenceError` at render time.
|
|
2098
|
+
*/
|
|
2099
|
+
const SFC_MAIN_DECLARATION = /\b(?:const|let|var)\s+_sfc_main\s*=/;
|
|
2100
|
+
/**
|
|
2101
|
+
* Register an SFC in `ssrContext.modules` during SSR, the way
|
|
2102
|
+
* `@vitejs/plugin-vue` does.
|
|
2103
|
+
*
|
|
2104
|
+
* After rendering, `vue-bundle-renderer` intersects `ssrContext.modules` with
|
|
2105
|
+
* the client manifest to decide which stylesheets belong in the document head.
|
|
2106
|
+
* A component that never registers itself contributes no `<link>`, so the
|
|
2107
|
+
* server-rendered markup arrives unstyled and only gains its styles once the
|
|
2108
|
+
* route chunk loads on the client — a flash of unstyled content that never
|
|
2109
|
+
* recovers when JavaScript is disabled (#3868).
|
|
2110
|
+
*
|
|
2111
|
+
* The key must be the module's path relative to the Vite root with POSIX
|
|
2112
|
+
* separators, because that is what the client manifest is keyed on.
|
|
2113
|
+
*/
|
|
2114
|
+
function ssrModuleRegistrationCode(filePath, root, helpers = {}, frameworkRoot) {
|
|
2115
|
+
const moduleId = JSON.stringify(frameworkRoot === void 0 ? toManifestModuleId(filePath, root) : path.relative(frameworkRoot, filePath).replace(/\\/g, "/"));
|
|
2116
|
+
const useSSRContext = helpers.useSSRContext ?? "__vize_useSSRContext";
|
|
2117
|
+
const sfcSetup = helpers.sfcSetup ?? "__vize_sfc_setup";
|
|
2118
|
+
return {
|
|
2119
|
+
prologue: `${REGISTRATION_MARKER}\nimport { useSSRContext as ${useSSRContext} } from "vue";`,
|
|
2120
|
+
epilogue: [
|
|
2121
|
+
`const ${sfcSetup} = _sfc_main.setup;`,
|
|
2122
|
+
`_sfc_main.setup = (props, ctx) => {`,
|
|
2123
|
+
` const ssrContext = ${useSSRContext}();`,
|
|
2124
|
+
` (ssrContext.modules || (ssrContext.modules = new Set())).add(${moduleId});`,
|
|
2125
|
+
` return ${sfcSetup} ? ${sfcSetup}(props, ctx) : undefined;`,
|
|
2126
|
+
`};`
|
|
2127
|
+
].join("\n")
|
|
2128
|
+
};
|
|
2129
|
+
}
|
|
2130
|
+
/**
|
|
2131
|
+
* The client-manifest key for `filePath`: relative to `root`, POSIX separators.
|
|
2132
|
+
*
|
|
2133
|
+
* A path outside the root keeps its absolute form rather than becoming a `../`
|
|
2134
|
+
* chain, matching how Vite keys modules it cannot root-relativize. Only a real
|
|
2135
|
+
* parent-directory step counts as outside: a filename that merely begins with
|
|
2136
|
+
* `..` still lives in the root and is keyed relative to it.
|
|
2137
|
+
*/
|
|
2138
|
+
function toManifestModuleId(filePath, root) {
|
|
2139
|
+
const relative = path.relative(root, filePath).replace(/\\/g, "/");
|
|
2140
|
+
if (!relative || relative === ".." || relative.startsWith("../") || path.isAbsolute(relative)) return filePath.replace(/\\/g, "/");
|
|
2141
|
+
return relative;
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Wrap an emitted module with the registration.
|
|
2145
|
+
*
|
|
2146
|
+
* The wrapper is appended, so it closes over whatever `setup` the emitter's own
|
|
2147
|
+
* rewrites left in place, but its `import` is *prepended*. A trailing `import`
|
|
2148
|
+
* is legal ESM, yet it makes the module's last import statement its last line,
|
|
2149
|
+
* and Nuxt's auto-import injection then inserts nothing — a component relying on
|
|
2150
|
+
* an auto-imported composable loses that binding and throws `ReferenceError` at
|
|
2151
|
+
* render time (#3868). Leading the module with the import keeps the import
|
|
2152
|
+
* section where every downstream transform expects to find it.
|
|
2153
|
+
*
|
|
2154
|
+
* `useSSRContext()` throws outside a render, so this is a no-op unless `isSsr`.
|
|
2155
|
+
* Modules without an `_sfc_main` declaration — a render-function-only output, or
|
|
2156
|
+
* a boundary placeholder — have no component object to wrap and are returned
|
|
2157
|
+
* untouched.
|
|
2158
|
+
*/
|
|
2159
|
+
function appendSsrModuleRegistration(code, filePath, root, isSsr, frameworkRoot) {
|
|
2160
|
+
if (!isSsr || !SFC_MAIN_DECLARATION.test(code)) return code;
|
|
2161
|
+
if (code.includes(REGISTRATION_MARKER)) return code;
|
|
2162
|
+
const { prologue, epilogue } = ssrModuleRegistrationCode(filePath, root, {
|
|
2163
|
+
useSSRContext: freeIdentifier("__vize_useSSRContext", code),
|
|
2164
|
+
sfcSetup: freeIdentifier("__vize_sfc_setup", code)
|
|
2165
|
+
}, frameworkRoot);
|
|
2166
|
+
return `${prologue}\n${code}\n${epilogue}`;
|
|
2167
|
+
}
|
|
2168
|
+
/**
|
|
2169
|
+
* `base`, or `base` plus the smallest numeric suffix the module does not use.
|
|
2170
|
+
*
|
|
2171
|
+
* Re-declaring an identifier the SFC already bound is a `SyntaxError`, which
|
|
2172
|
+
* would take down the whole module rather than just its stylesheet.
|
|
2173
|
+
*/
|
|
2174
|
+
function freeIdentifier(base, code) {
|
|
2175
|
+
if (!new RegExp(`\\b${base}\\b`).test(code)) return base;
|
|
2176
|
+
for (let suffix = 2;; suffix++) {
|
|
2177
|
+
const candidate = `${base}${suffix}`;
|
|
2178
|
+
if (!new RegExp(`\\b${candidate}\\b`).test(code)) return candidate;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
/**
|
|
2182
|
+
* Whether the environment bundles `request` instead of loading it at runtime.
|
|
2183
|
+
*
|
|
2184
|
+
* Node SSR leaves Vue external, but a worker runtime such as Cloudflare's
|
|
2185
|
+
* workerd (Void, `@cloudflare/vite-plugin`) sets `noExternal: true` and has no
|
|
2186
|
+
* `node_modules` to import from, so Vue must stay in its bundle.
|
|
2187
|
+
*/
|
|
2188
|
+
function ssrEnvironmentBundles(resolve, request) {
|
|
2189
|
+
const { noExternal, external } = resolve ?? {};
|
|
2190
|
+
const packageName = request.split("/", request.startsWith("@") ? 2 : 1).join("/");
|
|
2191
|
+
if (external !== true && (external?.includes(request) || external?.includes(packageName))) return false;
|
|
2192
|
+
if (noExternal === true) return true;
|
|
2193
|
+
if (noExternal === void 0) return false;
|
|
2194
|
+
return (Array.isArray(noExternal) ? noExternal : [noExternal]).some((pattern) => typeof pattern === "string" ? pattern === packageName : pattern.test(packageName));
|
|
2195
|
+
}
|
|
2196
|
+
/** Keep compiler/config root separate from Nuxt's source-relative manifest IDs. */
|
|
2197
|
+
function registerSfcModule(state, code, filePath, isSsr) {
|
|
2198
|
+
return appendSsrModuleRegistration(code, filePath, state.root, isSsr, state.mergedOptions.ssrModuleIdRoot);
|
|
2199
|
+
}
|
|
2200
|
+
//#endregion
|
|
2074
2201
|
//#region src/plugin/tree-shaking.ts
|
|
2075
2202
|
/** Template-only client output has no authored top-level script effects. */
|
|
2076
2203
|
function isPureTemplateOnlyModule(compiled) {
|
|
@@ -2558,10 +2685,11 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
2558
2685
|
return devSsrVueEntry;
|
|
2559
2686
|
}
|
|
2560
2687
|
}
|
|
2561
|
-
return {
|
|
2688
|
+
if (!ssrEnvironmentBundles(ctx.environment?.config?.resolve, ssrExternalVueRequest)) return {
|
|
2562
2689
|
id: ssrExternalVueRequest,
|
|
2563
2690
|
external: true
|
|
2564
2691
|
};
|
|
2692
|
+
return resolveWithVite(ctx, state, ssrExternalVueRequest, cleanImporter, { skipSelf: true });
|
|
2565
2693
|
}
|
|
2566
2694
|
if (!id.startsWith("./") && !id.startsWith("../") && !id.startsWith("/")) {
|
|
2567
2695
|
const isVueRuntime = isVueRuntimeRequest(id);
|
|
@@ -2771,118 +2899,6 @@ function shouldLoadCompiledVueSfcPath(state, realPath, hasNuxtComponentQuery = f
|
|
|
2771
2899
|
return true;
|
|
2772
2900
|
}
|
|
2773
2901
|
//#endregion
|
|
2774
|
-
//#region src/plugin/ssr-modules.ts
|
|
2775
|
-
/**
|
|
2776
|
-
* Point a compiled SSR module at the `vue/server-renderer` subpath.
|
|
2777
|
-
*
|
|
2778
|
-
* The compiler emits `@vue/server-renderer`, which is not a dependency every
|
|
2779
|
-
* app declares; the subpath re-export always resolves alongside `vue` itself.
|
|
2780
|
-
*/
|
|
2781
|
-
function normalizeVueServerRendererImport(code) {
|
|
2782
|
-
return code.replace(/\bfrom\s+(['"])@vue\/server-renderer\1/g, "from \"vue/server-renderer\"");
|
|
2783
|
-
}
|
|
2784
|
-
/**
|
|
2785
|
-
* Marks a module whose registration has already been appended.
|
|
2786
|
-
*
|
|
2787
|
-
* Idempotency cannot key on the helper identifiers: an SFC is free to declare
|
|
2788
|
-
* `__vize_useSSRContext` itself, and skipping registration for it would cost it
|
|
2789
|
-
* its initial stylesheet.
|
|
2790
|
-
*/
|
|
2791
|
-
const REGISTRATION_MARKER = "/* @vize-ssr-modules-registered */";
|
|
2792
|
-
/**
|
|
2793
|
-
* Matches the `_sfc_main` component declaration the emitted module carries.
|
|
2794
|
-
*
|
|
2795
|
-
* A bare `\b_sfc_main\b` also matches the identifier inside a string literal or
|
|
2796
|
-
* a comment, and wrapping a component that was never declared is a
|
|
2797
|
-
* `ReferenceError` at render time.
|
|
2798
|
-
*/
|
|
2799
|
-
const SFC_MAIN_DECLARATION = /\b(?:const|let|var)\s+_sfc_main\s*=/;
|
|
2800
|
-
/**
|
|
2801
|
-
* Register an SFC in `ssrContext.modules` during SSR, the way
|
|
2802
|
-
* `@vitejs/plugin-vue` does.
|
|
2803
|
-
*
|
|
2804
|
-
* After rendering, `vue-bundle-renderer` intersects `ssrContext.modules` with
|
|
2805
|
-
* the client manifest to decide which stylesheets belong in the document head.
|
|
2806
|
-
* A component that never registers itself contributes no `<link>`, so the
|
|
2807
|
-
* server-rendered markup arrives unstyled and only gains its styles once the
|
|
2808
|
-
* route chunk loads on the client — a flash of unstyled content that never
|
|
2809
|
-
* recovers when JavaScript is disabled (#3868).
|
|
2810
|
-
*
|
|
2811
|
-
* The key must be the module's path relative to the Vite root with POSIX
|
|
2812
|
-
* separators, because that is what the client manifest is keyed on.
|
|
2813
|
-
*/
|
|
2814
|
-
function ssrModuleRegistrationCode(filePath, root, helpers = {}, frameworkRoot) {
|
|
2815
|
-
const moduleId = JSON.stringify(frameworkRoot === void 0 ? toManifestModuleId(filePath, root) : path.relative(frameworkRoot, filePath).replace(/\\/g, "/"));
|
|
2816
|
-
const useSSRContext = helpers.useSSRContext ?? "__vize_useSSRContext";
|
|
2817
|
-
const sfcSetup = helpers.sfcSetup ?? "__vize_sfc_setup";
|
|
2818
|
-
return {
|
|
2819
|
-
prologue: `${REGISTRATION_MARKER}\nimport { useSSRContext as ${useSSRContext} } from "vue";`,
|
|
2820
|
-
epilogue: [
|
|
2821
|
-
`const ${sfcSetup} = _sfc_main.setup;`,
|
|
2822
|
-
`_sfc_main.setup = (props, ctx) => {`,
|
|
2823
|
-
` const ssrContext = ${useSSRContext}();`,
|
|
2824
|
-
` (ssrContext.modules || (ssrContext.modules = new Set())).add(${moduleId});`,
|
|
2825
|
-
` return ${sfcSetup} ? ${sfcSetup}(props, ctx) : undefined;`,
|
|
2826
|
-
`};`
|
|
2827
|
-
].join("\n")
|
|
2828
|
-
};
|
|
2829
|
-
}
|
|
2830
|
-
/**
|
|
2831
|
-
* The client-manifest key for `filePath`: relative to `root`, POSIX separators.
|
|
2832
|
-
*
|
|
2833
|
-
* A path outside the root keeps its absolute form rather than becoming a `../`
|
|
2834
|
-
* chain, matching how Vite keys modules it cannot root-relativize. Only a real
|
|
2835
|
-
* parent-directory step counts as outside: a filename that merely begins with
|
|
2836
|
-
* `..` still lives in the root and is keyed relative to it.
|
|
2837
|
-
*/
|
|
2838
|
-
function toManifestModuleId(filePath, root) {
|
|
2839
|
-
const relative = path.relative(root, filePath).replace(/\\/g, "/");
|
|
2840
|
-
if (!relative || relative === ".." || relative.startsWith("../") || path.isAbsolute(relative)) return filePath.replace(/\\/g, "/");
|
|
2841
|
-
return relative;
|
|
2842
|
-
}
|
|
2843
|
-
/**
|
|
2844
|
-
* Wrap an emitted module with the registration.
|
|
2845
|
-
*
|
|
2846
|
-
* The wrapper is appended, so it closes over whatever `setup` the emitter's own
|
|
2847
|
-
* rewrites left in place, but its `import` is *prepended*. A trailing `import`
|
|
2848
|
-
* is legal ESM, yet it makes the module's last import statement its last line,
|
|
2849
|
-
* and Nuxt's auto-import injection then inserts nothing — a component relying on
|
|
2850
|
-
* an auto-imported composable loses that binding and throws `ReferenceError` at
|
|
2851
|
-
* render time (#3868). Leading the module with the import keeps the import
|
|
2852
|
-
* section where every downstream transform expects to find it.
|
|
2853
|
-
*
|
|
2854
|
-
* `useSSRContext()` throws outside a render, so this is a no-op unless `isSsr`.
|
|
2855
|
-
* Modules without an `_sfc_main` declaration — a render-function-only output, or
|
|
2856
|
-
* a boundary placeholder — have no component object to wrap and are returned
|
|
2857
|
-
* untouched.
|
|
2858
|
-
*/
|
|
2859
|
-
function appendSsrModuleRegistration(code, filePath, root, isSsr, frameworkRoot) {
|
|
2860
|
-
if (!isSsr || !SFC_MAIN_DECLARATION.test(code)) return code;
|
|
2861
|
-
if (code.includes(REGISTRATION_MARKER)) return code;
|
|
2862
|
-
const { prologue, epilogue } = ssrModuleRegistrationCode(filePath, root, {
|
|
2863
|
-
useSSRContext: freeIdentifier("__vize_useSSRContext", code),
|
|
2864
|
-
sfcSetup: freeIdentifier("__vize_sfc_setup", code)
|
|
2865
|
-
}, frameworkRoot);
|
|
2866
|
-
return `${prologue}\n${code}\n${epilogue}`;
|
|
2867
|
-
}
|
|
2868
|
-
/**
|
|
2869
|
-
* `base`, or `base` plus the smallest numeric suffix the module does not use.
|
|
2870
|
-
*
|
|
2871
|
-
* Re-declaring an identifier the SFC already bound is a `SyntaxError`, which
|
|
2872
|
-
* would take down the whole module rather than just its stylesheet.
|
|
2873
|
-
*/
|
|
2874
|
-
function freeIdentifier(base, code) {
|
|
2875
|
-
if (!new RegExp(`\\b${base}\\b`).test(code)) return base;
|
|
2876
|
-
for (let suffix = 2;; suffix++) {
|
|
2877
|
-
const candidate = `${base}${suffix}`;
|
|
2878
|
-
if (!new RegExp(`\\b${candidate}\\b`).test(code)) return candidate;
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2881
|
-
/** Keep compiler/config root separate from Nuxt's source-relative manifest IDs. */
|
|
2882
|
-
function registerSfcModule(state, code, filePath, isSsr) {
|
|
2883
|
-
return appendSsrModuleRegistration(code, filePath, state.root, isSsr, state.mergedOptions.ssrModuleIdRoot);
|
|
2884
|
-
}
|
|
2885
|
-
//#endregion
|
|
2886
2902
|
//#region src/plugin/vite-transform.ts
|
|
2887
2903
|
function createVirtualTypeScriptTransformer(viteApi) {
|
|
2888
2904
|
return async (code, id) => {
|
|
@@ -3441,6 +3457,84 @@ async function handleHotUpdateEnvironmentHook(state, environment, options) {
|
|
|
3441
3457
|
return modules;
|
|
3442
3458
|
}
|
|
3443
3459
|
//#endregion
|
|
3460
|
+
//#region src/plugin/manifest.ts
|
|
3461
|
+
/** The query `toPluginVisibleVirtualId` gives a main SFC module. */
|
|
3462
|
+
const MAIN_SFC_QUERY = "?vue&vize";
|
|
3463
|
+
function sourceIdentity(key) {
|
|
3464
|
+
const query = key.indexOf("?");
|
|
3465
|
+
if (query < 0 || key.slice(query) !== MAIN_SFC_QUERY) return null;
|
|
3466
|
+
const source = key.slice(0, query);
|
|
3467
|
+
return source.endsWith(".vue") ? source : null;
|
|
3468
|
+
}
|
|
3469
|
+
/**
|
|
3470
|
+
* Key a Vite build manifest by SFC source path, as `@vitejs/plugin-vue` does.
|
|
3471
|
+
*
|
|
3472
|
+
* Vize's main SFC modules carry `?vue&vize`, so Vite keys their chunks
|
|
3473
|
+
* `pages/index.vue?vue&vize`. Servers that look up a route's CSS and preloads
|
|
3474
|
+
* by its source file (Void, Vite SSR setups) would miss them.
|
|
3475
|
+
*/
|
|
3476
|
+
function restoreManifestSourceIds(manifest) {
|
|
3477
|
+
const identities = /* @__PURE__ */ new Map();
|
|
3478
|
+
for (const [key, entry] of Object.entries(manifest)) {
|
|
3479
|
+
const source = sourceIdentity(key);
|
|
3480
|
+
if (!source || entry.src !== key || Object.hasOwn(manifest, source)) continue;
|
|
3481
|
+
identities.set(key, source);
|
|
3482
|
+
}
|
|
3483
|
+
if (identities.size === 0) return false;
|
|
3484
|
+
for (const [key, entry] of Object.entries(manifest)) {
|
|
3485
|
+
const source = identities.get(key);
|
|
3486
|
+
if (source) {
|
|
3487
|
+
delete manifest[key];
|
|
3488
|
+
manifest[source] = entry;
|
|
3489
|
+
entry.src = source;
|
|
3490
|
+
}
|
|
3491
|
+
for (const field of ["imports", "dynamicImports"]) {
|
|
3492
|
+
const references = entry[field];
|
|
3493
|
+
if (references?.some((reference) => identities.has(reference))) entry[field] = references.map((reference) => identities.get(reference) ?? reference);
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
return true;
|
|
3497
|
+
}
|
|
3498
|
+
/** Same for `build.ssrManifest`, whose keys are module IDs. */
|
|
3499
|
+
function restoreSsrManifestSourceIds(manifest) {
|
|
3500
|
+
let changed = false;
|
|
3501
|
+
for (const key of Object.keys(manifest)) {
|
|
3502
|
+
const source = sourceIdentity(key);
|
|
3503
|
+
if (!source || Object.hasOwn(manifest, source)) continue;
|
|
3504
|
+
manifest[source] = manifest[key];
|
|
3505
|
+
delete manifest[key];
|
|
3506
|
+
changed = true;
|
|
3507
|
+
}
|
|
3508
|
+
return changed;
|
|
3509
|
+
}
|
|
3510
|
+
function manifestFileName(option, fallback) {
|
|
3511
|
+
if (!option) return null;
|
|
3512
|
+
return typeof option === "string" ? option : fallback;
|
|
3513
|
+
}
|
|
3514
|
+
function rewriteAsset(bundle, fileName, restore) {
|
|
3515
|
+
const asset = fileName ? bundle[fileName] : void 0;
|
|
3516
|
+
if (asset?.type !== "asset" || asset.source === void 0) return;
|
|
3517
|
+
const text = typeof asset.source === "string" ? asset.source : new TextDecoder().decode(asset.source);
|
|
3518
|
+
const manifest = JSON.parse(text);
|
|
3519
|
+
if (restore(manifest)) asset.source = JSON.stringify(manifest, null, 2);
|
|
3520
|
+
}
|
|
3521
|
+
function createManifestPlugin() {
|
|
3522
|
+
return {
|
|
3523
|
+
name: "vite-plugin-vize:manifest",
|
|
3524
|
+
apply: "build",
|
|
3525
|
+
generateBundle: {
|
|
3526
|
+
order: "post",
|
|
3527
|
+
handler(_, bundle) {
|
|
3528
|
+
const build = this.environment?.config.build;
|
|
3529
|
+
if (!build) return;
|
|
3530
|
+
const assets = bundle;
|
|
3531
|
+
rewriteAsset(assets, manifestFileName(build.manifest, ".vite/manifest.json"), restoreManifestSourceIds);
|
|
3532
|
+
rewriteAsset(assets, manifestFileName(build.ssrManifest, ".vite/ssr-manifest.json"), restoreSsrManifestSourceIds);
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
};
|
|
3536
|
+
}
|
|
3537
|
+
//#endregion
|
|
3444
3538
|
//#region src/plugin/compat.ts
|
|
3445
3539
|
/**
|
|
3446
3540
|
* The `vite:vue` shim a host framework probes for a Vue plugin.
|
|
@@ -4334,6 +4428,8 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
|
|
|
4334
4428
|
const sharedConfigPromise = resolveSharedConfig(options, state.root, configEnv, state.logger, resolvedConfig, hostContext);
|
|
4335
4429
|
const sharedConfig = await register(resolvedConfig, state.root, sharedConfigPromise);
|
|
4336
4430
|
state.mergedOptions = mergeCompilerOptions(options, sharedConfig, compilerDefaults);
|
|
4431
|
+
const replaced = removeHostVueSfcCompilers(resolvedConfig.plugins, state.mergedOptions);
|
|
4432
|
+
if (replaced > 0) state.logger.log(`Replaced ${replaced} @vitejs/plugin-vue instance(s) with Vize.`);
|
|
4337
4433
|
state.fileCompilerOptions = createFileCompilerOptions(sharedConfig, state.root, options, compilerDefaults);
|
|
4338
4434
|
state.compilerScopeIdentity = sharedConfig?.entries;
|
|
4339
4435
|
state.dynamicImportAliasRules = [];
|
|
@@ -4426,7 +4522,8 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
|
|
|
4426
4522
|
}
|
|
4427
4523
|
},
|
|
4428
4524
|
createStylePostTransformPlugin(),
|
|
4429
|
-
createPostTransformPlugin(state)
|
|
4525
|
+
createPostTransformPlugin(state),
|
|
4526
|
+
...hostContext === "nuxt" ? [] : [createManifestPlugin()]
|
|
4430
4527
|
];
|
|
4431
4528
|
}
|
|
4432
4529
|
//#endregion
|
package/dist/vite-plus.mjs
CHANGED
|
@@ -303,10 +303,10 @@ function defineConfig(config = {}, integration = {}) {
|
|
|
303
303
|
const source = await resolveConfig(config, env);
|
|
304
304
|
const { vp, metadata, compiler } = normalizeConfig(source, integration);
|
|
305
305
|
const { options } = metadata;
|
|
306
|
-
const legacy = compiler !== false && (await import("./vue-version-
|
|
306
|
+
const legacy = compiler !== false && (await import("./vue-version-C75M7lgZ.mjs")).isLegacyVueCompatibilityMode(compiler);
|
|
307
307
|
const plugins = compiler === false || legacy ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
|
|
308
308
|
if (compiler !== false) {
|
|
309
|
-
const { vize } = await import("./plugin-
|
|
309
|
+
const { vize } = await import("./plugin-t5V0g-uQ.mjs");
|
|
310
310
|
plugins.push(vize({
|
|
311
311
|
...compiler,
|
|
312
312
|
configMode: false,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as isLegacyVueCompatibilityMode } from "./vue-version-
|
|
1
|
+
import { r as isLegacyVueCompatibilityMode } from "./vue-version-JgVRwvCy.mjs";
|
|
2
2
|
export { isLegacyVueCompatibilityMode };
|
|
@@ -71,5 +71,23 @@ function createLegacyVueCompatibilityPlugin(options) {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Remove `@vitejs/plugin-vue` instances that sit beside Vize, such as the one a
|
|
76
|
+
* framework adapter bundles (`@void/vue`'s `voidVue()`), so one compiler owns
|
|
77
|
+
* each `.vue` module. Vize's own `vite:vue` shim has no compiler hooks and stays.
|
|
78
|
+
* An explicit `exclude` keeps the host compiler for the SFCs Vize skips.
|
|
79
|
+
*/
|
|
80
|
+
function removeHostVueSfcCompilers(plugins, options) {
|
|
81
|
+
if (options.exclude !== void 0) return 0;
|
|
82
|
+
let removed = 0;
|
|
83
|
+
for (let index = plugins.length - 1; index >= 0; index--) {
|
|
84
|
+
const plugin = plugins[index];
|
|
85
|
+
if (plugin.name === "vite:vue" && (plugin.transform || plugin.load)) {
|
|
86
|
+
plugins.splice(index, 1);
|
|
87
|
+
removed++;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return removed;
|
|
91
|
+
}
|
|
74
92
|
//#endregion
|
|
75
|
-
export {
|
|
93
|
+
export { removeHostVueSfcCompilers as a, rewriteDynamicTemplateImports as c, shouldApplyDefineInVirtualModule as d, isLegacyVueVersion as i, rewriteImportMetaGlobBase as l, hasHostVueSfcCompilerPlugin as n, applyDefineReplacements as o, isLegacyVueCompatibilityMode as r, createLogger as s, createLegacyVueCompatibilityPlugin as t, rewriteStaticAssetUrls as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.483.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vizejs/native": "0.
|
|
55
|
-
"@vizejs/unplugin": "0.
|
|
54
|
+
"@vizejs/native": "0.483.0",
|
|
55
|
+
"@vizejs/unplugin": "0.483.0",
|
|
56
56
|
"jsonc-parser": "^3.3.1",
|
|
57
57
|
"oxc-parser": "0.144.0",
|
|
58
58
|
"picomatch": "4.0.5",
|
|
59
59
|
"tinyglobby": "0.2.17",
|
|
60
|
-
"vize": "0.
|
|
60
|
+
"vize": "0.483.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "25.9.2",
|
package/dist/plugin-C1ZHQliC.mjs
DELETED