@vizejs/vite-plugin 0.109.0 → 0.113.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/README.md +1 -0
- package/dist/index.mjs +43 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -74,6 +74,7 @@ vite {
|
|
|
74
74
|
`@vizejs/vite-plugin` loads the same `vize.config.ts`, `vize.config.js`, `vize.config.mjs`,
|
|
75
75
|
`vize.config.pkl`, and `vize.config.json` files as the `vize` npm CLI. Importing
|
|
76
76
|
`defineConfig` from `@vizejs/vite-plugin` still works, but `vize` is the shared entry point.
|
|
77
|
+
Install `@pkl-community/pkl` or provide a `pkl` binary on `PATH` when using `vize.config.pkl`.
|
|
77
78
|
|
|
78
79
|
### Nuxt
|
|
79
80
|
|
package/dist/index.mjs
CHANGED
|
@@ -386,6 +386,13 @@ function syncCollectedCssForFile(state, filePath, compiled) {
|
|
|
386
386
|
if (compiled.css && !hasDelegatedStyles(compiled)) state.collectedCss.set(filePath, resolveCssImports(compiled.css, filePath, state.cssAliasRules, false));
|
|
387
387
|
else state.collectedCss.delete(filePath);
|
|
388
388
|
}
|
|
389
|
+
function clearBuildCaches(state) {
|
|
390
|
+
state.cache.clear();
|
|
391
|
+
state.ssrCache.clear();
|
|
392
|
+
state.collectedCss.clear();
|
|
393
|
+
state.precompileMetadata.clear();
|
|
394
|
+
state.pendingHmrUpdateTypes.clear();
|
|
395
|
+
}
|
|
389
396
|
/**
|
|
390
397
|
* Pre-compile all Vue files matching scan patterns.
|
|
391
398
|
*/
|
|
@@ -531,6 +538,14 @@ function resolveVueBundlerEntryWithNode(state, id, importer) {
|
|
|
531
538
|
function isVueRuntimeRequest(id) {
|
|
532
539
|
return splitViteIdQuery(id).request === "vue";
|
|
533
540
|
}
|
|
541
|
+
function resolveSsrExternalVueRequest(id) {
|
|
542
|
+
const { request, querySuffix } = splitViteIdQuery(id);
|
|
543
|
+
if (querySuffix) return null;
|
|
544
|
+
if (request === "@vue/server-renderer" || request === "vue/server-renderer") return "vue/server-renderer";
|
|
545
|
+
if (request === "vue" || request.startsWith("vue/dist/")) return "vue";
|
|
546
|
+
if (request.startsWith("@vue/")) return request;
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
534
549
|
function isVuePackageEntry(id) {
|
|
535
550
|
const { request } = splitViteIdQuery(id);
|
|
536
551
|
const normalized = request.split(path.sep).join("/");
|
|
@@ -552,8 +567,16 @@ function isPotentialVizeResolveId(id) {
|
|
|
552
567
|
function isPotentialVizeImporter(importer) {
|
|
553
568
|
return importer !== void 0 && (importer.startsWith("\0") || importer.startsWith("vize:"));
|
|
554
569
|
}
|
|
570
|
+
function shouldCompileVueSfcRequest(request) {
|
|
571
|
+
if (!request.isVueSfcPath || request.isVueStyleQuery || request.hasMacroQuery || request.hasDefinePageQuery) return false;
|
|
572
|
+
if (!request.querySuffix) return true;
|
|
573
|
+
const params = new URLSearchParams(request.querySuffix.slice(1));
|
|
574
|
+
if (params.has("raw") || params.has("url") || params.has("worker") || params.has("sharedworker")) return false;
|
|
575
|
+
return params.has("nuxt_component");
|
|
576
|
+
}
|
|
555
577
|
async function resolveAliasedVueImport(ctx, state, id, importer, isSsrRequest, handleNodeModules) {
|
|
556
578
|
if (path.isAbsolute(id)) return null;
|
|
579
|
+
const request = classifyVitePluginRequest(id);
|
|
557
580
|
const viteImporter = normalizeViteRequireBase(importer) ?? importer;
|
|
558
581
|
const viteResolved = await ctx.resolve(id, viteImporter, { skipSelf: true });
|
|
559
582
|
const realPath = viteResolved ? normalizeResolvedVuePath(viteResolved.id) : null;
|
|
@@ -569,7 +592,7 @@ async function resolveAliasedVueImport(ctx, state, id, importer, isSsrRequest, h
|
|
|
569
592
|
}
|
|
570
593
|
if (state.cache.has(realPath) || fs.existsSync(realPath)) {
|
|
571
594
|
state.logger.log(`resolveId: resolved via Vite fallback ${id} to ${realPath}`);
|
|
572
|
-
return toVirtualId(realPath, isSsrRequest)
|
|
595
|
+
return `${toVirtualId(realPath, isSsrRequest)}${request.querySuffix}`;
|
|
573
596
|
}
|
|
574
597
|
return null;
|
|
575
598
|
}
|
|
@@ -631,6 +654,11 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
631
654
|
return null;
|
|
632
655
|
}
|
|
633
656
|
if (!id.endsWith(".vue")) {
|
|
657
|
+
const ssrExternalVueRequest = isSsrRequest ? resolveSsrExternalVueRequest(id) : null;
|
|
658
|
+
if (ssrExternalVueRequest) return {
|
|
659
|
+
id: ssrExternalVueRequest,
|
|
660
|
+
external: true
|
|
661
|
+
};
|
|
634
662
|
if (!id.startsWith("./") && !id.startsWith("../") && !id.startsWith("/")) {
|
|
635
663
|
const isVueRuntime = isVueRuntimeRequest(id);
|
|
636
664
|
const aliasRequest = resolveAliasRequest(state, id);
|
|
@@ -747,13 +775,14 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
747
775
|
return null;
|
|
748
776
|
}
|
|
749
777
|
}
|
|
750
|
-
if (
|
|
778
|
+
if (shouldCompileVueSfcRequest(request)) {
|
|
751
779
|
const handleNodeModules = state.initialized ? state.mergedOptions.handleNodeModulesVue ?? true : true;
|
|
752
|
-
|
|
780
|
+
const vueRequestPath = request.path;
|
|
781
|
+
if (!handleNodeModules && vueRequestPath.includes("node_modules")) {
|
|
753
782
|
state.logger.log(`resolveId: skipping node_modules import ${id}`);
|
|
754
783
|
return null;
|
|
755
784
|
}
|
|
756
|
-
const resolved = resolveVuePath(state,
|
|
785
|
+
const resolved = resolveVuePath(state, vueRequestPath, importer);
|
|
757
786
|
const fileExists = fs.existsSync(resolved);
|
|
758
787
|
if (!fileExists) {
|
|
759
788
|
const aliased = await resolveAliasedVueImport(ctx, state, id, importer, isSsrRequest, handleNodeModules);
|
|
@@ -770,7 +799,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
770
799
|
}
|
|
771
800
|
const hasCache = state.cache.has(resolved);
|
|
772
801
|
state.logger.log(`resolveId: id=${id}, resolved=${resolved}, hasCache=${hasCache}, fileExists=${fileExists}, importer=${importer ?? "none"}`);
|
|
773
|
-
if (hasCache || fileExists) return toVirtualId(resolved, isSsrRequest)
|
|
802
|
+
if (hasCache || fileExists) return `${toVirtualId(resolved, isSsrRequest)}${request.querySuffix}`;
|
|
774
803
|
}
|
|
775
804
|
return null;
|
|
776
805
|
}
|
|
@@ -805,6 +834,9 @@ function getVirtualModuleDefines(state, ssr) {
|
|
|
805
834
|
...ssr ? state.serverViteDefine : state.clientViteDefine
|
|
806
835
|
};
|
|
807
836
|
}
|
|
837
|
+
function normalizeVueServerRendererImport(code) {
|
|
838
|
+
return code.replace(/\bfrom\s+(['"])@vue\/server-renderer\1/g, "from \"vue/server-renderer\"");
|
|
839
|
+
}
|
|
808
840
|
function findMacroArtifactModule(state, realPath, ssr, kind) {
|
|
809
841
|
const cache = getEnvironmentCache(state, ssr);
|
|
810
842
|
realPath = classifyVitePluginRequest(realPath).normalizedVuePath;
|
|
@@ -880,13 +912,6 @@ function loadHook(state, id, loadOptions) {
|
|
|
880
912
|
if (request.isVueSfcPath) {
|
|
881
913
|
const artifactLoad = loadDefinePageMetaArtifact(state, realPath, !!loadOptions?.ssr);
|
|
882
914
|
if (artifactLoad) return artifactLoad;
|
|
883
|
-
if (fs.existsSync(realPath)) {
|
|
884
|
-
const setupMatch = fs.readFileSync(realPath, "utf-8").match(/<script\s+setup[^>]*>([\s\S]*?)<\/script>/);
|
|
885
|
-
if (setupMatch) return {
|
|
886
|
-
code: `${setupMatch[1]}\nexport default {}`,
|
|
887
|
-
map: null
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
915
|
return {
|
|
891
916
|
code: "export default {}",
|
|
892
917
|
map: null
|
|
@@ -922,14 +947,15 @@ function loadHook(state, id, loadOptions) {
|
|
|
922
947
|
...compiled,
|
|
923
948
|
css: resolveCssImports(compiled.css, realPath, state.cssAliasRules, state.server !== null, currentBase)
|
|
924
949
|
};
|
|
925
|
-
const
|
|
950
|
+
const generatedOutput = generateOutput(compiled, {
|
|
926
951
|
isProduction: state.isProduction,
|
|
927
952
|
isDev: state.server !== null && !isSsr,
|
|
928
953
|
ssr: isSsr,
|
|
929
954
|
hmrUpdateType: pendingHmrUpdateType,
|
|
930
955
|
extractCss: state.extractCss,
|
|
931
956
|
filePath: realPath
|
|
932
|
-
})
|
|
957
|
+
});
|
|
958
|
+
const output = rewriteStaticAssetUrls(rewriteDynamicTemplateImports(isSsr ? normalizeVueServerRendererImport(generatedOutput) : generatedOutput, state.dynamicImportAliasRules), state.dynamicImportAliasRules);
|
|
933
959
|
if (!loadOptions?.ssr) state.pendingHmrUpdateTypes.delete(realPath);
|
|
934
960
|
return {
|
|
935
961
|
code: output,
|
|
@@ -1348,6 +1374,9 @@ function vize(options = {}) {
|
|
|
1348
1374
|
},
|
|
1349
1375
|
generateBundle() {
|
|
1350
1376
|
handleGenerateBundleHook(state, this.emitFile.bind(this));
|
|
1377
|
+
},
|
|
1378
|
+
closeBundle() {
|
|
1379
|
+
if (state.server === null) clearBuildCaches(state);
|
|
1351
1380
|
}
|
|
1352
1381
|
},
|
|
1353
1382
|
createPostTransformPlugin(state)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.113.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@vizejs/native": "0.
|
|
40
|
+
"@vizejs/native": "0.113.0",
|
|
41
41
|
"tinyglobby": "0.2.16",
|
|
42
|
-
"vize": "0.
|
|
42
|
+
"vize": "0.113.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "25.7.0",
|