@vizejs/vite-plugin 0.405.0 → 0.406.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.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as VizeInspectorLintPlanProvider, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeVueFeatures, l as VizeVueVersion, m as VizeConfig, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-
|
|
1
|
+
import { a as VizeInspectorLintPlanProvider, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeVueFeatures, l as VizeVueVersion, m as VizeConfig, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-bT8mHbbM.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/virtual.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -775,12 +775,19 @@ function isPluginVueCustomElement(options, filePath) {
|
|
|
775
775
|
//#region src/plugin/precompile.ts
|
|
776
776
|
const DEFAULT_PRECOMPILE_IGNORE_PATTERNS = [
|
|
777
777
|
"node_modules/**",
|
|
778
|
+
"**/node_modules/**",
|
|
778
779
|
"dist/**",
|
|
780
|
+
"**/dist/**",
|
|
779
781
|
".git/**",
|
|
782
|
+
"**/.git/**",
|
|
780
783
|
".nuxt/**",
|
|
784
|
+
"**/.nuxt/**",
|
|
781
785
|
".output/**",
|
|
786
|
+
"**/.output/**",
|
|
782
787
|
".nitro/**",
|
|
783
|
-
"
|
|
788
|
+
"**/.nitro/**",
|
|
789
|
+
"coverage/**",
|
|
790
|
+
"**/coverage/**"
|
|
784
791
|
];
|
|
785
792
|
function isPrecompileSfcPath(path) {
|
|
786
793
|
return path.endsWith(".vue");
|
|
@@ -1687,7 +1694,8 @@ async function compileAll(state) {
|
|
|
1687
1694
|
const sfcFiles = (await glob(state.scanPatterns, {
|
|
1688
1695
|
cwd: state.root,
|
|
1689
1696
|
ignore: state.ignorePatterns,
|
|
1690
|
-
absolute: true
|
|
1697
|
+
absolute: true,
|
|
1698
|
+
followSymbolicLinks: false
|
|
1691
1699
|
})).filter(isPrecompileSfcPath);
|
|
1692
1700
|
const currentMetadata = /* @__PURE__ */ new Map();
|
|
1693
1701
|
for (const file of sfcFiles) try {
|
|
@@ -1840,6 +1848,110 @@ function isProjectSourceImporter(root, importer) {
|
|
|
1840
1848
|
}
|
|
1841
1849
|
}
|
|
1842
1850
|
//#endregion
|
|
1851
|
+
//#region src/plugin/package-imports.ts
|
|
1852
|
+
const PACKAGE_IMPORT_CONDITIONS = [
|
|
1853
|
+
"browser",
|
|
1854
|
+
"import",
|
|
1855
|
+
"module",
|
|
1856
|
+
"default",
|
|
1857
|
+
"node",
|
|
1858
|
+
"require",
|
|
1859
|
+
"types"
|
|
1860
|
+
];
|
|
1861
|
+
function resolvePackageJsonImportFromVizeImporter(state, id, importer) {
|
|
1862
|
+
const { request, querySuffix } = splitViteIdQuery(id);
|
|
1863
|
+
if (!request.startsWith("#")) return null;
|
|
1864
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1865
|
+
for (const base of createViteBareImportBases(state.root, importer)) {
|
|
1866
|
+
const packageRoot = findPackageScope(base);
|
|
1867
|
+
if (!packageRoot || seen.has(packageRoot)) continue;
|
|
1868
|
+
seen.add(packageRoot);
|
|
1869
|
+
const direct = tryRequireResolve(path.join(packageRoot, "package.json"), request, querySuffix);
|
|
1870
|
+
if (direct) return direct;
|
|
1871
|
+
const imports = readPackageImports(packageRoot);
|
|
1872
|
+
const target = imports ? resolvePackageImportTarget(imports, request) : null;
|
|
1873
|
+
const resolved = target ? resolvePackageImportTargetPath(packageRoot, target, importer, querySuffix) : null;
|
|
1874
|
+
if (resolved) return resolved;
|
|
1875
|
+
}
|
|
1876
|
+
return null;
|
|
1877
|
+
}
|
|
1878
|
+
function findPackageScope(base) {
|
|
1879
|
+
let current = fs.existsSync(base) && fs.statSync(base).isDirectory() ? base : path.dirname(base);
|
|
1880
|
+
while (current !== path.dirname(current)) {
|
|
1881
|
+
if (fs.existsSync(path.join(current, "package.json"))) return current;
|
|
1882
|
+
current = path.dirname(current);
|
|
1883
|
+
}
|
|
1884
|
+
return null;
|
|
1885
|
+
}
|
|
1886
|
+
function tryRequireResolve(base, request, querySuffix) {
|
|
1887
|
+
try {
|
|
1888
|
+
return `${createRequire(base).resolve(request)}${querySuffix}`;
|
|
1889
|
+
} catch {
|
|
1890
|
+
return null;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
function readPackageImports(packageRoot) {
|
|
1894
|
+
try {
|
|
1895
|
+
const json = JSON.parse(fs.readFileSync(path.join(packageRoot, "package.json"), "utf8"));
|
|
1896
|
+
return isPlainObject(json.imports) ? json.imports : null;
|
|
1897
|
+
} catch {
|
|
1898
|
+
return null;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
function resolvePackageImportTarget(imports, request) {
|
|
1902
|
+
const exact = resolveConditionalTarget(imports[request]);
|
|
1903
|
+
if (exact) return exact;
|
|
1904
|
+
let best = null;
|
|
1905
|
+
for (const [key, value] of Object.entries(imports)) {
|
|
1906
|
+
const starIndex = key.indexOf("*");
|
|
1907
|
+
if (starIndex === -1) continue;
|
|
1908
|
+
const prefix = key.slice(0, starIndex);
|
|
1909
|
+
const suffix = key.slice(starIndex + 1);
|
|
1910
|
+
if (!request.startsWith(prefix) || !request.endsWith(suffix)) continue;
|
|
1911
|
+
const target = resolveConditionalTarget(value);
|
|
1912
|
+
if (!target || best && key.length <= best.keyLength) continue;
|
|
1913
|
+
const matched = request.slice(prefix.length, request.length - suffix.length);
|
|
1914
|
+
best = {
|
|
1915
|
+
keyLength: key.length,
|
|
1916
|
+
target: target.replaceAll("*", matched)
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
return best?.target ?? null;
|
|
1920
|
+
}
|
|
1921
|
+
function resolveConditionalTarget(value) {
|
|
1922
|
+
if (typeof value === "string") return value;
|
|
1923
|
+
if (Array.isArray(value)) {
|
|
1924
|
+
for (const item of value) {
|
|
1925
|
+
const target = resolveConditionalTarget(item);
|
|
1926
|
+
if (target) return target;
|
|
1927
|
+
}
|
|
1928
|
+
return null;
|
|
1929
|
+
}
|
|
1930
|
+
if (!isPlainObject(value)) return null;
|
|
1931
|
+
for (const condition of PACKAGE_IMPORT_CONDITIONS) {
|
|
1932
|
+
const target = resolveConditionalTarget(value[condition]);
|
|
1933
|
+
if (target) return target;
|
|
1934
|
+
}
|
|
1935
|
+
return null;
|
|
1936
|
+
}
|
|
1937
|
+
function resolvePackageImportTargetPath(packageRoot, target, importer, querySuffix) {
|
|
1938
|
+
const { request } = splitViteIdQuery(target);
|
|
1939
|
+
if (request.startsWith("./")) {
|
|
1940
|
+
const resolved = resolveViteRelativeImport(request, path.join(packageRoot, "package.json"));
|
|
1941
|
+
return resolved && isInsidePackage(packageRoot, resolved) ? `${resolved}${querySuffix}` : null;
|
|
1942
|
+
}
|
|
1943
|
+
if (request.startsWith("../")) return null;
|
|
1944
|
+
if (path.isAbsolute(request)) return fs.existsSync(request) ? `${request}${querySuffix}` : null;
|
|
1945
|
+
return tryRequireResolve(importer, request, querySuffix);
|
|
1946
|
+
}
|
|
1947
|
+
function isPlainObject(value) {
|
|
1948
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1949
|
+
}
|
|
1950
|
+
function isInsidePackage(packageRoot, resolved) {
|
|
1951
|
+
const relative = path.relative(packageRoot, splitViteIdQuery(resolved).request);
|
|
1952
|
+
return relative === "" || !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
1953
|
+
}
|
|
1954
|
+
//#endregion
|
|
1843
1955
|
//#region src/plugin/resolve-relative-vue.ts
|
|
1844
1956
|
function cleanVueSfcImporter(importer, request) {
|
|
1845
1957
|
let cleanImporter = request?.normalizedFsId ?? request?.normalizedVuePath ?? importer;
|
|
@@ -2303,10 +2415,12 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
2303
2415
|
state.logger.log(`resolveId from virtual: id=${id}, cleanImporter=${cleanImporter}`);
|
|
2304
2416
|
const relativeVueResolved = await resolveRelativeVueSfcImport(ctx, state, id, cleanImporter, isSsrRequest, isDependencyScan, resolveWithVite);
|
|
2305
2417
|
if (relativeVueResolved) return relativeVueResolved;
|
|
2306
|
-
if (id.startsWith("#"))
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2418
|
+
if (id.startsWith("#")) {
|
|
2419
|
+
try {
|
|
2420
|
+
const resolved = await resolveWithVite(ctx, state, id, cleanImporter, { skipSelf: true });
|
|
2421
|
+
if (resolved) return resolved;
|
|
2422
|
+
} catch {}
|
|
2423
|
+
return resolvePackageJsonImportFromVizeImporter(state, id, cleanImporter);
|
|
2310
2424
|
}
|
|
2311
2425
|
if (!id.endsWith(".vue")) {
|
|
2312
2426
|
const ssrExternalVueRequest = isSsrRequest ? resolveSsrExternalVueRequest(id) : null;
|
|
@@ -1067,8 +1067,9 @@ interface VizeOptions extends ExperimentalPluginOptions {
|
|
|
1067
1067
|
*/
|
|
1068
1068
|
precompileBatchSize?: number;
|
|
1069
1069
|
/**
|
|
1070
|
-
* Glob patterns to ignore during pre-compilation
|
|
1071
|
-
*
|
|
1070
|
+
* Glob patterns to ignore during pre-compilation. Defaults exclude common
|
|
1071
|
+
* dependency and build-output directories at the project root and at any
|
|
1072
|
+
* workspace package depth.
|
|
1072
1073
|
*/
|
|
1073
1074
|
ignorePatterns?: string[];
|
|
1074
1075
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.406.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@vizejs/native": "0.
|
|
48
|
+
"@vizejs/native": "0.406.0",
|
|
49
49
|
"oxc-parser": "0.144.0",
|
|
50
50
|
"tinyglobby": "0.2.17",
|
|
51
|
-
"vize": "0.
|
|
51
|
+
"vize": "0.406.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "25.9.2",
|