@vizejs/vite-plugin 0.23.0 → 0.25.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.js +31 -11
- package/package.json +6 -4
package/dist/index.js
CHANGED
|
@@ -457,6 +457,25 @@ async function loadConfigFile(configPath, env) {
|
|
|
457
457
|
*/
|
|
458
458
|
const vizeConfigStore = new Map();
|
|
459
459
|
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/compile-options.ts
|
|
462
|
+
function buildCompileFileOptions(filePath, source, options) {
|
|
463
|
+
const scopeId = /<style[^>]*\bscoped\b/.test(source) ? `data-v-${generateScopeId(filePath)}` : void 0;
|
|
464
|
+
return {
|
|
465
|
+
filename: filePath,
|
|
466
|
+
sourceMap: options.sourceMap,
|
|
467
|
+
ssr: options.ssr,
|
|
468
|
+
vapor: options.vapor,
|
|
469
|
+
scopeId
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function buildCompileBatchOptions(options) {
|
|
473
|
+
return {
|
|
474
|
+
ssr: options.ssr,
|
|
475
|
+
vapor: options.vapor
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
|
|
460
479
|
//#endregion
|
|
461
480
|
//#region src/compiler.ts
|
|
462
481
|
const { compileSfc, compileSfcBatchWithResults } = native;
|
|
@@ -491,12 +510,7 @@ function compileFile(filePath, cache, options, source) {
|
|
|
491
510
|
const content = source ?? fs.readFileSync(filePath, "utf-8");
|
|
492
511
|
const scopeId = generateScopeId(filePath);
|
|
493
512
|
const hasScoped = /<style[^>]*\bscoped\b/.test(content);
|
|
494
|
-
const result = compileSfc(content,
|
|
495
|
-
filename: filePath,
|
|
496
|
-
sourceMap: options.sourceMap,
|
|
497
|
-
ssr: options.ssr,
|
|
498
|
-
scopeId: hasScoped ? `data-v-${scopeId}` : void 0
|
|
499
|
-
});
|
|
513
|
+
const result = compileSfc(content, buildCompileFileOptions(filePath, content, options));
|
|
500
514
|
if (result.errors.length > 0) {
|
|
501
515
|
const errorMsg = result.errors.join("\n");
|
|
502
516
|
console.error(`[vize] Compilation error in ${filePath}:\n${errorMsg}`);
|
|
@@ -527,7 +541,7 @@ function compileBatch(files, cache, options) {
|
|
|
527
541
|
path: f.path,
|
|
528
542
|
source: f.source
|
|
529
543
|
}));
|
|
530
|
-
const result = compileSfcBatchWithResults(inputs,
|
|
544
|
+
const result = compileSfcBatchWithResults(inputs, buildCompileBatchOptions(options));
|
|
531
545
|
const sourceMap = new Map();
|
|
532
546
|
for (const f of files) sourceMap.set(f.path, f.source);
|
|
533
547
|
for (const fileResult of result.results) {
|
|
@@ -616,7 +630,10 @@ async function compileAll(state) {
|
|
|
616
630
|
} catch (e) {
|
|
617
631
|
state.logger.error(`Failed to read ${file}:`, e);
|
|
618
632
|
}
|
|
619
|
-
const result = compileBatch(fileContents, state.cache, {
|
|
633
|
+
const result = compileBatch(fileContents, state.cache, {
|
|
634
|
+
ssr: state.mergedOptions.ssr ?? false,
|
|
635
|
+
vapor: state.mergedOptions.vapor ?? false
|
|
636
|
+
});
|
|
620
637
|
for (const file of changedFiles) {
|
|
621
638
|
state.collectedCss.delete(file);
|
|
622
639
|
state.pendingHmrUpdateTypes.delete(file);
|
|
@@ -905,7 +922,8 @@ function loadHook(state, id, loadOptions) {
|
|
|
905
922
|
state.logger.log(`load: on-demand compiling ${realPath}`);
|
|
906
923
|
compiled = compileFile(realPath, state.cache, {
|
|
907
924
|
sourceMap: state.mergedOptions?.sourceMap ?? !(state.isProduction ?? false),
|
|
908
|
-
ssr: state.mergedOptions?.ssr ?? false
|
|
925
|
+
ssr: state.mergedOptions?.ssr ?? false,
|
|
926
|
+
vapor: state.mergedOptions?.vapor ?? false
|
|
909
927
|
});
|
|
910
928
|
}
|
|
911
929
|
if (compiled) {
|
|
@@ -979,7 +997,8 @@ async function handleHotUpdateHook(state, ctx) {
|
|
|
979
997
|
const prevCompiled = state.cache.get(file);
|
|
980
998
|
compileFile(file, state.cache, {
|
|
981
999
|
sourceMap: state.mergedOptions?.sourceMap ?? !state.isProduction,
|
|
982
|
-
ssr: state.mergedOptions?.ssr ?? false
|
|
1000
|
+
ssr: state.mergedOptions?.ssr ?? false,
|
|
1001
|
+
vapor: state.mergedOptions?.vapor ?? false
|
|
983
1002
|
}, source);
|
|
984
1003
|
const newCompiled = state.cache.get(file);
|
|
985
1004
|
try {
|
|
@@ -1092,7 +1111,8 @@ function createPostTransformPlugin(state) {
|
|
|
1092
1111
|
try {
|
|
1093
1112
|
const compiled = compileFile(id, state.cache, {
|
|
1094
1113
|
sourceMap: state.mergedOptions?.sourceMap ?? !(state.isProduction ?? false),
|
|
1095
|
-
ssr: state.mergedOptions?.ssr ?? false
|
|
1114
|
+
ssr: state.mergedOptions?.ssr ?? false,
|
|
1115
|
+
vapor: state.mergedOptions?.vapor ?? false
|
|
1096
1116
|
}, code);
|
|
1097
1117
|
const output = generateOutput(compiled, {
|
|
1098
1118
|
isProduction: state.isProduction,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^22.0.0",
|
|
37
37
|
"tsdown": "^0.9.0",
|
|
38
|
+
"tsx": "^4.21.0",
|
|
38
39
|
"typescript": "~5.6.0",
|
|
39
40
|
"vite": "^8.0.0-beta.0"
|
|
40
41
|
},
|
|
@@ -43,14 +44,15 @@
|
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"tinyglobby": "^0.2.0",
|
|
46
|
-
"@vizejs/native": "0.
|
|
47
|
+
"@vizejs/native": "0.25.0"
|
|
47
48
|
},
|
|
48
49
|
"scripts": {
|
|
49
50
|
"build": "tsdown",
|
|
50
51
|
"dev": "tsdown --watch",
|
|
51
52
|
"lint": "oxlint --deny-warnings --type-aware --tsconfig tsconfig.json",
|
|
52
53
|
"lint:fix": "oxlint --type-aware --tsconfig tsconfig.json --fix",
|
|
53
|
-
"fmt": "oxfmt --write src",
|
|
54
|
-
"fmt:check": "oxfmt src"
|
|
54
|
+
"fmt": "oxfmt --write src tsdown.config.ts",
|
|
55
|
+
"fmt:check": "oxfmt src tsdown.config.ts",
|
|
56
|
+
"test": "node --import tsx src/test.ts"
|
|
55
57
|
}
|
|
56
58
|
}
|