@vizejs/vite-plugin 0.89.0 → 0.90.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 +35 -53
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -364,14 +364,14 @@ function resolveCssPath(importPath, importer, aliasRules) {
|
|
|
364
364
|
}
|
|
365
365
|
function resolveAliasPath(importPath, rule) {
|
|
366
366
|
if (typeof rule.find !== "string") {
|
|
367
|
-
const pattern = stableAliasPattern(rule.find);
|
|
367
|
+
const pattern = stableAliasPattern$1(rule.find);
|
|
368
368
|
return pattern.test(importPath) ? importPath.replace(pattern, rule.replacement) : null;
|
|
369
369
|
}
|
|
370
370
|
const suffix = matchedAliasSuffix(importPath, rule.find);
|
|
371
371
|
if (suffix !== null) return path.join(rule.replacement, suffix);
|
|
372
372
|
return null;
|
|
373
373
|
}
|
|
374
|
-
function stableAliasPattern(pattern) {
|
|
374
|
+
function stableAliasPattern$1(pattern) {
|
|
375
375
|
return new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, ""));
|
|
376
376
|
}
|
|
377
377
|
function matchedAliasSuffix(importPath, find) {
|
|
@@ -651,15 +651,14 @@ function createLogger(debug) {
|
|
|
651
651
|
const vizeConfigStore = /* @__PURE__ */ new Map();
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region src/compile-options.ts
|
|
654
|
-
function buildCompileFileOptions(filePath,
|
|
655
|
-
const scopeId = /<style[^>]*\bscoped\b/.test(source) ? `data-v-${generateScopeId(filePath)}` : void 0;
|
|
654
|
+
function buildCompileFileOptions(filePath, options) {
|
|
656
655
|
return {
|
|
657
656
|
filename: filePath,
|
|
658
657
|
sourceMap: options.sourceMap,
|
|
659
658
|
ssr: options.ssr,
|
|
660
659
|
vapor: options.vapor,
|
|
661
660
|
customRenderer: options.customRenderer ?? false,
|
|
662
|
-
scopeId
|
|
661
|
+
scopeId: `data-v-${generateScopeId(filePath)}`
|
|
663
662
|
};
|
|
664
663
|
}
|
|
665
664
|
function buildCompileBatchOptions(options) {
|
|
@@ -672,38 +671,20 @@ function buildCompileBatchOptions(options) {
|
|
|
672
671
|
//#endregion
|
|
673
672
|
//#region src/compiler.ts
|
|
674
673
|
const { compileSfc, compileSfcBatchWithResults } = native;
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
while ((match = styleRegex.exec(source)) !== null) {
|
|
685
|
-
const attrs = match[1];
|
|
686
|
-
const content = match[2];
|
|
687
|
-
const lang = attrs.match(/\blang=["']([^"']+)["']/)?.[1] ?? null;
|
|
688
|
-
const scoped = /\bscoped\b/.test(attrs);
|
|
689
|
-
const moduleMatch = attrs.match(/\bmodule(?:=["']([^"']+)["'])?/);
|
|
690
|
-
const isModule = moduleMatch ? moduleMatch[1] || true : false;
|
|
691
|
-
blocks.push({
|
|
692
|
-
content,
|
|
693
|
-
lang,
|
|
694
|
-
scoped,
|
|
695
|
-
module: isModule,
|
|
696
|
-
index
|
|
697
|
-
});
|
|
698
|
-
index++;
|
|
699
|
-
}
|
|
700
|
-
return blocks;
|
|
674
|
+
function normalizeStyleBlocks(styles) {
|
|
675
|
+
if (!styles) return [];
|
|
676
|
+
return styles.map((block) => ({
|
|
677
|
+
content: block.content,
|
|
678
|
+
lang: block.lang ?? null,
|
|
679
|
+
scoped: block.scoped,
|
|
680
|
+
module: block.module ? block.moduleName ?? true : false,
|
|
681
|
+
index: block.index
|
|
682
|
+
}));
|
|
701
683
|
}
|
|
702
684
|
function compileFile(filePath, cache, options, source) {
|
|
703
685
|
const content = source ?? fs.readFileSync(filePath, "utf-8");
|
|
704
686
|
const scopeId = generateScopeId(filePath);
|
|
705
|
-
const
|
|
706
|
-
const result = compileSfc(content, buildCompileFileOptions(filePath, content, options));
|
|
687
|
+
const result = compileSfc(content, buildCompileFileOptions(filePath, options));
|
|
707
688
|
if (result.errors.length > 0) {
|
|
708
689
|
const errorMsg = result.errors.join("\n");
|
|
709
690
|
console.error(`[vize] Compilation error in ${filePath}:\n${errorMsg}`);
|
|
@@ -711,17 +692,16 @@ function compileFile(filePath, cache, options, source) {
|
|
|
711
692
|
if (result.warnings.length > 0) result.warnings.forEach((warning) => {
|
|
712
693
|
console.warn(`[vize] Warning in ${filePath}: ${warning}`);
|
|
713
694
|
});
|
|
714
|
-
const styles = extractStyleBlocks(content);
|
|
715
695
|
const compiled = {
|
|
716
696
|
code: result.code,
|
|
717
697
|
css: result.css,
|
|
718
698
|
scopeId,
|
|
719
|
-
hasScoped,
|
|
699
|
+
hasScoped: result.hasScoped,
|
|
720
700
|
templateHash: result.templateHash,
|
|
721
701
|
styleHash: result.styleHash,
|
|
722
702
|
scriptHash: result.scriptHash,
|
|
723
703
|
macroArtifacts: result.macroArtifacts ?? [],
|
|
724
|
-
styles
|
|
704
|
+
styles: normalizeStyleBlocks(result.styles)
|
|
725
705
|
};
|
|
726
706
|
cache.set(filePath, compiled);
|
|
727
707
|
return compiled;
|
|
@@ -735,24 +715,18 @@ function compileBatch(files, cache, options) {
|
|
|
735
715
|
path: f.path,
|
|
736
716
|
source: f.source
|
|
737
717
|
})), buildCompileBatchOptions(options));
|
|
738
|
-
const sourceMap = /* @__PURE__ */ new Map();
|
|
739
|
-
for (const f of files) sourceMap.set(f.path, f.source);
|
|
740
718
|
for (const fileResult of result.results) {
|
|
741
|
-
if (fileResult.errors.length === 0) {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
macroArtifacts: fileResult.macroArtifacts ?? [],
|
|
753
|
-
styles
|
|
754
|
-
});
|
|
755
|
-
}
|
|
719
|
+
if (fileResult.errors.length === 0) cache.set(fileResult.path, {
|
|
720
|
+
code: fileResult.code,
|
|
721
|
+
css: fileResult.css,
|
|
722
|
+
scopeId: fileResult.scopeId,
|
|
723
|
+
hasScoped: fileResult.hasScoped,
|
|
724
|
+
templateHash: fileResult.templateHash,
|
|
725
|
+
styleHash: fileResult.styleHash,
|
|
726
|
+
scriptHash: fileResult.scriptHash,
|
|
727
|
+
macroArtifacts: fileResult.macroArtifacts ?? [],
|
|
728
|
+
styles: normalizeStyleBlocks(fileResult.styles)
|
|
729
|
+
});
|
|
756
730
|
if (fileResult.errors.length > 0) console.error(`[vize] Compilation error in ${fileResult.path}:\n${fileResult.errors.join("\n")}`);
|
|
757
731
|
if (fileResult.warnings.length > 0) fileResult.warnings.forEach((warning) => {
|
|
758
732
|
console.warn(`[vize] Warning in ${fileResult.path}: ${warning}`);
|
|
@@ -942,12 +916,20 @@ function isBareSpecifier(id) {
|
|
|
942
916
|
function resolveAliasRequest(state, id) {
|
|
943
917
|
const [request, querySuffix] = splitIdQuery(id);
|
|
944
918
|
for (const rule of state.cssAliasRules) {
|
|
919
|
+
if (rule.find instanceof RegExp) {
|
|
920
|
+
const pattern = stableAliasPattern(rule.find);
|
|
921
|
+
if (pattern.test(request)) return request.replace(pattern, rule.replacement) + querySuffix;
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
945
924
|
if (request === rule.find) return rule.replacement + querySuffix;
|
|
946
925
|
const findPrefix = rule.find.endsWith("/") ? rule.find : rule.find + "/";
|
|
947
926
|
if (request.startsWith(findPrefix)) return (rule.replacement.endsWith("/") ? rule.replacement : rule.replacement + "/") + request.slice(findPrefix.length) + querySuffix;
|
|
948
927
|
}
|
|
949
928
|
return null;
|
|
950
929
|
}
|
|
930
|
+
function stableAliasPattern(pattern) {
|
|
931
|
+
return new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, ""));
|
|
932
|
+
}
|
|
951
933
|
function pushPnpmHoistBases(candidates, start, isDirectory) {
|
|
952
934
|
if (!start) return;
|
|
953
935
|
let dir = isDirectory ? start : path.dirname(start);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@vizejs/native": "0.
|
|
36
|
+
"@vizejs/native": "0.90.0",
|
|
37
37
|
"tinyglobby": "0.2.16",
|
|
38
|
-
"vize": "0.
|
|
38
|
+
"vize": "0.90.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "25.7.0",
|