@vizejs/vite-plugin 0.104.0 → 0.106.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 +3 -1
- package/dist/index.mjs +69 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -15,9 +15,11 @@ High-performance native Vite plugin for Vue SFC compilation powered by [Vize](ht
|
|
|
15
15
|
Install `vp` once from the [Vite+ install guide](https://viteplus.dev/guide/install), then add the packages:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
vp install -D @vizejs/vite-plugin
|
|
18
|
+
vp install -D @vizejs/vite-plugin
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
Add `vize` as a direct dependency only if your project imports shared config helpers from `"vize"` (see [Shared Config](../docs/content/guide/vite-plugin.md#shared-config)).
|
|
22
|
+
|
|
21
23
|
## Usage
|
|
22
24
|
|
|
23
25
|
### Vite
|
package/dist/index.mjs
CHANGED
|
@@ -503,6 +503,43 @@ function resolveBareImportCandidatesWithNode(state, id, importer, resolvedId) {
|
|
|
503
503
|
}
|
|
504
504
|
return null;
|
|
505
505
|
}
|
|
506
|
+
function findPackageRoot(resolvedFile) {
|
|
507
|
+
let current = path.dirname(resolvedFile);
|
|
508
|
+
while (current !== path.dirname(current)) {
|
|
509
|
+
if (fs.existsSync(path.join(current, "package.json"))) return current;
|
|
510
|
+
current = path.dirname(current);
|
|
511
|
+
}
|
|
512
|
+
return null;
|
|
513
|
+
}
|
|
514
|
+
function resolveVueBundlerEntryWithNode(state, id, importer) {
|
|
515
|
+
const { request, querySuffix } = splitViteIdQuery(id);
|
|
516
|
+
if (request !== "vue") return null;
|
|
517
|
+
const packageJson = resolveBareImportWithNode(state, "vue/package.json", importer);
|
|
518
|
+
const resolvedVue = packageJson ? null : resolveBareImportWithNode(state, "vue", importer);
|
|
519
|
+
const packageRoot = packageJson ? path.dirname(packageJson) : resolvedVue ? findPackageRoot(resolvedVue) : null;
|
|
520
|
+
if (!packageRoot) return null;
|
|
521
|
+
for (const relativeEntry of [
|
|
522
|
+
"dist/vue.runtime.esm-bundler.js",
|
|
523
|
+
"dist/vue.esm-bundler.js",
|
|
524
|
+
"index.mjs"
|
|
525
|
+
]) {
|
|
526
|
+
const entry = path.join(packageRoot, relativeEntry);
|
|
527
|
+
if (fs.existsSync(entry)) return `${entry}${querySuffix}`;
|
|
528
|
+
}
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
function isVueRuntimeRequest(id) {
|
|
532
|
+
return splitViteIdQuery(id).request === "vue";
|
|
533
|
+
}
|
|
534
|
+
function isVuePackageEntry(id) {
|
|
535
|
+
const { request } = splitViteIdQuery(id);
|
|
536
|
+
const normalized = request.split(path.sep).join("/");
|
|
537
|
+
return normalized.endsWith("/node_modules/vue/index.js") || normalized.endsWith("/node_modules/vue/dist/vue.runtime.esm-bundler.js") || normalized.endsWith("/node_modules/vue/dist/vue.esm-bundler.js") || normalized.includes("/node_modules/.pnpm/vue@") || normalized.includes("/node_modules/.pnpm/@vue+");
|
|
538
|
+
}
|
|
539
|
+
function isOptimizedVueDependency(id) {
|
|
540
|
+
const { request } = splitViteIdQuery(id);
|
|
541
|
+
return request.split(path.sep).join("/").includes("/node_modules/.vite/deps/vue.");
|
|
542
|
+
}
|
|
506
543
|
function normalizeResolvedVuePath(id) {
|
|
507
544
|
return normalizeViteResolvedVuePath(id);
|
|
508
545
|
}
|
|
@@ -595,8 +632,9 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
595
632
|
}
|
|
596
633
|
if (!id.endsWith(".vue")) {
|
|
597
634
|
if (!id.startsWith("./") && !id.startsWith("../") && !id.startsWith("/")) {
|
|
635
|
+
const isVueRuntime = isVueRuntimeRequest(id);
|
|
598
636
|
const aliasRequest = resolveAliasRequest(state, id);
|
|
599
|
-
if (aliasRequest && isViteBareSpecifier(aliasRequest)) {
|
|
637
|
+
if (!isVueRuntime && aliasRequest && isViteBareSpecifier(aliasRequest)) {
|
|
600
638
|
const nodeResolved = resolveBareImportCandidatesWithNode(state, id, cleanImporter);
|
|
601
639
|
if (nodeResolved) {
|
|
602
640
|
state.logger.log(`resolveId: resolved aliased bare ${id} to ${nodeResolved} via Node fallback`);
|
|
@@ -612,7 +650,28 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
612
650
|
...resolved,
|
|
613
651
|
id: normalizedFsId
|
|
614
652
|
};
|
|
653
|
+
if (isVueRuntime && state.server !== null && !isOptimizedVueDependency(resolved.id)) {
|
|
654
|
+
state.logger.log(`resolveId: deferring Vue runtime ${resolved.id} to Vite optimizer`);
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
if (isVueRuntime && isVuePackageEntry(resolved.id)) {
|
|
658
|
+
const vueBundlerEntry = resolveVueBundlerEntryWithNode(state, id, cleanImporter);
|
|
659
|
+
if (vueBundlerEntry) {
|
|
660
|
+
state.logger.log(`resolveId: resolved Vue runtime to ${vueBundlerEntry}`);
|
|
661
|
+
return vueBundlerEntry;
|
|
662
|
+
}
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
615
665
|
if (isViteBareSpecifier(resolved.id)) {
|
|
666
|
+
if (isVueRuntime) {
|
|
667
|
+
const vueBundlerEntry = isBuild ? resolveVueBundlerEntryWithNode(state, id, cleanImporter) : null;
|
|
668
|
+
if (vueBundlerEntry) {
|
|
669
|
+
state.logger.log(`resolveId: resolved Vue runtime to ${vueBundlerEntry}`);
|
|
670
|
+
return vueBundlerEntry;
|
|
671
|
+
}
|
|
672
|
+
state.logger.log(`resolveId: deferring bare Vue runtime ${id} to Vite`);
|
|
673
|
+
return null;
|
|
674
|
+
}
|
|
616
675
|
const nodeResolved = resolveBareImportCandidatesWithNode(state, id, cleanImporter, resolved.id);
|
|
617
676
|
if (nodeResolved) {
|
|
618
677
|
state.logger.log(`resolveId: normalized bare ${id} to ${nodeResolved} via Node fallback`);
|
|
@@ -623,6 +682,15 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
623
682
|
return resolved;
|
|
624
683
|
}
|
|
625
684
|
} catch {}
|
|
685
|
+
if (isVueRuntime) {
|
|
686
|
+
const vueBundlerEntry = isBuild ? resolveVueBundlerEntryWithNode(state, id, cleanImporter) : null;
|
|
687
|
+
if (vueBundlerEntry) {
|
|
688
|
+
state.logger.log(`resolveId: resolved Vue runtime to ${vueBundlerEntry}`);
|
|
689
|
+
return vueBundlerEntry;
|
|
690
|
+
}
|
|
691
|
+
state.logger.log(`resolveId: deferring Vue runtime ${id} to Vite`);
|
|
692
|
+
return null;
|
|
693
|
+
}
|
|
626
694
|
const nodeResolved = resolveBareImportCandidatesWithNode(state, id, cleanImporter);
|
|
627
695
|
if (nodeResolved) {
|
|
628
696
|
state.logger.log(`resolveId: resolved bare ${id} to ${nodeResolved} via Node fallback`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.106.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.106.0",
|
|
41
41
|
"tinyglobby": "0.2.16",
|
|
42
|
-
"vize": "0.
|
|
42
|
+
"vize": "0.106.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "25.7.0",
|