@vizejs/vite-plugin 0.26.0 → 0.29.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.ts +5 -0
- package/dist/index.js +44 -13
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -413,6 +413,11 @@ interface VizeConfig {
|
|
|
413
413
|
//#endregion
|
|
414
414
|
//#region src/types.d.ts
|
|
415
415
|
interface VizeOptions {
|
|
416
|
+
/**
|
|
417
|
+
* Override the public base used for dev-time asset URLs such as /@fs paths.
|
|
418
|
+
* Useful for frameworks like Nuxt that serve Vite from a subpath (e.g. /_nuxt/).
|
|
419
|
+
*/
|
|
420
|
+
devUrlBase?: string;
|
|
416
421
|
/**
|
|
417
422
|
* Files to include in compilation
|
|
418
423
|
* @default /\.vue$/
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { glob } from "tinyglobby";
|
|
5
5
|
import * as native from "@vizejs/native";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
6
7
|
import { pathToFileURL } from "node:url";
|
|
7
8
|
import { transformWithOxc } from "vite";
|
|
8
|
-
import { createRequire } from "node:module";
|
|
9
9
|
|
|
10
10
|
//#region src/hmr.ts
|
|
11
11
|
function didHashChange(prevHash, nextHash) {
|
|
@@ -670,6 +670,29 @@ function resolveVuePath(state, id, importer) {
|
|
|
670
670
|
if (!path.isAbsolute(resolved)) resolved = path.resolve(state.root, resolved);
|
|
671
671
|
return path.normalize(resolved);
|
|
672
672
|
}
|
|
673
|
+
function normalizeRequireBase(importer) {
|
|
674
|
+
if (!importer) return null;
|
|
675
|
+
let normalized = importer;
|
|
676
|
+
if (isVizeVirtual(normalized)) normalized = fromVirtualId(normalized);
|
|
677
|
+
else if (normalized.startsWith("\0") && normalized.endsWith("?macro=true")) normalized = normalized.slice(1).replace("?macro=true", "");
|
|
678
|
+
return normalized.split("?")[0] ?? null;
|
|
679
|
+
}
|
|
680
|
+
function resolveBareImportWithNode(state, id, importer) {
|
|
681
|
+
const [request, queryPart] = id.split("?");
|
|
682
|
+
const querySuffix = queryPart ? `?${queryPart}` : "";
|
|
683
|
+
const candidates = [normalizeRequireBase(importer), path.join(state.root, "package.json")].filter((candidate) => candidate != null);
|
|
684
|
+
const seen = new Set();
|
|
685
|
+
for (const candidate of candidates) {
|
|
686
|
+
if (seen.has(candidate)) continue;
|
|
687
|
+
seen.add(candidate);
|
|
688
|
+
try {
|
|
689
|
+
const requireFromBase = createRequire(candidate);
|
|
690
|
+
const resolved = requireFromBase.resolve(request);
|
|
691
|
+
return `${resolved}${querySuffix}`;
|
|
692
|
+
} catch {}
|
|
693
|
+
}
|
|
694
|
+
return null;
|
|
695
|
+
}
|
|
673
696
|
async function resolveIdHook(ctx, state, id, importer) {
|
|
674
697
|
const isBuild = state.server === null;
|
|
675
698
|
if (id.startsWith("\0")) {
|
|
@@ -728,17 +751,24 @@ async function resolveIdHook(ctx, state, id, importer) {
|
|
|
728
751
|
if (!id.endsWith(".vue")) {
|
|
729
752
|
if (!id.startsWith("./") && !id.startsWith("../") && !id.startsWith("/")) {
|
|
730
753
|
const matchesAlias = state.cssAliasRules.some((rule) => id === rule.find || id.startsWith(rule.find + "/"));
|
|
731
|
-
if (!matchesAlias)
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
754
|
+
if (!matchesAlias) {
|
|
755
|
+
try {
|
|
756
|
+
const resolved = await ctx.resolve(id, cleanImporter, { skipSelf: true });
|
|
757
|
+
if (resolved) {
|
|
758
|
+
state.logger.log(`resolveId: resolved bare ${id} to ${resolved.id} via Vite resolver`);
|
|
759
|
+
if (isBuild && resolved.id.startsWith("/@fs/")) return {
|
|
760
|
+
...resolved,
|
|
761
|
+
id: normalizeFsIdForBuild(resolved.id)
|
|
762
|
+
};
|
|
763
|
+
return resolved;
|
|
764
|
+
}
|
|
765
|
+
} catch {}
|
|
766
|
+
const nodeResolved = resolveBareImportWithNode(state, id, cleanImporter);
|
|
767
|
+
if (nodeResolved) {
|
|
768
|
+
state.logger.log(`resolveId: resolved bare ${id} to ${nodeResolved} via Node fallback`);
|
|
769
|
+
return nodeResolved;
|
|
740
770
|
}
|
|
741
|
-
}
|
|
771
|
+
}
|
|
742
772
|
return null;
|
|
743
773
|
}
|
|
744
774
|
try {
|
|
@@ -1191,8 +1221,9 @@ function vize(options = {}) {
|
|
|
1191
1221
|
state.root = options.root ?? resolvedConfig.root;
|
|
1192
1222
|
state.isProduction = options.isProduction ?? resolvedConfig.isProduction;
|
|
1193
1223
|
const isSsrBuild = !!resolvedConfig.build?.ssr;
|
|
1194
|
-
|
|
1195
|
-
|
|
1224
|
+
const currentBase = resolvedConfig.command === "serve" ? options.devUrlBase ?? resolvedConfig.base ?? "/" : resolvedConfig.base ?? "/";
|
|
1225
|
+
if (isSsrBuild) state.serverViteBase = currentBase;
|
|
1226
|
+
else state.clientViteBase = currentBase;
|
|
1196
1227
|
state.extractCss = state.isProduction;
|
|
1197
1228
|
const isSsr = !!resolvedConfig.build?.ssr;
|
|
1198
1229
|
const envDefine = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"tsdown": "^0.9.0",
|
|
38
38
|
"tsx": "^4.21.0",
|
|
39
39
|
"typescript": "~5.6.0",
|
|
40
|
-
"vite": "^8.0.0
|
|
40
|
+
"vite": "^8.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"vite": "^
|
|
43
|
+
"vite": "^8.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"tinyglobby": "^0.2.0",
|
|
47
|
-
"@vizejs/native": "0.
|
|
47
|
+
"@vizejs/native": "0.29.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsdown",
|