@vizejs/vite-plugin 0.664.0 → 0.666.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 +1 -1
- package/dist/internal/config-bridge.d.mts +1 -1
- package/dist/plugin-CwodSCpW.mjs +2 -0
- package/dist/{plugin-BNLDCUfA.mjs → plugin-pJzKyVGe.mjs} +125 -104
- package/dist/{types-CP73ozVq.d.mts → types-mem20MPI.d.mts} +1 -7
- package/dist/vite-plus.d.mts +1 -1
- package/dist/vite-plus.mjs +1 -1
- package/package.json +4 -4
- package/dist/plugin-C9YYGkLC.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-mem20MPI.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/plugin/compiler-config.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as vize } from "./plugin-
|
|
1
|
+
import { t as vize } from "./plugin-pJzKyVGe.mjs";
|
|
2
2
|
import { u as rewriteStaticAssetUrls } from "./vue-version-BFh0eI6J.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
|
|
@@ -3,7 +3,7 @@ import { a as resolveViteConfigExport, i as resolveConfigExport, o as vizeConfig
|
|
|
3
3
|
import { n as registerResolvedVizeConfig, r as unregisterResolvedVizeConfig } from "./config-bridge-Dv6U7_RC.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as native from "@vizejs/native";
|
|
6
|
-
import { buildInspectorGraph, chunkVitePrecompileFiles, classifyVitePluginRequest, createViteBareImportBases, createViteBareImportCandidates, createViteVirtualId, detectViteHmrUpdateType, diffVitePrecompileFiles, generateSfcScopeId, generateViteHmrCode, hasViteHmrChanges, isViteBareSpecifier, normalizeViteCssModuleFilename, normalizeViteDevMiddlewareUrl, normalizeVitePrecompileBatchSize, normalizeViteRequireBase, normalizeViteResolvedVuePath, resolveViteAliasRequest, resolveViteCssImports, resolveViteRelativeImport, resolveViteVuePath, scopeViteCssForPipeline, splitViteIdQuery, toViteBrowserImportPrefix, transformViteCssVarsForPipeline } from "@vizejs/native";
|
|
6
|
+
import { buildInspectorGraph, chunkVitePrecompileFiles, classifyVitePluginRequest, createViteBareImportBases, createViteBareImportCandidates, createViteVirtualId, detectViteHmrUpdateType, diffVitePrecompileFiles, generateSfcScopeId, generateViteHmrCode, hasViteHmrChanges, isViteBareSpecifier, normalizeViteCssModuleFilename, normalizeViteDevMiddlewareUrl, normalizeVitePrecompileBatchSize, normalizeViteRequireBase, normalizeViteResolvedVuePath, parseSfc, resolveViteAliasRequest, resolveViteCssImports, resolveViteRelativeImport, resolveViteVuePath, scopeViteCssForPipeline, splitViteIdQuery, toViteBrowserImportPrefix, transformViteCssVarsForPipeline } from "@vizejs/native";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { parseSync } from "oxc-parser";
|
|
9
9
|
import fs from "node:fs";
|
|
@@ -212,32 +212,13 @@ function rewriteDefaultExportToSfcMain(code, moduleInfo = {
|
|
|
212
212
|
return `${code.slice(0, exportStart)}const ${SFC_MAIN_NAME} =${code.slice(keywordEnd)}`;
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* the default export's declaration *is* the `_sfc_main` identifier, which cannot
|
|
219
|
-
* happen unless that name occurs in the module.
|
|
215
|
+
* Insert `insertion` before `export default _sfc_main`. `moduleInfo` must
|
|
216
|
+
* describe `code` exactly (offsets are used verbatim), so the module is never
|
|
217
|
+
* parsed again (#3425).
|
|
220
218
|
*/
|
|
221
|
-
function
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
defaultExportEnd: null,
|
|
225
|
-
defaultExportIsSfcMain: false
|
|
226
|
-
};
|
|
227
|
-
const defaultExport = findDefaultExport(parseProgram(code));
|
|
228
|
-
return {
|
|
229
|
-
defaultExportStart: getNodeStart(defaultExport),
|
|
230
|
-
defaultExportEnd: getNodeEnd(defaultExport),
|
|
231
|
-
defaultExportIsSfcMain: isSfcMainDefaultExport(defaultExport)
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function insertBeforeSfcMainDefaultExport(code, insertion, options = {}) {
|
|
235
|
-
const { defaultExportStart: exportStart, defaultExportEnd: exportEnd, defaultExportIsSfcMain } = options.moduleInfo ?? findSfcMainDefaultExport(code);
|
|
236
|
-
if (!defaultExportIsSfcMain || exportStart == null) return code;
|
|
237
|
-
if (options.normalizeSemicolon && exportEnd != null) {
|
|
238
|
-
const suffixStart = code[exportEnd] === ";" ? exportEnd + 1 : exportEnd;
|
|
239
|
-
return `${code.slice(0, exportStart)}${insertion}\nexport default ${SFC_MAIN_NAME};${code.slice(suffixStart)}`;
|
|
240
|
-
}
|
|
219
|
+
function insertBeforeSfcMainDefaultExport(code, insertion, moduleInfo) {
|
|
220
|
+
const exportStart = moduleInfo.defaultExportStart;
|
|
221
|
+
if (!moduleInfo.defaultExportIsSfcMain || exportStart == null) return code;
|
|
241
222
|
return `${code.slice(0, exportStart)}${insertion}\n${code.slice(exportStart)}`;
|
|
242
223
|
}
|
|
243
224
|
//#endregion
|
|
@@ -386,22 +367,25 @@ function assembleComponentOutput(compiled) {
|
|
|
386
367
|
const hasNamedRenderExport = moduleInfo.hasNamedRenderExport;
|
|
387
368
|
const hasNamedSsrRenderExport = moduleInfo.hasNamedSsrRenderExport;
|
|
388
369
|
const hasSfcMainDefined = moduleInfo.hasSfcMainDefined;
|
|
370
|
+
let exportsSfcMain = true;
|
|
389
371
|
if (hasExportDefault && !hasSfcMainDefined) {
|
|
390
372
|
emitted.edit(rewriteDefaultExportToSfcMain(emitted.code, moduleInfo));
|
|
391
373
|
if (compiled.hasScoped && compiled.scopeId) emitted.edit(`${emitted.code}\n_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`);
|
|
392
374
|
emitted.edit(`${emitted.code}\nexport default _sfc_main;`);
|
|
393
375
|
} else if (hasExportDefault && hasSfcMainDefined) {
|
|
394
|
-
|
|
376
|
+
exportsSfcMain = moduleInfo.defaultExportIsSfcMain;
|
|
377
|
+
if (compiled.hasScoped && compiled.scopeId) emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, `_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`, moduleInfo));
|
|
395
378
|
} else if (!hasExportDefault && !hasSfcMainDefined && hasNamedRenderExport) {
|
|
396
379
|
const scope = compiled.hasScoped && compiled.scopeId ? `, __scopeId: "data-v-${compiled.scopeId}"` : "";
|
|
397
380
|
emitted.edit(`${emitted.code}\nconst _sfc_main = { render${scope} };\nexport default _sfc_main;`);
|
|
398
381
|
} else if (!hasExportDefault && !hasSfcMainDefined && hasNamedSsrRenderExport) {
|
|
399
382
|
const scope = compiled.hasScoped && compiled.scopeId ? `, __scopeId: "data-v-${compiled.scopeId}"` : "";
|
|
400
383
|
emitted.edit(`${emitted.code}\nconst _sfc_main = { ssrRender${scope} };\nexport default _sfc_main;`);
|
|
401
|
-
}
|
|
384
|
+
} else exportsSfcMain = false;
|
|
402
385
|
return {
|
|
403
386
|
emitted,
|
|
404
|
-
hasExportDefault
|
|
387
|
+
hasExportDefault,
|
|
388
|
+
exportsSfcMain
|
|
405
389
|
};
|
|
406
390
|
}
|
|
407
391
|
//#endregion
|
|
@@ -699,7 +683,7 @@ function generateOutput(compiled, options) {
|
|
|
699
683
|
*/
|
|
700
684
|
function generateOutputWithMap(compiled, options) {
|
|
701
685
|
const { customElement, isProduction, isDev, ssr, hmrUpdateType, extractCss, filePath, root } = options;
|
|
702
|
-
const { emitted, hasExportDefault } = assembleComponentOutput(compiled);
|
|
686
|
+
const { emitted, hasExportDefault, exportsSfcMain } = assembleComponentOutput(compiled);
|
|
703
687
|
if (usesStyleImports(compiled, options)) {
|
|
704
688
|
const styleImports = [];
|
|
705
689
|
const cssModuleImports = [];
|
|
@@ -731,8 +715,8 @@ function generateOutputWithMap(compiled, options) {
|
|
|
731
715
|
}
|
|
732
716
|
const allImports = [...styleImports, ...cssModuleImports].join("\n");
|
|
733
717
|
if (allImports) emitted.edit(insertAfterStaticImports(emitted.code, allImports));
|
|
734
|
-
if (customElementStyleBindings.length > 0) emitted.edit(
|
|
735
|
-
else if (cssModuleImports.length > 0) {
|
|
718
|
+
if (exportsSfcMain && customElementStyleBindings.length > 0) emitted.edit(`${emitted.code}\n_sfc_main.styles = [${customElementStyleBindings.join(", ")}];`);
|
|
719
|
+
else if (exportsSfcMain && cssModuleImports.length > 0) {
|
|
736
720
|
const moduleBindings = [];
|
|
737
721
|
for (const block of compiled.styles) if (isCssModule(block)) {
|
|
738
722
|
const bindingName = typeof block.module === "string" ? block.module : "$style";
|
|
@@ -742,7 +726,7 @@ function generateOutputWithMap(compiled, options) {
|
|
|
742
726
|
});
|
|
743
727
|
}
|
|
744
728
|
const cssModuleSetup = moduleBindings.map((m) => `_sfc_main.__cssModules = _sfc_main.__cssModules || {};\n_sfc_main.__cssModules[${JSON.stringify(m.name)}] = ${m.bindingName};`).join("\n");
|
|
745
|
-
emitted.edit(
|
|
729
|
+
emitted.edit(`${emitted.code}\n${cssModuleSetup}`);
|
|
746
730
|
}
|
|
747
731
|
} else if (!ssr && compiled.css && !(isProduction && extractCss)) emitted.edit(prependInlineStyleInjection(emitted.code, compiled.css, compiled.scopeId));
|
|
748
732
|
if (!isProduction && isDev && hasExportDefault) {
|
|
@@ -1077,6 +1061,111 @@ async function resolveSfcSrcRequests(importer, requests, resolve) {
|
|
|
1077
1061
|
}
|
|
1078
1062
|
return resolutions;
|
|
1079
1063
|
}
|
|
1064
|
+
const SRC_BLOCK_HINT = /<(?:template|script|style)\b[^>]*\ssrc\s*=/i;
|
|
1065
|
+
const ATTRIBUTE_RE = /\s+([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gy;
|
|
1066
|
+
/** Split an opening tag into its `src` value and the tag without it. */
|
|
1067
|
+
function splitSrcAttribute(tag, openTag) {
|
|
1068
|
+
const head = `<${tag}`;
|
|
1069
|
+
if (!openTag.toLowerCase().startsWith(head)) return null;
|
|
1070
|
+
const body = openTag.slice(head.length).replace(/\s*\/?\s*>$/, "");
|
|
1071
|
+
let rest = "";
|
|
1072
|
+
let src = null;
|
|
1073
|
+
let consumed = 0;
|
|
1074
|
+
ATTRIBUTE_RE.lastIndex = 0;
|
|
1075
|
+
for (let match = ATTRIBUTE_RE.exec(body); match; match = ATTRIBUTE_RE.exec(body)) {
|
|
1076
|
+
consumed = ATTRIBUTE_RE.lastIndex;
|
|
1077
|
+
if (match[1].toLowerCase() === "src" && src === null) src = match[2] ?? match[3] ?? match[4] ?? "";
|
|
1078
|
+
else rest += match[0];
|
|
1079
|
+
}
|
|
1080
|
+
if (src === null || consumed !== body.length) return null;
|
|
1081
|
+
return {
|
|
1082
|
+
src,
|
|
1083
|
+
openTag: `${head}${rest}>`
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
/** The `src` blocks the native parser finds, so `src` text in scripts or comments is not one. */
|
|
1087
|
+
function collectSrcBlocks(parseSfc, filePath, bytes, source) {
|
|
1088
|
+
let parsed;
|
|
1089
|
+
try {
|
|
1090
|
+
parsed = parseSfc(source, { filename: filePath });
|
|
1091
|
+
} catch {
|
|
1092
|
+
return [];
|
|
1093
|
+
}
|
|
1094
|
+
const blocks = [
|
|
1095
|
+
["template", parsed.template],
|
|
1096
|
+
["script", parsed.script],
|
|
1097
|
+
["script", parsed.scriptSetup],
|
|
1098
|
+
...parsed.styles.map((style) => ["style", style])
|
|
1099
|
+
];
|
|
1100
|
+
const found = [];
|
|
1101
|
+
for (const [tag, block] of blocks) {
|
|
1102
|
+
if (!block) continue;
|
|
1103
|
+
const { start, tagStart, tagEnd } = block.loc;
|
|
1104
|
+
const split = splitSrcAttribute(tag, bytes.subarray(tagStart, start).toString("utf8"));
|
|
1105
|
+
if (split) found.push({
|
|
1106
|
+
tag,
|
|
1107
|
+
...split,
|
|
1108
|
+
tagStart,
|
|
1109
|
+
tagEnd
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
return found;
|
|
1113
|
+
}
|
|
1114
|
+
/** The `src` module requests (not relative paths) of an SFC's blocks, in source order. */
|
|
1115
|
+
function listSfcSrcRequests(parseSfc, filePath, source) {
|
|
1116
|
+
if (!SRC_BLOCK_HINT.test(source)) return [];
|
|
1117
|
+
return collectSrcBlocks(parseSfc, filePath, Buffer.from(source), source).map((block) => block.src).filter((src) => !isRelativeSfcSrc(src));
|
|
1118
|
+
}
|
|
1119
|
+
function readSrcBlock(filePath, tag, src, resolutions) {
|
|
1120
|
+
const resolved = sfcSrcFile(filePath, tag, src, resolutions);
|
|
1121
|
+
try {
|
|
1122
|
+
return {
|
|
1123
|
+
path: resolved,
|
|
1124
|
+
content: fs.readFileSync(resolved, "utf8")
|
|
1125
|
+
};
|
|
1126
|
+
} catch {
|
|
1127
|
+
throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolved}) in ${filePath}`);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Inline `<template src>`, `<script src>` and `<style src>` files into the SFC
|
|
1132
|
+
* source. Blocks are located by the native parser. Module requests come from
|
|
1133
|
+
* the bundler's `resolutions` (see {@link sfcSrcFile}).
|
|
1134
|
+
*/
|
|
1135
|
+
function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
|
|
1136
|
+
if (!SRC_BLOCK_HINT.test(source)) return {
|
|
1137
|
+
source,
|
|
1138
|
+
dependencies: []
|
|
1139
|
+
};
|
|
1140
|
+
const bytes = Buffer.from(source);
|
|
1141
|
+
const edits = [];
|
|
1142
|
+
const dependencies = [];
|
|
1143
|
+
for (const block of collectSrcBlocks(parseSfc, filePath, bytes, source)) {
|
|
1144
|
+
const file = readSrcBlock(filePath, block.tag, block.src, resolutions);
|
|
1145
|
+
dependencies.push(file.path);
|
|
1146
|
+
edits.push({
|
|
1147
|
+
start: block.tagStart,
|
|
1148
|
+
end: block.tagEnd,
|
|
1149
|
+
text: `${block.openTag}\n${file.content}\n</${block.tag}>`
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
if (edits.length === 0) return {
|
|
1153
|
+
source,
|
|
1154
|
+
dependencies
|
|
1155
|
+
};
|
|
1156
|
+
edits.sort((a, b) => a.start - b.start);
|
|
1157
|
+
const parts = [];
|
|
1158
|
+
let offset = 0;
|
|
1159
|
+
for (const edit of edits) {
|
|
1160
|
+
parts.push(bytes.subarray(offset, edit.start), Buffer.from(edit.text));
|
|
1161
|
+
offset = edit.end;
|
|
1162
|
+
}
|
|
1163
|
+
parts.push(bytes.subarray(offset));
|
|
1164
|
+
return {
|
|
1165
|
+
source: Buffer.concat(parts).toString("utf8"),
|
|
1166
|
+
dependencies
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1080
1169
|
//#endregion
|
|
1081
1170
|
//#region src/compile-options.ts
|
|
1082
1171
|
function buildCompileFileOptions(filePath, options, scopeId = generateScopeId(filePath, options.root, options.isProd ?? false)) {
|
|
@@ -1168,77 +1257,9 @@ function normalizeStyleBlocks(styles) {
|
|
|
1168
1257
|
index: block.index
|
|
1169
1258
|
}));
|
|
1170
1259
|
}
|
|
1171
|
-
function readSrcImport(filePath, tag, src, resolutions) {
|
|
1172
|
-
const resolvedPath = sfcSrcFile(filePath, tag, src, resolutions);
|
|
1173
|
-
try {
|
|
1174
|
-
return {
|
|
1175
|
-
path: resolvedPath,
|
|
1176
|
-
content: fs.readFileSync(resolvedPath, "utf-8")
|
|
1177
|
-
};
|
|
1178
|
-
} catch {
|
|
1179
|
-
throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolvedPath}) in ${filePath}`);
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
function stripSrcAttribute(attrs) {
|
|
1183
|
-
return attrs.replace(/\s*\bsrc\s*=\s*(?:"[^"]*"|'[^']*')/i, "");
|
|
1184
|
-
}
|
|
1185
|
-
function inlineSingleSrcBlock(source, filePath, tag, src, dependencies, resolutions) {
|
|
1186
|
-
if (!src) return source;
|
|
1187
|
-
const imported = readSrcImport(filePath, tag, src, resolutions);
|
|
1188
|
-
dependencies.push(imported.path);
|
|
1189
|
-
const pattern = new RegExp(`<${tag}\\b([^>]*)\\bsrc\\s*=\\s*(['"])[^'"]+\\2([^>]*)>[\\s\\S]*?<\\/${tag}>`, "i");
|
|
1190
|
-
return source.replace(pattern, (_match, beforeSrc, _quote, afterSrc) => {
|
|
1191
|
-
return `<${tag}${stripSrcAttribute(`${beforeSrc}${afterSrc}`)}>\n${imported.content}\n</${tag}>`;
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
|
-
const STYLE_SRC_BLOCK_RE = /<style\b([^>]*)\bsrc\s*=\s*(['"])([^'"]+)\2([^>]*)>[\s\S]*?<\/style>/gi;
|
|
1195
|
-
function inlineStyleSrcBlocks(source, filePath, dependencies, resolutions) {
|
|
1196
|
-
return source.replace(STYLE_SRC_BLOCK_RE, (_match, beforeSrc, _quote, src, afterSrc) => {
|
|
1197
|
-
const imported = readSrcImport(filePath, "style", src, resolutions);
|
|
1198
|
-
dependencies.push(imported.path);
|
|
1199
|
-
return `<style${stripSrcAttribute(`${beforeSrc}${afterSrc}`)}>\n${imported.content}\n</style>`;
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
/**
|
|
1203
|
-
* Cheap necessary condition for an SFC block carrying a `src` attribute.
|
|
1204
|
-
*
|
|
1205
|
-
* `extractSfcSrcInfo` parses a full SFC descriptor, so calling it for every file
|
|
1206
|
-
* costs a second whole-source parse per compile on top of the one the compiler
|
|
1207
|
-
* itself performs -- and block `src` attributes are rare (roughly 4% of files in
|
|
1208
|
-
* a real app). Any `<script src>`/`<template src>`/`<style src>` necessarily
|
|
1209
|
-
* contains `src` followed by `=`, so a source without this substring provably
|
|
1210
|
-
* has nothing to inline and can skip the descriptor parse entirely. False
|
|
1211
|
-
* positives (e.g. `<img src=...>` in a template) simply take the original path.
|
|
1212
|
-
*/
|
|
1213
|
-
const SFC_SRC_ATTRIBUTE_HINT = /\bsrc\s*=/i;
|
|
1214
|
-
/** Module requests in `src` come from the bundler's `resolutions` (see {@link sfcSrcFile}). */
|
|
1215
|
-
function resolveSfcSrcImports(filePath, source, resolutions) {
|
|
1216
|
-
if (!SFC_SRC_ATTRIBUTE_HINT.test(source)) return {
|
|
1217
|
-
source,
|
|
1218
|
-
dependencies: []
|
|
1219
|
-
};
|
|
1220
|
-
const dependencies = [];
|
|
1221
|
-
const srcInfo = native.extractSfcSrcInfo(source, filePath);
|
|
1222
|
-
let resolvedSource = source;
|
|
1223
|
-
resolvedSource = inlineSingleSrcBlock(resolvedSource, filePath, "script", srcInfo.scriptSrc, dependencies, resolutions);
|
|
1224
|
-
resolvedSource = inlineSingleSrcBlock(resolvedSource, filePath, "template", srcInfo.templateSrc, dependencies, resolutions);
|
|
1225
|
-
resolvedSource = inlineStyleSrcBlocks(resolvedSource, filePath, dependencies, resolutions);
|
|
1226
|
-
return {
|
|
1227
|
-
source: resolvedSource,
|
|
1228
|
-
dependencies
|
|
1229
|
-
};
|
|
1230
|
-
}
|
|
1231
|
-
/** The `src` module requests (not relative paths) the inliner will need resolved. */
|
|
1232
|
-
function listSfcSrcRequests(filePath, source) {
|
|
1233
|
-
if (!SFC_SRC_ATTRIBUTE_HINT.test(source)) return [];
|
|
1234
|
-
const srcInfo = native.extractSfcSrcInfo(source, filePath);
|
|
1235
|
-
const requests = [srcInfo.scriptSrc, srcInfo.templateSrc];
|
|
1236
|
-
for (const match of source.matchAll(STYLE_SRC_BLOCK_RE)) requests.push(match[3]);
|
|
1237
|
-
return requests.filter((src) => !!src && !isRelativeSfcSrc(src));
|
|
1238
|
-
}
|
|
1239
1260
|
function compileFile(filePath, cache, options, source, diagnostics) {
|
|
1240
1261
|
const content = source ?? fs.readFileSync(filePath, "utf-8");
|
|
1241
|
-
const resolved =
|
|
1262
|
+
const resolved = inlineSfcSrcBlocks(native.parseSfc, filePath, content, options.srcResolutions?.get(filePath));
|
|
1242
1263
|
const scopeId = generateScopeId(filePath, options.root, options.isProd ?? false, content);
|
|
1243
1264
|
const result = compileSfc(resolved.source, buildCompileFileOptions(filePath, options, scopeId));
|
|
1244
1265
|
if (result.errors.length > 0) throw new VizeSfcCompileError(filePath, result.errors);
|
|
@@ -1301,7 +1322,7 @@ function compileJsxModule(filePath, source, options = {}) {
|
|
|
1301
1322
|
function compileBatch(files, cache, options) {
|
|
1302
1323
|
const dependenciesByPath = /* @__PURE__ */ new Map();
|
|
1303
1324
|
const resolvedFiles = files.map((file) => {
|
|
1304
|
-
const resolved =
|
|
1325
|
+
const resolved = inlineSfcSrcBlocks(native.parseSfc, file.path, file.source, options.srcResolutions?.get(file.path));
|
|
1305
1326
|
dependenciesByPath.set(file.path, resolved.dependencies);
|
|
1306
1327
|
return {
|
|
1307
1328
|
path: file.path,
|
|
@@ -1863,7 +1884,7 @@ function viteHostResolve(resolve) {
|
|
|
1863
1884
|
* them from `state.srcResolutions`. A request left unresolved fails that compile.
|
|
1864
1885
|
*/
|
|
1865
1886
|
async function prepareSfcSrcRequests(state, resolve, file, source) {
|
|
1866
|
-
const requests = listSfcSrcRequests(file, source);
|
|
1887
|
+
const requests = listSfcSrcRequests(parseSfc, file, source);
|
|
1867
1888
|
if (requests.length === 0) {
|
|
1868
1889
|
state.srcResolutions?.delete(file);
|
|
1869
1890
|
return;
|
|
@@ -1144,13 +1144,7 @@ type ModuleOutputInfo = {
|
|
|
1144
1144
|
hasNamedRenderExport: boolean;
|
|
1145
1145
|
hasNamedSsrRenderExport: boolean;
|
|
1146
1146
|
defaultExportKeywordEnd: number | null;
|
|
1147
|
-
defaultExportStart: number | null;
|
|
1148
|
-
/**
|
|
1149
|
-
* End offset of the whole `export default ...` statement, or `null`.
|
|
1150
|
-
*
|
|
1151
|
-
* Recorded so {@link insertBeforeSfcMainDefaultExport} can reuse the caller's
|
|
1152
|
-
* analysis instead of parsing the module a second time (#3425).
|
|
1153
|
-
*/
|
|
1147
|
+
defaultExportStart: number | null; /** End offset of the whole `export default ...` statement, or `null`. */
|
|
1154
1148
|
defaultExportEnd: number | null;
|
|
1155
1149
|
/**
|
|
1156
1150
|
* Whether the default export's declaration is exactly the `_sfc_main`
|
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-mem20MPI.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
|
@@ -400,7 +400,7 @@ function defineConfig(config = {}, integration = {}) {
|
|
|
400
400
|
const legacy = compiler !== false && (await import("./vue-version-DOjZaMiI.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-CwodSCpW.mjs");
|
|
404
404
|
plugins.push(vize({
|
|
405
405
|
...plugin,
|
|
406
406
|
configMode: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.666.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.666.0",
|
|
55
|
+
"@vizejs/unplugin": "0.666.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.666.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "25.9.2",
|
package/dist/plugin-C9YYGkLC.mjs
DELETED