@vizejs/vite-plugin 0.429.2 → 0.431.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 UserConfigExport, n as CompiledModule, o as VizeInspectorLintPlanRequest, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv, y as VizeConfig } from "./types-VGJL5xEW.mjs";
1
+ import { a as VizeInspectorLintPlanProvider, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeVueFeatures, l as VizeVueVersion, m as UserConfigExport, n as CompiledModule, o as VizeInspectorLintPlanRequest, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv, y as VizeConfig } from "./types-NyrQJOwS.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/virtual.d.ts
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as rewriteStaticAssetUrls, t as vize } from "./plugin-Bu9B_IUr.mjs";
1
+ import { n as rewriteStaticAssetUrls, t as vize } from "./plugin-DZV6zTPW.mjs";
2
2
  import { a as vizeConfigStore, i as resolveConfigExport, n as defineConfig, r as loadConfig, t as VIZE_CONFIG_FILE_ENV } from "./config-PP6EAmWc.mjs";
3
3
  //#region src/index.ts
4
4
  const __internal = { rewriteStaticAssetUrls };
@@ -1,4 +1,4 @@
1
- import { f as ResolvedVizeConfig } from "../types-VGJL5xEW.mjs";
1
+ import { f as ResolvedVizeConfig } from "../types-NyrQJOwS.mjs";
2
2
  import { ResolvedConfig } from "vite";
3
3
 
4
4
  //#region src/internal/config-bridge.d.ts
@@ -1,4 +1,4 @@
1
- import { n as runTask } from "../runner-Tb17R9ol.mjs";
1
+ import { n as runTask } from "../runner-D0tDOiOp.mjs";
2
2
  //#region src/internal/vite-plus-task.ts
