@vizejs/vite-plugin 0.674.0 → 0.676.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.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/internal/config-bridge.d.mts +1 -1
- package/dist/plugin-CKHGV6Rv.mjs +2 -0
- package/dist/{plugin-NwXGnmXs.mjs → plugin-DzHoecVf.mjs} +197 -98
- package/dist/{types-ChOAu19s.d.mts → types-BaSwgC_i.d.mts} +5 -0
- package/dist/vite-plus.d.mts +1 -1
- package/dist/vite-plus.mjs +2 -2
- package/dist/{vue-version-BFh0eI6J.mjs → vue-version-B0qUneRk.mjs} +13 -2
- package/dist/{vue-version-DOjZaMiI.mjs → vue-version-DL5NF2G-.mjs} +1 -1
- package/package.json +4 -4
- package/dist/plugin-Bmz-K8re.mjs +0 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as VizeInspectorLintPlanProvider, b as VizeConfig, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, h as VueOptionsEntry, i as VizeVueFeatures, l as VizeVueVersion, m as VueOptions, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-
|
|
1
|
+
import { a as VizeInspectorLintPlanProvider, b as VizeConfig, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, h as VueOptionsEntry, i as VizeVueFeatures, l as VizeVueVersion, m as VueOptions, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-BaSwgC_i.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/compiler-config.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as vize } from "./plugin-
|
|
2
|
-
import { u as rewriteStaticAssetUrls } from "./vue-version-
|
|
1
|
+
import { t as vize } from "./plugin-DzHoecVf.mjs";
|
|
2
|
+
import { u as rewriteStaticAssetUrls } from "./vue-version-B0qUneRk.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-LlMZcDZI.mjs";
|
|
4
4
|
//#region src/index.ts
|
|
5
5
|
const __internal = { rewriteStaticAssetUrls };
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-B0qUneRk.mjs";
|
|
2
2
|
import { a as resolveViteConfigExport, i as resolveConfigExport, o as vizeConfigStore, r as loadConfig } from "./config-LlMZcDZI.mjs";
|
|
3
3
|
import { n as registerResolvedVizeConfig, r as unregisterResolvedVizeConfig } from "./config-bridge-Dv6U7_RC.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
@@ -361,6 +361,49 @@ var MappedModule = class {
|
|
|
361
361
|
this.edit(`${this.code.slice(0, start)}${text}${this.code.slice(end)}`);
|
|
362
362
|
}
|
|
363
363
|
};
|
|
364
|
+
const BASE64_DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
365
|
+
function vlq(value) {
|
|
366
|
+
let rest = value < 0 ? -value << 1 | 1 : value << 1;
|
|
367
|
+
let encoded = "";
|
|
368
|
+
do {
|
|
369
|
+
const digit = rest & 31;
|
|
370
|
+
rest >>>= 5;
|
|
371
|
+
encoded += BASE64_DIGITS[rest > 0 ? digit | 32 : digit];
|
|
372
|
+
} while (rest > 0);
|
|
373
|
+
return encoded;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* The map of a module whose code is `source` as written in `file`.
|
|
377
|
+
*
|
|
378
|
+
* A bundler names a module's original after its id unless `load` supplies a
|
|
379
|
+
* map, and a Vize SFC id carries a query. A segment at every non-blank column
|
|
380
|
+
* keeps each position a later map traces through it exact.
|
|
381
|
+
*/
|
|
382
|
+
function identitySourceMap(file, source) {
|
|
383
|
+
const lines = [];
|
|
384
|
+
let previousLine = 0;
|
|
385
|
+
let previousColumn = 0;
|
|
386
|
+
for (const [line, text] of source.split("\n").entries()) {
|
|
387
|
+
let segments = "";
|
|
388
|
+
let generatedColumn = 0;
|
|
389
|
+
for (let column = 0; column < text.length; column++) {
|
|
390
|
+
const code = text.charCodeAt(column);
|
|
391
|
+
if (code === 32 || code === 9 || code === 13) continue;
|
|
392
|
+
segments += `${segments ? "," : ""}${vlq(column - generatedColumn)}A${vlq(line - previousLine)}${vlq(column - previousColumn)}`;
|
|
393
|
+
generatedColumn = column;
|
|
394
|
+
previousLine = line;
|
|
395
|
+
previousColumn = column;
|
|
396
|
+
}
|
|
397
|
+
lines.push(segments);
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
version: 3,
|
|
401
|
+
sources: [file],
|
|
402
|
+
sourcesContent: [source],
|
|
403
|
+
names: [],
|
|
404
|
+
mappings: lines.join(";")
|
|
405
|
+
};
|
|
406
|
+
}
|
|
364
407
|
//#endregion
|
|
365
408
|
//#region src/utils/component-output.ts
|
|
366
409
|
/** Assemble the compiler's component export before CSS and HMR decoration. */
|
|
@@ -1366,6 +1409,7 @@ function compileFile(filePath, cache, options, source, diagnostics) {
|
|
|
1366
1409
|
console.warn(`[vize] Warning in ${filePath}: ${warning}`);
|
|
1367
1410
|
});
|
|
1368
1411
|
const compiled = {
|
|
1412
|
+
source: content,
|
|
1369
1413
|
code: result.code,
|
|
1370
1414
|
...result.map ? { map: result.map } : {},
|
|
1371
1415
|
css: result.css,
|
|
@@ -1457,6 +1501,7 @@ function compileBatch(files, cache, options) {
|
|
|
1457
1501
|
}
|
|
1458
1502
|
for (const fileResult of result.results) {
|
|
1459
1503
|
if (fileResult.errors.length === 0) cache.set(fileResult.path, {
|
|
1504
|
+
source: filesByPath.get(fileResult.path)?.source,
|
|
1460
1505
|
code: fileResult.code,
|
|
1461
1506
|
...fileResult.map ? { map: fileResult.map } : {},
|
|
1462
1507
|
css: fileResult.css,
|
|
@@ -1619,7 +1664,7 @@ function decompressBody(codec, body) {
|
|
|
1619
1664
|
}
|
|
1620
1665
|
/** `<meta JSON>\n<code><css>\n` -- the trailing LF marks the record boundary. */
|
|
1621
1666
|
function encodeRecord(module) {
|
|
1622
|
-
const { code, css, ...rest } = module;
|
|
1667
|
+
const { code, css, source: _source, ...rest } = module;
|
|
1623
1668
|
const codeBytes = Buffer.from(code, "utf8");
|
|
1624
1669
|
const cssBytes = css === void 0 ? null : Buffer.from(css, "utf8");
|
|
1625
1670
|
const meta = Buffer.from(JSON.stringify([
|
|
@@ -1953,31 +1998,6 @@ function compileScopedBatch(files, state) {
|
|
|
1953
1998
|
};
|
|
1954
1999
|
}
|
|
1955
2000
|
//#endregion
|
|
1956
|
-
//#region src/plugin/load-sfc.ts
|
|
1957
|
-
function shouldLoadVueSfcRequest(request) {
|
|
1958
|
-
if (!request.isVueSfcPath || request.isVueStyleQuery || request.hasMacroQuery || request.hasDefinePageQuery) return false;
|
|
1959
|
-
if (!request.querySuffix) return true;
|
|
1960
|
-
const params = new URLSearchParams(request.querySuffix.slice(1));
|
|
1961
|
-
if (params.has("raw") || params.has("url") || params.has("worker") || params.has("sharedworker")) return false;
|
|
1962
|
-
return params.has("nuxt_component");
|
|
1963
|
-
}
|
|
1964
|
-
function getLoadableVueSfcPath(request) {
|
|
1965
|
-
if (!shouldLoadVueSfcRequest(request)) return null;
|
|
1966
|
-
return classifyVitePluginRequest(request.normalizedFsId ?? request.path).normalizedVuePath;
|
|
1967
|
-
}
|
|
1968
|
-
function shouldLoadCompiledVueSfcPath(state, realPath, hasNuxtComponentQuery = false) {
|
|
1969
|
-
const isNodeModulesPath = realPath.includes("node_modules");
|
|
1970
|
-
if (!(state.mergedOptions.handleNodeModulesVue ?? true) && isNodeModulesPath && hasNuxtComponentQuery) {
|
|
1971
|
-
state.logger.log(`load: skipping node_modules Vue SFC ${realPath}`);
|
|
1972
|
-
return false;
|
|
1973
|
-
}
|
|
1974
|
-
if (!isNodeModulesPath && !state.filter(realPath)) {
|
|
1975
|
-
state.logger.log(`load: skipping filtered Vue SFC ${realPath}`);
|
|
1976
|
-
return false;
|
|
1977
|
-
}
|
|
1978
|
-
return true;
|
|
1979
|
-
}
|
|
1980
|
-
//#endregion
|
|
1981
2001
|
//#region src/plugin/src-requests.ts
|
|
1982
2002
|
/**
|
|
1983
2003
|
* Resolve one SFC's `src` module requests before the synchronous compile reads
|
|
@@ -1991,22 +2011,6 @@ async function prepareSfcSrcRequests(state, resolve, file, source) {
|
|
|
1991
2011
|
}
|
|
1992
2012
|
(state.srcResolutions ??= /* @__PURE__ */ new Map()).set(file, await resolveSfcSrcRequests(file, requests, resolve));
|
|
1993
2013
|
}
|
|
1994
|
-
/**
|
|
1995
|
-
* A `load` that compiles its SFC on demand resolves the SFC's requests first.
|
|
1996
|
-
* It returns the source it read, so that compile does not read the file again.
|
|
1997
|
-
*/
|
|
1998
|
-
async function prepareLoadSrcRequests(state, resolve, id) {
|
|
1999
|
-
if (!id.includes(".vue")) return void 0;
|
|
2000
|
-
const request = classifyVitePluginRequest(id);
|
|
2001
|
-
const file = request.vizeVirtualPath ?? fromPluginVisibleVirtualId(id) ?? getLoadableVueSfcPath(request);
|
|
2002
|
-
if (!file?.endsWith(".vue") || state.cache.has(file) || state.ssrCache.has(file) || state.srcResolutions?.has(file) || !fs.existsSync(file)) return;
|
|
2003
|
-
const source = fs.readFileSync(file, "utf-8");
|
|
2004
|
-
await prepareSfcSrcRequests(state, resolve, file, source);
|
|
2005
|
-
return {
|
|
2006
|
-
file,
|
|
2007
|
-
source
|
|
2008
|
-
};
|
|
2009
|
-
}
|
|
2010
2014
|
//#endregion
|
|
2011
2015
|
//#region src/plugin/precompile-run.ts
|
|
2012
2016
|
/**
|
|
@@ -2120,8 +2124,12 @@ async function compileAll(state, owners = [], resolve) {
|
|
|
2120
2124
|
continue;
|
|
2121
2125
|
}
|
|
2122
2126
|
const sourceHash = cacheEnabled ? hashPrecompileSource(source) : void 0;
|
|
2123
|
-
const
|
|
2124
|
-
if (
|
|
2127
|
+
const stored = sourceHash === void 0 ? void 0 : cache.get(file, sourceHash);
|
|
2128
|
+
if (stored) {
|
|
2129
|
+
const restored = {
|
|
2130
|
+
...stored,
|
|
2131
|
+
source
|
|
2132
|
+
};
|
|
2125
2133
|
state.cache.set(file, restored);
|
|
2126
2134
|
const metadata = currentMetadata.get(file);
|
|
2127
2135
|
if (metadata) state.precompileMetadata.set(file, metadata);
|
|
@@ -3211,6 +3219,31 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
3211
3219
|
return null;
|
|
3212
3220
|
}
|
|
3213
3221
|
//#endregion
|
|
3222
|
+
//#region src/plugin/load-sfc.ts
|
|
3223
|
+
function shouldLoadVueSfcRequest(request) {
|
|
3224
|
+
if (!request.isVueSfcPath || request.isVueStyleQuery || request.hasMacroQuery || request.hasDefinePageQuery) return false;
|
|
3225
|
+
if (!request.querySuffix) return true;
|
|
3226
|
+
const params = new URLSearchParams(request.querySuffix.slice(1));
|
|
3227
|
+
if (params.has("raw") || params.has("url") || params.has("worker") || params.has("sharedworker")) return false;
|
|
3228
|
+
return params.has("nuxt_component");
|
|
3229
|
+
}
|
|
3230
|
+
function getLoadableVueSfcPath(request) {
|
|
3231
|
+
if (!shouldLoadVueSfcRequest(request)) return null;
|
|
3232
|
+
return classifyVitePluginRequest(request.normalizedFsId ?? request.path).normalizedVuePath;
|
|
3233
|
+
}
|
|
3234
|
+
function shouldLoadCompiledVueSfcPath(state, realPath, hasNuxtComponentQuery = false) {
|
|
3235
|
+
const isNodeModulesPath = realPath.includes("node_modules");
|
|
3236
|
+
if (!(state.mergedOptions.handleNodeModulesVue ?? true) && isNodeModulesPath && hasNuxtComponentQuery) {
|
|
3237
|
+
state.logger.log(`load: skipping node_modules Vue SFC ${realPath}`);
|
|
3238
|
+
return false;
|
|
3239
|
+
}
|
|
3240
|
+
if (!isNodeModulesPath && !state.filter(realPath)) {
|
|
3241
|
+
state.logger.log(`load: skipping filtered Vue SFC ${realPath}`);
|
|
3242
|
+
return false;
|
|
3243
|
+
}
|
|
3244
|
+
return true;
|
|
3245
|
+
}
|
|
3246
|
+
//#endregion
|
|
3214
3247
|
//#region src/plugin/vite-transform.ts
|
|
3215
3248
|
function createVirtualTypeScriptTransformer(viteApi) {
|
|
3216
3249
|
return async (code, id) => {
|
|
@@ -3283,7 +3316,13 @@ function getVirtualStyleContent(block, options) {
|
|
|
3283
3316
|
return transformCssVarsForPipeline(styleContent, options.scopeId, options.productionFilename);
|
|
3284
3317
|
}
|
|
3285
3318
|
//#endregion
|
|
3286
|
-
//#region src/plugin/
|
|
3319
|
+
//#region src/plugin/sfc-module.ts
|
|
3320
|
+
/**
|
|
3321
|
+
* The SFC main module: `load` serves the SFC text and `transform` compiles the
|
|
3322
|
+
* text the pipeline delivers, at @vitejs/plugin-vue's position. Host transforms
|
|
3323
|
+
* ordered before the compiler (Nuxt's `<DevOnly>` strip, #11641) therefore
|
|
3324
|
+
* reach the source, and those after it see the compiled module.
|
|
3325
|
+
*/
|
|
3287
3326
|
const SERVER_PLACEHOLDER_CODE = `import { createElementBlock, defineComponent } from "vue";
|
|
3288
3327
|
export default defineComponent({
|
|
3289
3328
|
name: "ServerPlaceholder",
|
|
@@ -3298,51 +3337,92 @@ function getBoundaryPlaceholderCode(realPath, ssr) {
|
|
|
3298
3337
|
if (!ssr && boundaryKind === "server") return SERVER_PLACEHOLDER_CODE;
|
|
3299
3338
|
return null;
|
|
3300
3339
|
}
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3340
|
+
/** The SFC an id compiles as a whole component, or `null` for any other request. */
|
|
3341
|
+
function getSfcModuleRequest(state, id) {
|
|
3342
|
+
if (!id.includes(".vue")) return null;
|
|
3343
|
+
if (classifyVitePluginRequest(normalizeStyleVirtualId(id)).isVueStyleQuery) return null;
|
|
3344
|
+
const request = classifyVitePluginRequest(id);
|
|
3345
|
+
const nullPrefixed = id.startsWith("\0");
|
|
3346
|
+
if (nullPrefixed && request.isVueSfcPath && (request.hasDefinePageQuery || request.hasMacroQuery)) return null;
|
|
3347
|
+
const visiblePath = fromPluginVisibleVirtualId(id);
|
|
3348
|
+
if (request.isVizeVirtual || visiblePath) {
|
|
3349
|
+
const realPath = request.vizeVirtualPath ?? visiblePath ?? "";
|
|
3350
|
+
if (!realPath.endsWith(".vue") || !shouldLoadCompiledVueSfcPath(state, realPath)) return null;
|
|
3351
|
+
return {
|
|
3352
|
+
realPath,
|
|
3353
|
+
ssrId: request.isVizeSsrVirtual || isPluginVisibleSsrVirtualId(id),
|
|
3354
|
+
virtual: true,
|
|
3355
|
+
nullPrefixed
|
|
3356
|
+
};
|
|
3309
3357
|
}
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3358
|
+
const realPath = getLoadableVueSfcPath(request);
|
|
3359
|
+
if (!realPath) return null;
|
|
3360
|
+
if (!shouldLoadCompiledVueSfcPath(state, realPath, !!request.querySuffix && new URLSearchParams(request.querySuffix.slice(1)).has("nuxt_component"))) return null;
|
|
3361
|
+
return {
|
|
3362
|
+
realPath,
|
|
3363
|
+
ssrId: false,
|
|
3364
|
+
virtual: false,
|
|
3365
|
+
nullPrefixed
|
|
3366
|
+
};
|
|
3315
3367
|
}
|
|
3316
|
-
|
|
3317
|
-
|
|
3368
|
+
/**
|
|
3369
|
+
* The SFC text a main module request starts the pipeline with, mapped to its
|
|
3370
|
+
* file when the compile emits a map.
|
|
3371
|
+
*/
|
|
3372
|
+
function loadSfcModuleSource(state, sfc, ssr) {
|
|
3373
|
+
let source;
|
|
3374
|
+
try {
|
|
3375
|
+
source = fs.readFileSync(sfc.realPath, "utf-8");
|
|
3376
|
+
} catch (error) {
|
|
3377
|
+
if (error.code === "ENOENT") return null;
|
|
3378
|
+
throw error;
|
|
3379
|
+
}
|
|
3380
|
+
if (!getCompileOptionsForRequest(state, sfc.ssrId || ssr, sfc.realPath).sourceMap) return source;
|
|
3381
|
+
return {
|
|
3382
|
+
code: source,
|
|
3383
|
+
map: identitySourceMap(sfc.realPath, source)
|
|
3384
|
+
};
|
|
3385
|
+
}
|
|
3386
|
+
function shouldLogSfcWarnings(state, realPath) {
|
|
3387
|
+
if (!realPath.includes("node_modules")) return true;
|
|
3388
|
+
if ((state.mergedOptions.handleNodeModulesVue ?? true) === false) return false;
|
|
3389
|
+
return state.filter(realPath);
|
|
3390
|
+
}
|
|
3391
|
+
/** Compile the SFC text `code` that the pipeline delivered for `sfc`. */
|
|
3392
|
+
async function transformSfcModule(state, code, sfc, options = {}) {
|
|
3393
|
+
const { realPath } = sfc;
|
|
3394
|
+
const environmentSsr = !!options.ssr;
|
|
3395
|
+
const placeholderCode = getBoundaryPlaceholderCode(realPath, environmentSsr);
|
|
3318
3396
|
if (placeholderCode) {
|
|
3319
|
-
state.logger.log(`
|
|
3397
|
+
state.logger.log(`transform: using boundary placeholder for ${realPath}`);
|
|
3320
3398
|
return {
|
|
3321
3399
|
code: placeholderCode,
|
|
3322
3400
|
map: null
|
|
3323
3401
|
};
|
|
3324
3402
|
}
|
|
3403
|
+
const isSsr = sfc.ssrId || environmentSsr;
|
|
3404
|
+
const currentBase = environmentSsr ? state.serverViteBase : state.clientViteBase;
|
|
3325
3405
|
const cache = getEnvironmentCache(state, isSsr);
|
|
3326
3406
|
const customElement = isPluginVueCustomElement(state.mergedOptions, realPath);
|
|
3327
3407
|
const extractCss = shouldExtractCssForRequest(state, isSsr) && !customElement;
|
|
3328
3408
|
let compiled = cache.get(realPath);
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
compiled = compileFile(realPath, cache, getCompileOptionsForRequest(state, isSsr, realPath),
|
|
3409
|
+
if (compiled?.source !== code) {
|
|
3410
|
+
state.logger.log(`transform: compiling ${realPath}`);
|
|
3411
|
+
if (options.resolve) await prepareSfcSrcRequests(state, options.resolve, realPath, code);
|
|
3412
|
+
compiled = compileFile(realPath, cache, getCompileOptionsForRequest(state, isSsr, realPath), code, { logWarnings: shouldLogSfcWarnings(state, realPath) });
|
|
3333
3413
|
}
|
|
3334
3414
|
syncCollectedCssForFile({
|
|
3335
3415
|
...state,
|
|
3336
3416
|
extractCss
|
|
3337
3417
|
}, realPath, compiled);
|
|
3338
|
-
|
|
3339
|
-
for (const watchFile of new Set([realPath, ...
|
|
3418
|
+
const dependencies = compiled.dependencies ?? [];
|
|
3419
|
+
for (const watchFile of new Set(sfc.nullPrefixed ? [realPath, ...dependencies] : dependencies)) options.addWatchFile?.(watchFile);
|
|
3340
3420
|
const hasDelegated = hasDelegatedStyles(compiled);
|
|
3341
3421
|
const outputOptions = {
|
|
3342
3422
|
isProduction: state.isProduction,
|
|
3343
3423
|
isDev: state.server !== null && !isSsr,
|
|
3344
3424
|
ssr: isSsr,
|
|
3345
|
-
hmrUpdateType:
|
|
3425
|
+
hmrUpdateType: environmentSsr ? void 0 : state.pendingHmrUpdateTypes.get(realPath),
|
|
3346
3426
|
extractCss,
|
|
3347
3427
|
customElement,
|
|
3348
3428
|
filePath: realPath,
|
|
@@ -3356,9 +3436,32 @@ function loadCompiledSfcModule(state, realPath, isSsr, currentBase, needsGlobBas
|
|
|
3356
3436
|
const rewritten = new MappedModule(isSsr ? normalizeVueServerRendererImport(emitted.code) : emitted.code, emitted.map);
|
|
3357
3437
|
rewritten.edit(rewriteDynamicTemplateImports(rewritten.code, state.dynamicImportAliasRules));
|
|
3358
3438
|
rewritten.edit(rewriteStaticAssetUrls(rewritten.code, state.dynamicImportAliasRules));
|
|
3359
|
-
if (
|
|
3439
|
+
if (sfc.nullPrefixed) rewritten.edit(rewriteImportMetaGlobBase(rewritten.code, realPath, state.root));
|
|
3360
3440
|
rewritten.edit(registerSfcModule(state, rewritten.code, realPath, isSsr));
|
|
3361
|
-
|
|
3441
|
+
const result = loadedSfcModule(rewritten.code, rewritten.map, state.isProduction, isSsr, compiled);
|
|
3442
|
+
if (!sfc.virtual) return result;
|
|
3443
|
+
const defined = await transformVizeVirtualModule(state, result.code, realPath, environmentSsr);
|
|
3444
|
+
return defined ? {
|
|
3445
|
+
...result,
|
|
3446
|
+
code: defined.code
|
|
3447
|
+
} : result;
|
|
3448
|
+
}
|
|
3449
|
+
//#endregion
|
|
3450
|
+
//#region src/plugin/load.ts
|
|
3451
|
+
function findMacroArtifactModule(state, realPath, ssr, kind) {
|
|
3452
|
+
const cache = getEnvironmentCache(state, ssr);
|
|
3453
|
+
const extractCss = shouldExtractCssForRequest(state, ssr);
|
|
3454
|
+
realPath = classifyVitePluginRequest(realPath).normalizedVuePath;
|
|
3455
|
+
let compiled = cache.get(realPath) ?? state.cache.get(realPath) ?? state.ssrCache.get(realPath);
|
|
3456
|
+
if (!compiled && fs.existsSync(realPath)) {
|
|
3457
|
+
const source = fs.readFileSync(realPath, "utf-8");
|
|
3458
|
+
compiled = compileFile(realPath, cache, getCompileOptionsForRequest(state, ssr, realPath), source);
|
|
3459
|
+
}
|
|
3460
|
+
syncCollectedCssForFile({
|
|
3461
|
+
...state,
|
|
3462
|
+
extractCss
|
|
3463
|
+
}, realPath, compiled);
|
|
3464
|
+
return compiled?.macroArtifacts?.find((artifact) => artifact.kind === kind)?.moduleCode ?? null;
|
|
3362
3465
|
}
|
|
3363
3466
|
function loadDefinePageArtifact(state, realPath, ssr) {
|
|
3364
3467
|
return {
|
|
@@ -3430,19 +3533,9 @@ function loadHook(state, id, loadOptions) {
|
|
|
3430
3533
|
};
|
|
3431
3534
|
}
|
|
3432
3535
|
}
|
|
3433
|
-
if (request.isVizeVirtual || pluginVisibleVirtualPath) {
|
|
3434
|
-
const
|
|
3435
|
-
|
|
3436
|
-
if (!realPath.endsWith(".vue")) {
|
|
3437
|
-
state.logger.log(`load: skipping non-vue virtual module ${realPath}`);
|
|
3438
|
-
return null;
|
|
3439
|
-
}
|
|
3440
|
-
if (!shouldLoadCompiledVueSfcPath(state, realPath)) return null;
|
|
3441
|
-
return loadCompiledSfcModule(state, realPath, isSsr, currentBase, id.startsWith("\0"), loadOptions);
|
|
3442
|
-
}
|
|
3443
|
-
if (loadableVueSfcPath) {
|
|
3444
|
-
if (!shouldLoadCompiledVueSfcPath(state, loadableVueSfcPath, !!request.querySuffix && new URLSearchParams(request.querySuffix.slice(1)).has("nuxt_component"))) return null;
|
|
3445
|
-
return loadCompiledSfcModule(state, loadableVueSfcPath, !!loadOptions?.ssr, currentBase, false, loadOptions);
|
|
3536
|
+
if (request.isVizeVirtual || pluginVisibleVirtualPath || loadableVueSfcPath) {
|
|
3537
|
+
const sfc = getSfcModuleRequest(state, id);
|
|
3538
|
+
return sfc ? loadSfcModuleSource(state, sfc, !!loadOptions?.ssr) : null;
|
|
3446
3539
|
}
|
|
3447
3540
|
if (id.startsWith("\0")) {
|
|
3448
3541
|
const afterPrefix = id.startsWith("\0vize:") ? id.slice(6) : id.slice(1);
|
|
@@ -3458,11 +3551,6 @@ function loadHook(state, id, loadOptions) {
|
|
|
3458
3551
|
}
|
|
3459
3552
|
return null;
|
|
3460
3553
|
}
|
|
3461
|
-
function shouldLogSfcWarnings(state, realPath) {
|
|
3462
|
-
if (!realPath.includes("node_modules")) return true;
|
|
3463
|
-
if ((state.mergedOptions.handleNodeModulesVue ?? true) === false) return false;
|
|
3464
|
-
return state.filter(realPath);
|
|
3465
|
-
}
|
|
3466
3554
|
function isJsxComponentPath(path) {
|
|
3467
3555
|
return /\.[jt]sx$/.test(path) && !/\.(?:stories|story)\.[jt]sx$/.test(path);
|
|
3468
3556
|
}
|
|
@@ -3508,6 +3596,7 @@ async function transformHook(state, code, id, options) {
|
|
|
3508
3596
|
if (jsxResult !== void 0) return jsxResult;
|
|
3509
3597
|
if (!id.startsWith("\0") && !pluginVisibleVirtualPath) return null;
|
|
3510
3598
|
const request = classifyVitePluginRequest(id);
|
|
3599
|
+
if (!request.isMacroVirtualId && getSfcModuleRequest(state, id)) return null;
|
|
3511
3600
|
if (request.isVizeVirtual || request.isMacroVirtualId || pluginVisibleVirtualPath) return transformVizeVirtualModule(state, code, request.isMacroVirtualId ? request.strippedVirtualPath ?? "" : request.vizeVirtualPath ?? pluginVisibleVirtualPath ?? "", options?.ssr ?? false, request.isMacroVirtualId);
|
|
3512
3601
|
return null;
|
|
3513
3602
|
}
|
|
@@ -4745,6 +4834,21 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
|
|
|
4745
4834
|
serverViteDefine: {},
|
|
4746
4835
|
logger: createLogger(options.debug ?? false)
|
|
4747
4836
|
};
|
|
4837
|
+
const sfcPlugin = {
|
|
4838
|
+
name: "vite-plugin-vize:sfc",
|
|
4839
|
+
transform: {
|
|
4840
|
+
filter: { id: /\.vue/ },
|
|
4841
|
+
async handler(code, id, transformOptions) {
|
|
4842
|
+
const sfc = getSfcModuleRequest(state, id);
|
|
4843
|
+
if (!sfc) return null;
|
|
4844
|
+
return transformSfcModule(state, code, sfc, {
|
|
4845
|
+
ssr: resolveHookSsr(this, transformOptions),
|
|
4846
|
+
addWatchFile: this.addWatchFile.bind(this),
|
|
4847
|
+
resolve: (request, importer) => this.resolve(request, importer, { skipSelf: true })
|
|
4848
|
+
});
|
|
4849
|
+
}
|
|
4850
|
+
}
|
|
4851
|
+
};
|
|
4748
4852
|
return [
|
|
4749
4853
|
createVueCompatPlugin(state, options),
|
|
4750
4854
|
{
|
|
@@ -4786,7 +4890,7 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
|
|
|
4786
4890
|
const sharedConfigPromise = resolveSharedConfig(options, state.root, configEnv, state.logger, resolvedConfig, hostContext);
|
|
4787
4891
|
const sharedConfig = await register(resolvedConfig, state.root, sharedConfigPromise);
|
|
4788
4892
|
state.mergedOptions = mergeCompilerOptions(options, sharedConfig, compilerDefaults);
|
|
4789
|
-
const replaced = removeHostVueSfcCompilers(resolvedConfig.plugins, state.mergedOptions);
|
|
4893
|
+
const replaced = removeHostVueSfcCompilers(resolvedConfig.plugins, state.mergedOptions, sfcPlugin);
|
|
4790
4894
|
if (replaced > 0) state.logger.log(`Replaced ${replaced} @vitejs/plugin-vue instance(s) with Vize.`);
|
|
4791
4895
|
state.fileCompilerOptions = createFileCompilerOptions(sharedConfig, state.root, options, compilerDefaults);
|
|
4792
4896
|
state.compilerScopeIdentity = sharedConfig?.entries;
|
|
@@ -4849,14 +4953,8 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
|
|
|
4849
4953
|
ssr: resolveHookSsr(this, options)
|
|
4850
4954
|
});
|
|
4851
4955
|
},
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
return loadHook(state, id, {
|
|
4855
|
-
...loadOptions,
|
|
4856
|
-
ssr: resolveHookSsr(this, loadOptions),
|
|
4857
|
-
addWatchFile: this.addWatchFile.bind(this),
|
|
4858
|
-
sfcSource
|
|
4859
|
-
});
|
|
4956
|
+
load(id, loadOptions) {
|
|
4957
|
+
return loadHook(state, id, { ssr: resolveHookSsr(this, loadOptions) });
|
|
4860
4958
|
},
|
|
4861
4959
|
async transform(code, id, transformOptions) {
|
|
4862
4960
|
return transformHook(state, code, id, {
|
|
@@ -4887,6 +4985,7 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
|
|
|
4887
4985
|
}
|
|
4888
4986
|
}
|
|
4889
4987
|
},
|
|
4988
|
+
sfcPlugin,
|
|
4890
4989
|
createStylePostTransformPlugin(),
|
|
4891
4990
|
createPostTransformPlugin(state),
|
|
4892
4991
|
...hostContext === "nuxt" ? [] : [createManifestPlugin()]
|
|
@@ -1175,6 +1175,11 @@ interface StyleBlockInfo {
|
|
|
1175
1175
|
index: number;
|
|
1176
1176
|
}
|
|
1177
1177
|
interface CompiledModule {
|
|
1178
|
+
/**
|
|
1179
|
+
* The SFC text this module was compiled from. A module answers only for this
|
|
1180
|
+
* text; the pre-compile cache stores its hash instead.
|
|
1181
|
+
*/
|
|
1182
|
+
source?: string;
|
|
1178
1183
|
code: string;
|
|
1179
1184
|
/**
|
|
1180
1185
|
* Source Map v3 document (JSON) describing `code`, when the compiler was
|
package/dist/vite-plus.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-
|
|
1
|
+
import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-BaSwgC_i.mjs";
|
|
2
2
|
import { ConfigEnv, UserConfig, defineConfig as defineConfig$1 } from "vite-plus";
|
|
3
3
|
|
|
4
4
|
//#region src/vite-plus/types.d.ts
|
package/dist/vite-plus.mjs
CHANGED
|
@@ -397,10 +397,10 @@ function defineConfig(config = {}, integration = {}) {
|
|
|
397
397
|
const source = await resolveConfig(config, env);
|
|
398
398
|
const { vp, metadata, compiler, plugin } = normalizeConfig(source, integration);
|
|
399
399
|
const { options } = metadata;
|
|
400
|
-
const legacy = compiler !== false && (await import("./vue-version-
|
|
400
|
+
const legacy = compiler !== false && (await import("./vue-version-DL5NF2G-.mjs")).isLegacyVueCompatibilityMode(compiler);
|
|
401
401
|
const plugins = compiler === false || legacy ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
|
|
402
402
|
if (compiler !== false) {
|
|
403
|
-
const { vize } = await import("./plugin-
|
|
403
|
+
const { vize } = await import("./plugin-CKHGV6Rv.mjs");
|
|
404
404
|
plugins.push(vize({
|
|
405
405
|
...plugin,
|
|
406
406
|
configMode: false,
|
|
@@ -71,18 +71,29 @@ function createLegacyVueCompatibilityPlugin(options) {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
+
function isHostVueSfcCompiler(plugin) {
|
|
75
|
+
return plugin.name === "vite:vue" && !!(plugin.transform || plugin.load);
|
|
76
|
+
}
|
|
74
77
|
/**
|
|
75
78
|
* Remove `@vitejs/plugin-vue` instances that sit beside Vize, such as the one a
|
|
76
79
|
* framework adapter bundles (`@void/vue`'s `voidVue()`), so one compiler owns
|
|
77
80
|
* each `.vue` module. Vize's own `vite:vue` shim has no compiler hooks and stays.
|
|
78
81
|
* An explicit `exclude` keeps the host compiler for the SFCs Vize skips.
|
|
82
|
+
* Vize's `compileStage` takes the first host compiler's place, so the host's
|
|
83
|
+
* transforms keep their order around the compiler.
|
|
79
84
|
*/
|
|
80
|
-
function removeHostVueSfcCompilers(plugins, options) {
|
|
85
|
+
function removeHostVueSfcCompilers(plugins, options, compileStage) {
|
|
86
|
+
const host = plugins.find(isHostVueSfcCompiler);
|
|
87
|
+
const own = compileStage ? plugins.indexOf(compileStage) : -1;
|
|
88
|
+
if (host && own !== -1) {
|
|
89
|
+
plugins.splice(own, 1);
|
|
90
|
+
plugins.splice(plugins.indexOf(host), 0, compileStage);
|
|
91
|
+
}
|
|
81
92
|
if (options.exclude !== void 0) return 0;
|
|
82
93
|
let removed = 0;
|
|
83
94
|
for (let index = plugins.length - 1; index >= 0; index--) {
|
|
84
95
|
const plugin = plugins[index];
|
|
85
|
-
if (
|
|
96
|
+
if (isHostVueSfcCompiler(plugin)) {
|
|
86
97
|
plugins.splice(index, 1);
|
|
87
98
|
removed++;
|
|
88
99
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as isLegacyVueCompatibilityMode } from "./vue-version-
|
|
1
|
+
import { r as isLegacyVueCompatibilityMode } from "./vue-version-B0qUneRk.mjs";
|
|
2
2
|
export { isLegacyVueCompatibilityMode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.676.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.676.0",
|
|
55
|
+
"@vizejs/unplugin": "0.676.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.676.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "25.9.2",
|
package/dist/plugin-Bmz-K8re.mjs
DELETED