3
3
  try {
4
4
  process.exitCode = await runTask(process.argv.slice(2));
@@ -0,0 +1,2 @@
1
+ import { t as vize } from "./plugin-DZV6zTPW.mjs";
2
+ export { vize };
@@ -891,26 +891,27 @@ function toNativePrecompileMetadataEntries(metadata) {
891
891
  function getEnvironmentCache(state, ssr) {
892
892
  return ssr ? state.ssrCache : state.cache;
893
893
  }
894
- function getCompileOptionsForRequest(state, ssr) {
894
+ function getCompileOptionsForRequest(state, ssr, file) {
895
+ const mergedOptions = file === void 0 ? state.mergedOptions : state.fileCompilerOptions?.(file) ?? state.mergedOptions;
895
896
  const options = {
896
- sourceMap: state.mergedOptions?.sourceMap ?? (!state.isProduction || !!state.viteBuildSourcemap),
897
+ sourceMap: mergedOptions?.sourceMap ?? (!state.isProduction || !!state.viteBuildSourcemap),
897
898
  ssr,
898
- vapor: !ssr && (state.mergedOptions?.vapor ?? false),
899
- customRenderer: state.mergedOptions?.customRenderer ?? false,
900
- templateSyntax: state.mergedOptions?.templateSyntax ?? "standard",
899
+ vapor: !ssr && (mergedOptions?.vapor ?? false),
900
+ customRenderer: mergedOptions?.customRenderer ?? false,
901
+ templateSyntax: mergedOptions?.templateSyntax ?? "standard",
901
902
  templateComments: !state.isProduction,
902
- ...resolvePluginVueCompileOptions(state.mergedOptions ?? {})
903
+ ...resolvePluginVueCompileOptions(mergedOptions ?? {})
903
904
  };
904
- if (state.mergedOptions?.customElements !== void 0) options.customElements = state.mergedOptions.customElements;
905
- if (state.mergedOptions?.mode !== void 0) options.mode = state.mergedOptions.mode;
906
- if (state.mergedOptions?.runtimeModuleName !== void 0) options.runtimeModuleName = state.mergedOptions.runtimeModuleName;
907
- if (state.mergedOptions?.runtimeGlobalName !== void 0) options.runtimeGlobalName = state.mergedOptions.runtimeGlobalName;
908
- if (state.mergedOptions?.vueVersion !== void 0) options.vueVersion = state.mergedOptions.vueVersion;
909
- if (state.mergedOptions?.experimentalInTagComments) options.experimentalInTagComments = true;
910
- if (state.mergedOptions?.experimentalPatternedTemplate) options.experimentalPatternedTemplate = true;
911
- if (state.mergedOptions?.experimentalSelfComponent) options.experimentalSelfComponent = true;
912
- if (state.mergedOptions?.experimentalStrictSlotChildren) options.experimentalStrictSlotChildren = true;
913
- if (state.mergedOptions?.experimentalServerScript) options.experimentalServerScript = true;
905
+ if (mergedOptions?.customElements !== void 0) options.customElements = mergedOptions.customElements;
906
+ if (mergedOptions?.mode !== void 0) options.mode = mergedOptions.mode;
907
+ if (mergedOptions?.runtimeModuleName !== void 0) options.runtimeModuleName = mergedOptions.runtimeModuleName;
908
+ if (mergedOptions?.runtimeGlobalName !== void 0) options.runtimeGlobalName = mergedOptions.runtimeGlobalName;
909
+ if (mergedOptions?.vueVersion !== void 0) options.vueVersion = mergedOptions.vueVersion;
910
+ if (mergedOptions?.experimentalInTagComments) options.experimentalInTagComments = true;
911
+ if (mergedOptions?.experimentalPatternedTemplate) options.experimentalPatternedTemplate = true;
912
+ if (mergedOptions?.experimentalSelfComponent) options.experimentalSelfComponent = true;
913
+ if (mergedOptions?.experimentalStrictSlotChildren) options.experimentalStrictSlotChildren = true;
914
+ if (mergedOptions?.experimentalServerScript) options.experimentalServerScript = true;
914
915
  if (state.isProduction) {
915
916
  options.isProd = true;
916
917
  if (!ssr && options.mode !== "function") options.inlineTemplate = true;
@@ -1729,6 +1730,32 @@ function writeManifest(file, container, onDiagnostic) {
1729
1730
  }
1730
1731
  }
1731
1732
  //#endregion
1733
+ //#region src/plugin/precompile-scopes.ts
1734
+ function compileScopedBatch(files, state) {
1735
+ const groups = /* @__PURE__ */ new Map();
1736
+ for (const file of files) {
1737
+ const options = getCompileOptionsForRequest(state, false, file.path);
1738
+ const key = JSON.stringify(buildCompileBatchOptions(options));
1739
+ const group = groups.get(key);
1740
+ if (group) group.files.push(file);
1741
+ else groups.set(key, {
1742
+ options,
1743
+ files: [file]
1744
+ });
1745
+ }
1746
+ const results = [];
1747
+ let timeMs = 0;
1748
+ for (const group of groups.values()) {
1749
+ const result = compileBatch(group.files, state.cache, group.options);
1750
+ results.push(...result.results);
1751
+ timeMs += result.timeMs;
1752
+ }
1753
+ return {
1754
+ results,
1755
+ timeMs
1756
+ };
1757
+ }
1758
+ //#endregion
1732
1759
  //#region src/plugin/precompile-run.ts
1733
1760
  /**
1734
1761
  * The pre-compilation pass.
@@ -1745,38 +1772,16 @@ function writeManifest(file, container, onDiagnostic) {
1745
1772
  * that reaches the native compiler reaches the key with it.
1746
1773
  */
1747
1774
  function resolvePrecompileBatchOptions(state) {
1748
- const requestOptions = getCompileOptionsForRequest(state, false);
1749
- return {
1750
- sourceMap: requestOptions.sourceMap,
1751
- ssr: false,
1752
- vapor: state.mergedOptions.vapor ?? false,
1753
- mode: state.mergedOptions.mode,
1754
- customRenderer: state.mergedOptions.customRenderer ?? false,
1755
- customElements: state.mergedOptions.customElements,
1756
- templateSyntax: state.mergedOptions.templateSyntax ?? "standard",
1757
- experimentalInTagComments: state.mergedOptions.experimentalInTagComments ?? false,
1758
- experimentalPatternedTemplate: state.mergedOptions.experimentalPatternedTemplate ?? false,
1759
- experimentalSelfComponent: state.mergedOptions.experimentalSelfComponent ?? false,
1760
- experimentalStrictSlotChildren: state.mergedOptions.experimentalStrictSlotChildren ?? false,
1761
- experimentalServerScript: state.mergedOptions.experimentalServerScript ?? false,
1762
- runtimeModuleName: state.mergedOptions.runtimeModuleName,
1763
- runtimeGlobalName: state.mergedOptions.runtimeGlobalName,
1764
- vueVersion: state.mergedOptions.vueVersion,
1765
- whitespace: requestOptions.whitespace,
1766
- styleTrim: requestOptions.styleTrim,
1767
- templateCacheHandlers: requestOptions.templateCacheHandlers,
1768
- templateComments: requestOptions.templateComments,
1769
- templateHoistStatic: requestOptions.templateHoistStatic,
1770
- templatePrefixIdentifiers: requestOptions.templatePrefixIdentifiers,
1771
- inlineTemplate: requestOptions.inlineTemplate,
1772
- isProd: requestOptions.isProd
1773
- };
1775
+ return getCompileOptionsForRequest(state, false);
1774
1776
  }
1775
1777
  function openCacheForRun(state, batchOptions) {
1776
1778
  if (!state.root) return createDisabledPrecompileCache();
1777
1779
  return openPrecompileCache({
1778
1780
  root: state.root,
1779
- compileOptions: buildCompileBatchOptions(batchOptions),
1781
+ compileOptions: {
1782
+ options: buildCompileBatchOptions(batchOptions),
1783
+ scopes: state.compilerScopeIdentity
1784
+ },
1780
1785
  onDiagnostic: (message, error) => error === void 0 ? state.logger.warn(message) : state.logger.warn(message, error)
1781
1786
  });
1782
1787
  }
@@ -1820,8 +1825,7 @@ async function compileAll(state) {
1820
1825
  if (state.extractCss) state.collectedCss.delete(file);
1821
1826
  state.pendingHmrUpdateTypes.delete(file);
1822
1827
  }
1823
- const batchOptions = resolvePrecompileBatchOptions(state);
1824
- const cache = openCacheForRun(state, batchOptions);
1828
+ const cache = openCacheForRun(state, resolvePrecompileBatchOptions(state));
1825
1829
  const cacheEnabled = cache.file !== null;
1826
1830
  let successCount = 0;
1827
1831
  let restoredCount = 0;
@@ -1866,7 +1870,7 @@ async function compileAll(state) {
1866
1870
  });
1867
1871
  }
1868
1872
  if (fileContents.length === 0) continue;
1869
- const result = compileBatch(fileContents, state.cache, batchOptions);
1873
+ const result = compileScopedBatch(fileContents, state);
1870
1874
  const chunkFailedCount = result.results.filter((fileResult) => fileResult.errors.length > 0).length;
1871
1875
  failedCount += chunkFailedCount;
1872
1876
  successCount += result.results.length - chunkFailedCount;
@@ -2319,7 +2323,7 @@ function resolveVuePeerRuntimeEntryWithNode(state, id, importer) {
2319
2323
  const nodeResolved = resolveBareImportWithNode(state, id, importer);
2320
2324
  return nodeResolved ? resolveProjectLocalResolvedPath(state, nodeResolved) : null;
2321
2325
  }
2322
- function resolveVuePeerRuntimeEntryFromBaseWithNode(state, id, base) {
2326
+ function resolveVuePeerRuntimeEntryFromBaseWithNode(id, base) {
2323
2327
  const { request, querySuffix } = splitViteIdQuery(id);
2324
2328
  const packageName = getBarePackageName(request);
2325
2329
  if (!packageName || !VUE_PEER_RUNTIME_PACKAGES.has(packageName)) return null;
@@ -2330,13 +2334,12 @@ function resolveVuePeerRuntimeEntryFromBaseWithNode(state, id, base) {
2330
2334
  return null;
2331
2335
  }
2332
2336
  const packageRoot = path.dirname(packageJson);
2333
- if (!resolveProjectLocalResolvedPath(state, packageRoot)) return null;
2334
2337
  if (request === packageName) for (const relativeEntry of VUE_PEER_RUNTIME_ESM_ENTRIES.get(packageName) ?? ["index.mjs"]) {
2335
2338
  const entry = path.join(packageRoot, relativeEntry);
2336
2339
  if (fs.existsSync(entry)) return `${entry}${querySuffix}`;
2337
2340
  }
2338
2341
  try {
2339
- return resolveProjectLocalResolvedPath(state, `${createRequire(base).resolve(request)}${querySuffix}`);
2342
+ return `${createRequire(base).resolve(request)}${querySuffix}`;
2340
2343
  } catch {
2341
2344
  return null;
2342
2345
  }
@@ -2347,8 +2350,7 @@ function resolveProjectNuxtVuePeerRuntimeEntryWithNode(state, id) {
2347
2350
  const nuxtPackageJson = resolveBareImportWithNode(state, "nuxt/package.json", path.join(state.root, "package.json"));
2348
2351
  if (!nuxtPackageJson) return null;
2349
2352
  const nuxtPackageRoot = path.dirname(splitViteIdQuery(nuxtPackageJson).request);
2350
- if (!resolveProjectLocalResolvedPath(state, nuxtPackageRoot)) return null;
2351
- return resolveVuePeerRuntimeEntryFromBaseWithNode(state, id, path.join(state.root, "package.json")) ?? resolveVuePeerRuntimeEntryFromBaseWithNode(state, id, path.join(nuxtPackageRoot, "package.json"));
2353
+ return resolveVuePeerRuntimeEntryFromBaseWithNode(id, path.join(state.root, "package.json")) ?? resolveVuePeerRuntimeEntryFromBaseWithNode(id, path.join(nuxtPackageRoot, "package.json"));
2352
2354
  }
2353
2355
  function isOptimizedVueDependency(id) {
2354
2356
  const { request } = splitViteIdQuery(id);
@@ -2373,15 +2375,18 @@ function normalizeResolvedVuePath(id) {
2373
2375
  return normalizeViteResolvedVuePath(id);
2374
2376
  }
2375
2377
  async function resolveProjectVueRuntime(ctx, state, id, importer, isSsrRequest) {
2376
- if (isSsrRequest || !isProjectVueRuntimeRequest(id) || !isProjectLocalImporter(state, importer)) return null;
2377
- const isBuild = state.server === null;
2378
- const viteImporter = normalizeViteRequireBase(importer) ?? importer;
2378
+ if (isSsrRequest || !isProjectVueRuntimeRequest(id)) return null;
2379
2379
  if (isVuePeerRuntimeRequest(id)) {
2380
2380
  const nuxtPeerEntry = resolveProjectNuxtVuePeerRuntimeEntryWithNode(state, id);
2381
2381
  if (nuxtPeerEntry) {
2382
2382
  state.logger.log(`resolveId: resolved Nuxt Vue peer runtime ${id} to ${nuxtPeerEntry}`);
2383
2383
  return nuxtPeerEntry;
2384
2384
  }
2385
+ }
2386
+ if (!isProjectLocalImporter(state, importer)) return null;
2387
+ const isBuild = state.server === null;
2388
+ const viteImporter = normalizeViteRequireBase(importer) ?? importer;
2389
+ if (isVuePeerRuntimeRequest(id)) {
2385
2390
  if (!isBuild && isProjectSourceImporter(state.root, importer)) {
2386
2391
  state.logger.log(`resolveId: deferring source Vue peer runtime ${id} to Vite optimizer`);
2387
2392
  return null;
@@ -2962,7 +2967,7 @@ function getCompiledStyleSource(state, realPath, ssr) {
2962
2967
  const cache = getEnvironmentCache(state, ssr);
2963
2968
  const compiled = cache.get(realPath) ?? state.cache.get(realPath) ?? state.ssrCache.get(realPath);
2964
2969
  if (compiled || !shouldLoadCompiledVueSfcPath(state, realPath) || !fs.existsSync(realPath)) return compiled;
2965
- return compileFile(realPath, cache, getCompileOptionsForRequest(state, ssr));
2970
+ return compileFile(realPath, cache, getCompileOptionsForRequest(state, ssr, realPath));
2966
2971
  }
2967
2972
  //#endregion
2968
2973
  //#region src/plugin/load.ts
@@ -2987,7 +2992,7 @@ function findMacroArtifactModule(state, realPath, ssr, kind) {
2987
2992
  let compiled = cache.get(realPath) ?? state.cache.get(realPath) ?? state.ssrCache.get(realPath);
2988
2993
  if (!compiled && fs.existsSync(realPath)) {
2989
2994
  const source = fs.readFileSync(realPath, "utf-8");
2990
- compiled = compileFile(realPath, cache, getCompileOptionsForRequest(state, ssr), source);
2995
+ compiled = compileFile(realPath, cache, getCompileOptionsForRequest(state, ssr, realPath), source);
2991
2996
  }
2992
2997
  syncCollectedCssForFile({
2993
2998
  ...state,
@@ -3010,7 +3015,7 @@ function loadCompiledSfcModule(state, realPath, isSsr, currentBase, loadOptions)
3010
3015
  let compiled = cache.get(realPath);
3011
3016
  if (!compiled && fs.existsSync(realPath)) {
3012
3017
  state.logger.log(`load: on-demand compiling ${realPath}`);
3013
- compiled = compileFile(realPath, cache, getCompileOptionsForRequest(state, isSsr), void 0, { logWarnings: shouldLogSfcWarnings(state, realPath) });
3018
+ compiled = compileFile(realPath, cache, getCompileOptionsForRequest(state, isSsr, realPath), void 0, { logWarnings: shouldLogSfcWarnings(state, realPath) });
3014
3019
  }
3015
3020
  syncCollectedCssForFile({
3016
3021
  ...state,
@@ -3158,13 +3163,13 @@ function transformJsxRequest(state, code, id, options) {
3158
3163
  if (!shouldTransformJsxRequest(state, request)) return;
3159
3164
  const realPath = request.normalizedFsId ? classifyVitePluginRequest(request.normalizedFsId).path : request.path;
3160
3165
  const ssr = options?.ssr ?? false;
3161
- const sourceMap = getCompileOptionsForRequest(state, ssr).sourceMap;
3166
+ const fileOptions = state.fileCompilerOptions?.(realPath) ?? state.mergedOptions;
3162
3167
  const { code: compiled, map, warnings } = compileJsxModule(realPath, code, {
3163
- jsxMode: state.mergedOptions.jsxMode,
3164
- jsxCompat: state.mergedOptions.jsxCompat,
3165
- vapor: state.mergedOptions.vapor ?? false,
3168
+ jsxMode: fileOptions.jsxMode,
3169
+ jsxCompat: fileOptions.jsxCompat,
3170
+ vapor: fileOptions.vapor ?? false,
3166
3171
  ssr,
3167
- sourceMap
3172
+ sourceMap: getCompileOptionsForRequest(state, ssr, realPath).sourceMap
3168
3173
  });
3169
3174
  for (const warning of warnings) state.logger.warn(`Warning in ${realPath}: ${warning}`);
3170
3175
  return {
@@ -3300,7 +3305,7 @@ async function handleHotUpdateHook(state, ctx, options = {}) {
3300
3305
  if (initialModules?.size === 0) return [];
3301
3306
  const source = await read();
3302
3307
  const prevCompiled = state.cache.get(file);
3303
- compileFile(file, state.cache, getCompileOptionsForRequest(state, false), source);
3308
+ compileFile(file, state.cache, getCompileOptionsForRequest(state, false, file), source);
3304
3309
  state.ssrCache.delete(file);
3305
3310
  const newCompiled = state.cache.get(file);
3306
3311
  try {
@@ -3538,7 +3543,7 @@ function createPostTransformPlugin(state) {
3538
3543
  try {
3539
3544
  const isSsr = !!transformOptions?.ssr;
3540
3545
  const extractCss = shouldExtractCssForRequest(state, isSsr);
3541
- const compiled = compileFile(id, getEnvironmentCache(state, isSsr), getCompileOptionsForRequest(state, isSsr), code);
3546
+ const compiled = compileFile(id, getEnvironmentCache(state, isSsr), getCompileOptionsForRequest(state, isSsr, id), code);
3542
3547
  syncCollectedCssForFile({
3543
3548
  ...state,
3544
3549
  extractCss
@@ -3939,6 +3944,151 @@ function createLegacyVueCompatibilityPlugin(options) {
3939
3944
  };
3940
3945
  }
3941
3946
  //#endregion
3947
+ //#region src/plugin/index-helpers.ts
3948
+ function shouldExtractCssForBuild(state, context) {
3949
+ if (!state.isProduction) return false;
3950
+ const environmentName = context.environment?.name;
3951
+ if (environmentName === "client" || environmentName === "browser") return true;
3952
+ if (environmentName === "ssr" || environmentName === "server") return false;
3953
+ return state.extractCss;
3954
+ }
3955
+ function resolveCompatibilityOptions(options, compilerConfig = {}) {
3956
+ const compatibility = {
3957
+ ...compilerConfig.compatibility,
3958
+ ...options.compatibility
3959
+ };
3960
+ const vueVersion = options.vueVersion ?? compatibility.vueVersion ?? 3;
3961
+ if (compatibility.hostCompiler === void 0 && isLegacyVueVersion(vueVersion)) compatibility.hostCompiler = true;
3962
+ return compatibility;
3963
+ }
3964
+ function aliasSortKey(find) {
3965
+ return typeof find === "string" ? find.length : find.source.length;
3966
+ }
3967
+ /** Vite 8 supplies SSR identity through the environment instead of hook arguments. */
3968
+ function resolveHookSsr(context, options) {
3969
+ return options?.ssr ?? (context.environment?.name === "ssr" || context.environment?.name === "server");
3970
+ }
3971
+ //#endregion
3972
+ //#region src/plugin/compiler-config.ts
3973
+ function mergeCompilerOptions(options, sharedConfig) {
3974
+ const viteConfig = sharedConfig?.vite ?? {};
3975
+ const compilerConfig = sharedConfig?.compiler ?? {};
3976
+ const compatibility = resolveCompatibilityOptions(options, compilerConfig);
3977
+ const vueVersion = options.vueVersion ?? compatibility.vueVersion ?? 3;
3978
+ const mode = options.mode ?? compilerConfig.mode ?? (compatibility.scriptSetupInStandalone === true ? "function" : "module");
3979
+ const templateSyntax = options.templateSyntax ?? compilerConfig.templateSyntax ?? "standard";
3980
+ return {
3981
+ ...options,
3982
+ ssr: options.ssr ?? compilerConfig.ssr ?? false,
3983
+ sourceMap: options.sourceMap ?? compilerConfig.sourceMap,
3984
+ ...resolveExperimentalCompilerOptions(options, compilerConfig, sharedConfig?.experimentals),
3985
+ customRenderer: options.customRenderer ?? compilerConfig.customRenderer ?? false,
3986
+ customElements: options.customElements ?? compilerConfig.customElements,
3987
+ templateSyntax,
3988
+ whitespace: options.whitespace ?? compilerConfig.whitespace,
3989
+ template: {
3990
+ ...options.template,
3991
+ compilerOptions: {
3992
+ cacheHandlers: compilerConfig.cacheHandlers,
3993
+ hoistStatic: compilerConfig.hoistStatic,
3994
+ prefixIdentifiers: compilerConfig.prefixIdentifiers,
3995
+ ...options.template?.compilerOptions
3996
+ }
3997
+ },
3998
+ compatibility,
3999
+ vueVersion,
4000
+ mode,
4001
+ runtimeModuleName: options.runtimeModuleName ?? compilerConfig.runtimeModuleName ?? "vue",
4002
+ runtimeGlobalName: options.runtimeGlobalName ?? compilerConfig.runtimeGlobalName ?? "Vue",
4003
+ include: options.include ?? viteConfig.include,
4004
+ exclude: options.exclude ?? viteConfig.exclude,
4005
+ scanPatterns: options.scanPatterns ?? viteConfig.scanPatterns,
4006
+ precompileBatchSize: options.precompileBatchSize ?? viteConfig.precompileBatchSize,
4007
+ ignorePatterns: options.ignorePatterns ?? viteConfig.ignorePatterns
4008
+ };
4009
+ }
4010
+ //#endregion
4011
+ //#region src/plugin/compiler-scopes.ts
4012
+ const picomatch = createRequire(import.meta.url)("picomatch");
4013
+ function normalizePattern(source) {
4014
+ if (!source.includes("/")) return source.replaceAll("\\", "/");
4015
+ return source.replace(/\\(.)/g, (_, char) => "\\[]*?{}".includes(char) ? char === "]" ? "[]]" : `[${char}]` : `/${char}`);
4016
+ }
4017
+ function compileSequence(patterns, files) {
4018
+ const steps = patterns.flatMap((source) => {
4019
+ const negated = source.startsWith("!");
4020
+ const pattern = normalizePattern(negated ? source.slice(1) : source).replace(/^(\.\/)+/, "");
4021
+ if (!pattern) return [];
4022
+ try {
4023
+ return [{
4024
+ negated,
4025
+ matches: picomatch(pattern, {
4026
+ dot: true,
4027
+ noext: true,
4028
+ nonegate: true,
4029
+ strictBrackets: true
4030
+ })
4031
+ }];
4032
+ } catch (error) {
4033
+ console.warn(`[vize] Ignoring invalid entry glob '${source}':`, error);
4034
+ return [];
4035
+ }
4036
+ });
4037
+ return (file) => {
4038
+ let matched = files && steps.length > 0 && steps.every((step) => step.negated);
4039
+ for (const step of steps) {
4040
+ let candidate = file;
4041
+ while (candidate) {
4042
+ if (step.matches(candidate)) {
4043
+ matched = !step.negated;
4044
+ break;
4045
+ }
4046
+ const slash = candidate.lastIndexOf("/");
4047
+ candidate = slash < 0 ? "" : candidate.slice(0, slash);
4048
+ }
4049
+ }
4050
+ return matched;
4051
+ };
4052
+ }
4053
+ function compileScopes(config, root) {
4054
+ return config.entries.flatMap((entry) => {
4055
+ if (!entry.compiler) return [];
4056
+ const files = entry.files === void 0 ? () => true : compileSequence(entry.files, true);
4057
+ const ignores = compileSequence(entry.ignores ?? [], false);
4058
+ return [{
4059
+ base: path.resolve(root, (entry.basePath ?? "").replaceAll("\\", "/")),
4060
+ compiler: entry.compiler,
4061
+ matches: (relative) => files(relative) && !ignores(relative)
4062
+ }];
4063
+ });
4064
+ }
4065
+ function resolveScopes(config, scopes, file) {
4066
+ let compiler = config.compiler ?? {};
4067
+ for (const scope of scopes) {
4068
+ const relative = path.relative(scope.base, file).replaceAll("\\", "/");
4069
+ if (relative === ".." || relative.startsWith("../") || path.isAbsolute(relative)) continue;
4070
+ if (!scope.matches(relative)) continue;
4071
+ compiler = {
4072
+ ...compiler,
4073
+ ...scope.compiler,
4074
+ compatibility: {
4075
+ ...compiler.compatibility,
4076
+ ...scope.compiler.compatibility
4077
+ }
4078
+ };
4079
+ }
4080
+ return compiler;
4081
+ }
4082
+ function createFileCompilerOptions(config, root, explicit) {
4083
+ if (!config) return void 0;
4084
+ const scopes = compileScopes(config, root);
4085
+ if (scopes.length === 0) return void 0;
4086
+ return (file) => mergeCompilerOptions(explicit, {
4087
+ ...config,
4088
+ compiler: resolveScopes(config, scopes, file)
4089
+ });
4090
+ }
4091
+ //#endregion
3942
4092
  //#region src/plugin/config-lifecycle.ts
3943
4093
  const compatibilityOwners = /* @__PURE__ */ new Map();
3944
4094
  const compatibilityRegistrations = /* @__PURE__ */ new WeakMap();
@@ -4026,31 +4176,6 @@ function resolveVueFeatureDefines(features, define) {
4026
4176
  };
4027
4177
  }
4028
4178
  //#endregion
4029
- //#region src/plugin/index-helpers.ts
4030
- function shouldExtractCssForBuild(state, context) {
4031
- if (!state.isProduction) return false;
4032
- const environmentName = context.environment?.name;
4033
- if (environmentName === "client" || environmentName === "browser") return true;
4034
- if (environmentName === "ssr" || environmentName === "server") return false;
4035
- return state.extractCss;
4036
- }
4037
- function resolveCompatibilityOptions(options, compilerConfig = {}) {
4038
- const compatibility = {
4039
- ...compilerConfig.compatibility,
4040
- ...options.compatibility
4041
- };
4042
- const vueVersion = options.vueVersion ?? compatibility.vueVersion ?? 3;
4043
- if (compatibility.hostCompiler === void 0 && isLegacyVueVersion(vueVersion)) compatibility.hostCompiler = true;
4044
- return compatibility;
4045
- }
4046
- function aliasSortKey(find) {
4047
- return typeof find === "string" ? find.length : find.source.length;
4048
- }
4049
- /** Vite 8 supplies SSR identity through the environment instead of hook arguments. */
4050
- function resolveHookSsr(context, options) {
4051
- return options?.ssr ?? (context.environment?.name === "ssr" || context.environment?.name === "server");
4052
- }
4053
- //#endregion
4054
4179
  //#region src/plugin/index.ts
4055
4180
  function vize(options = {}) {
4056
4181
  if (isLegacyVueCompatibilityMode(options)) return [createLegacyVueCompatibilityPlugin(options)];
@@ -4119,32 +4244,9 @@ function vize(options = {}) {
4119
4244
  };
4120
4245
  const sharedConfigPromise = resolveSharedConfig(options, state.root, configEnv, state.logger);
4121
4246
  const sharedConfig = await register(resolvedConfig, state.root, sharedConfigPromise);
4122
- const viteConfig = sharedConfig?.vite ?? {};
4123
- const compilerConfig = sharedConfig?.compiler ?? {};
4124
- const compatibility = resolveCompatibilityOptions(options, compilerConfig);
4125
- const vueVersion = options.vueVersion ?? compatibility.vueVersion ?? 3;
4126
- const mode = options.mode ?? compilerConfig.mode ?? (compatibility.scriptSetupInStandalone === true ? "function" : "module");
4127
- const templateSyntax = options.templateSyntax ?? compilerConfig.templateSyntax ?? "standard";
4128
- state.mergedOptions = {
4129
- ...options,
4130
- ssr: options.ssr ?? compilerConfig.ssr ?? false,
4131
- sourceMap: options.sourceMap ?? compilerConfig.sourceMap,
4132
- ...resolveExperimentalCompilerOptions(options, compilerConfig, sharedConfig?.experimentals),
4133
- customRenderer: options.customRenderer ?? compilerConfig.customRenderer ?? false,
4134
- customElements: options.customElements ?? compilerConfig.customElements,
4135
- templateSyntax,
4136
- whitespace: options.whitespace ?? compilerConfig.whitespace,
4137
- compatibility,
4138
- vueVersion,
4139
- mode,
4140
- runtimeModuleName: options.runtimeModuleName ?? compilerConfig.runtimeModuleName ?? "vue",
4141
- runtimeGlobalName: options.runtimeGlobalName ?? compilerConfig.runtimeGlobalName ?? "Vue",
4142
- include: options.include ?? viteConfig.include,
4143
- exclude: options.exclude ?? viteConfig.exclude,
4144
- scanPatterns: options.scanPatterns ?? viteConfig.scanPatterns,
4145
- precompileBatchSize: options.precompileBatchSize ?? viteConfig.precompileBatchSize,
4146
- ignorePatterns: options.ignorePatterns ?? viteConfig.ignorePatterns
4147
- };
4247
+ state.mergedOptions = mergeCompilerOptions(options, sharedConfig);
4248
+ state.fileCompilerOptions = createFileCompilerOptions(sharedConfig, state.root, options);
4249
+ state.compilerScopeIdentity = sharedConfig?.entries;
4148
4250
  state.dynamicImportAliasRules = [];
4149
4251
  for (const alias of resolvedConfig.resolve.alias) {
4150
4252
  if (typeof alias.find !== "string" || typeof alias.replacement !== "string") continue;
@@ -98,6 +98,25 @@ function availableVueRules() {
98
98
  }
99
99
  }
100
100
  //#endregion
101
+ //#region src/vite-plus/config-paths.ts
102
+ /** Keep project-relative scopes when the serialized config lives in OS temp. */
103
+ function relocateTaskConfig(config, root) {
104
+ const absolutePattern = (pattern) => {
105
+ const negative = pattern.startsWith("!");
106
+ const value = negative ? pattern.slice(1) : pattern;
107
+ return `${negative ? "!" : ""}${path.resolve(root, value).replaceAll("\\", "/")}`;
108
+ };
109
+ return {
110
+ ...config,
111
+ basePath: path.resolve(root, config.basePath ?? ""),
112
+ ignores: config.ignores?.map(absolutePattern),
113
+ entries: (config.entries ?? []).map((entry) => ({
114
+ ...entry,
115
+ basePath: path.resolve(root, entry.basePath ?? "")
116
+ }))
117
+ };
118
+ }
119
+ //#endregion
101
120
  //#region src/vite-plus/runner.ts
102
121
  /** Run every selected checker, even when an earlier tool reports diagnostics. */
103
122
  async function runTools(task, args, metadata, vp, native, execute) {
@@ -106,7 +125,7 @@ async function runTools(task, args, metadata, vp, native, execute) {
106
125
  const fmt = task === "check" || task === "fmt" || task === "fmt:check";
107
126
  const fix = task === "lint:fix" || args.includes("--fix");
108
127
  const formatCheck = task === "fmt:check" || task === "check" && !fix || args.includes("--check");
109
- if (task === "check" && args.some((arg) => arg.startsWith("-") && arg !== "--fix")) throw new Error("Vize check tasks accept paths and --fix. Put native tool options in defineConfig().");
128
+ if ((task === "check" || lint) && args.some((arg) => arg.startsWith("-") && arg !== "--fix")) throw new Error(`Vize ${task} tasks accept paths and --fix. Put native tool options in ${task === "check" ? "the corresponding config section" : "lint.vize"}.`);
110
129
  let status = 0;
111
130
  async function run(binary, argv) {
112
131
  const code = await execute(process.execPath, [binary, ...argv]);
@@ -223,7 +242,7 @@ async function runNative(command, argv, metadata, native = nativeBinary(), spawn
223
242
  const config = metadata.config === void 0 ? await loadConfig(process.cwd(), { env }) ?? {} : await resolveConfigExport(metadata.config, env);
224
243
  const file = path.join(os.tmpdir(), `.vize-vp-${randomUUID()}.json`);
225
244
  try {
226
- await writeFile(file, JSON.stringify(config), {
245
+ await writeFile(file, JSON.stringify(relocateTaskConfig(config, process.cwd())), {
227
246
  flag: "wx",
228
247
  mode: 384
229
248
  });
@@ -185,6 +185,26 @@ interface LinterConfig {
185
185
  * Enable native type-aware lint rules from the active lint configuration
186
186
  */
187
187
  typeAware?: boolean;
188
+ /**
189
+ * Analyze relationships between input components
190
+ */
191
+ crossFile?: boolean;
192
+ /**
193
+ * Display the provide/inject tree; enables cross-file analysis
194
+ */
195
+ crossFileTree?: boolean;
196
+ /**
197
+ * Display cross-file complexity; enables cross-file analysis
198
+ */
199
+ crossFileComplexity?: boolean;
200
+ /**
201
+ * Enable the native reactivity-loss rule unless rules explicitly disable it
202
+ */
203
+ strictReactivity?: boolean;
204
+ /**
205
+ * Fail when warnings exceed this limit; absent means unlimited
206
+ */
207
+ maxWarnings?: number;
188
208
  /**
189
209
  * Rules to enable/disable
190
210
  */
@@ -205,6 +225,16 @@ interface LinterConfig {
205
225
  };
206
226
  }
207
227
  interface LintRuleOptions {
228
+ "type/strict-boolean-expressions"?: {
229
+ allowString?: boolean;
230
+ allowNumber?: boolean;
231
+ allowNullableObject?: boolean;
232
+ allowNullableBoolean?: boolean;
233
+ allowNullableString?: boolean;
234
+ allowNullableNumber?: boolean;
235
+ allowNullableEnum?: boolean;
236
+ allowAny?: boolean;
237
+ };
208
238
  "script/no-restricted-globals"?: NoRestrictedGlobalsOptions;
209
239
  "script/no-restricted-members"?: NoRestrictedMembersOptions;
210
240
  "vue/component-name-in-template-casing"?: {
@@ -342,6 +372,10 @@ interface TypeCheckerConfig {
342
372
  * Formatter options
343
373
  */
344
374
  interface FormatterConfig {
375
+ /**
376
+ * Oxfmt-compatible import sorting; false disables it
377
+ */
378
+ sortImports?: false | SortImportsConfig;
345
379
  /**
346
380
  * Max line width
347
381
  */
@@ -427,6 +461,25 @@ interface FormatterConfig {
427
461
  */
428
462
  sortBlocks?: boolean;
429
463
  }
464
+ interface SortImportsConfig {
465
+ partitionByNewline?: boolean;
466
+ partitionByComment?: boolean;
467
+ sortSideEffects?: boolean;
468
+ order?: "asc" | "desc";
469
+ ignoreCase?: boolean;
470
+ newlinesBetween?: boolean;
471
+ internalPattern?: string[];
472
+ groups?: (string | string[] | {
473
+ newlinesBetween: boolean;
474
+ })[];
475
+ customGroups?: ImportSortCustomGroup[];
476
+ }
477
+ interface ImportSortCustomGroup {
478
+ groupName: string;
479
+ elementNamePattern?: string[];
480
+ selector?: string;
481
+ modifiers?: string[];
482
+ }
430
483
  /**
431
484
  * Language server options
432
485
  */
@@ -1,4 +1,4 @@
1
- import { _ as LinterConfig, g as FormatterConfig, h as CompilerConfig, m as UserConfigExport, p as UserConfig$1, t as VizeOptions, v as TypeCheckerConfig } from "./types-VGJL5xEW.mjs";
1
+ import { _ as LinterConfig, g as FormatterConfig, h as CompilerConfig, m as UserConfigExport, p as UserConfig$1, t as VizeOptions, v as TypeCheckerConfig } from "./types-NyrQJOwS.mjs";
2
2
  import { ConfigEnv, UserConfig, defineConfig as defineConfig$1 } from "vite-plus";
3
3
 
4
4
  //#region src/vite-plus/types.d.ts
@@ -1,6 +1,6 @@
1
1
  import { i as resolveConfigExport, r as loadConfig } from "./config-PP6EAmWc.mjs";
2
2
  import { t as mergeSharedConfig } from "./shared-config-dMxrrTkb.mjs";
3
- import { a as sourceConfigKey, i as resolveVitePlus, o as taskConfigKey, r as availableVueRules, t as runNative } from "./runner-Tb17R9ol.mjs";
3
+ import { a as sourceConfigKey, i as resolveVitePlus, o as taskConfigKey, r as availableVueRules, t as runNative } from "./runner-D0tDOiOp.mjs";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import path from "node:path";
6
6
  import { readFileSync } from "node:fs";
@@ -142,6 +142,10 @@ function normalizeConfig(source, integration) {
142
142
  const { compiler: compilerOption, typecheck, vize, lint, fmt, extends: _bases, ...rest } = source;
143
143
  const { vize: nativeLint, ...oxlint } = lint ?? {};
144
144
  const { vize: nativeFmt, ...oxfmt } = fmt ?? {};
145
+ const formatter = {
146
+ ...oxfmt.sortImports === void 0 ? {} : { sortImports: oxfmt.sortImports },
147
+ ...typeof nativeFmt === "object" ? nativeFmt : {}
148
+ };
145
149
  const alias = vize && typeof vize === "object" && !Array.isArray(vize) ? vize.lint : void 0;
146
150
  const lintConfig = typeof alias === "object" && typeof nativeLint === "object" ? {
147
151
  ...alias,
@@ -168,7 +172,7 @@ function normalizeConfig(source, integration) {
168
172
  ...compiler === false ? {} : { compiler: nativeCompiler(compiler) },
169
173
  ...typeof typecheck === "object" ? { typeChecker: typecheck } : {},
170
174
  ...typeof lintConfig === "object" ? { linter: withoutTaskLintOptions(lintConfig) } : {},
171
- ...typeof nativeFmt === "object" ? { formatter: nativeFmt } : {}
175
+ ...Object.keys(formatter).length ? { formatter } : {}
172
176
  }, env)) ?? {};
173
177
  };
174
178
  const metadata = {
@@ -322,7 +326,7 @@ function defineConfig(config = {}, integration = {}) {
322
326
  const { options } = metadata;
323
327
  const plugins = compiler === false ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
324
328
  if (compiler !== false) {
325
- const { vize } = await import("./plugin-DZDCjcNO.mjs");
329
+ const { vize } = await import("./plugin-9jvcWEU8.mjs");
326
330
  plugins.push(vize({
327
331
  ...compiler,
328
332
  configMode: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.429.2",
3
+ "version": "0.431.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -51,12 +51,13 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@vizejs/native": "0.429.2",
55
- "@vizejs/unplugin": "0.429.2",
54
+ "@vizejs/native": "0.431.0",
55
+ "@vizejs/unplugin": "0.431.0",
56
56
  "jsonc-parser": "^3.3.1",
57
57
  "oxc-parser": "0.144.0",
58
+ "picomatch": "4.0.5",
58
59
  "tinyglobby": "0.2.17",
59
- "vize": "0.429.2"
60
+ "vize": "0.431.0"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@types/node": "25.9.2",
@@ -1,2 +0,0 @@
1
- import { t as vize } from "./plugin-Bu9B_IUr.mjs";
2
- export { vize };