@vizejs/vite-plugin 0.241.0 → 0.242.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.
Files changed (2) hide show
  1. package/dist/index.mjs +47 -27
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -655,6 +655,43 @@ function formatUnknownError$1(error) {
655
655
  return error instanceof Error ? error.message : String(error);
656
656
  }
657
657
  //#endregion
658
+ //#region src/plugin/importer.ts
659
+ function isInsidePath(parent, child) {
660
+ const relative = path.relative(parent, child);
661
+ return relative === "" || !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
662
+ }
663
+ function normalizeNuxtVirtualImporterPath(importer) {
664
+ const { request } = splitViteIdQuery(importer);
665
+ for (const prefix of ["/@id/virtual:nuxt:", "virtual:nuxt:"]) {
666
+ if (!request.startsWith(prefix)) continue;
667
+ const encodedPath = request.slice(prefix.length);
668
+ try {
669
+ return decodeURIComponent(encodedPath);
670
+ } catch {
671
+ return encodedPath;
672
+ }
673
+ }
674
+ return null;
675
+ }
676
+ function normalizeImporterFilePath(importer) {
677
+ const nuxtVirtualPath = normalizeNuxtVirtualImporterPath(importer);
678
+ if (nuxtVirtualPath) return nuxtVirtualPath;
679
+ const request = classifyVitePluginRequest(importer);
680
+ return request.normalizedFsId ?? request.strippedVirtualPath ?? request.vizeVirtualPath ?? request.normalizedVuePath ?? splitViteIdQuery(importer).request;
681
+ }
682
+ function isProjectSourceImporter(root, importer) {
683
+ if (!importer) return false;
684
+ const importerPath = normalizeImporterFilePath(importer);
685
+ if (!path.isAbsolute(importerPath)) return false;
686
+ if (importerPath.split(path.sep).join("/").includes("/node_modules/")) return false;
687
+ if (isInsidePath(root, importerPath)) return true;
688
+ try {
689
+ return isInsidePath(fs.realpathSync(root), fs.realpathSync(importerPath));
690
+ } catch {
691
+ return false;
692
+ }
693
+ }
694
+ //#endregion
658
695
  //#region src/plugin/resolve.ts
659
696
  function resolveVuePath(state, id, importer) {
660
697
  return resolveViteVuePath(state.root, id, importer);
@@ -842,29 +879,6 @@ function isVuePackageEntry(id) {
842
879
  const normalized = request.split(path.sep).join("/");
843
880
  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+");
844
881
  }
845
- function isInsidePath(parent, child) {
846
- const relative = path.relative(parent, child);
847
- return relative === "" || !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
848
- }
849
- function normalizeNuxtVirtualImporterPath(importer) {
850
- const { request } = splitViteIdQuery(importer);
851
- for (const prefix of ["/@id/virtual:nuxt:", "virtual:nuxt:"]) {
852
- if (!request.startsWith(prefix)) continue;
853
- const encodedPath = request.slice(prefix.length);
854
- try {
855
- return decodeURIComponent(encodedPath);
856
- } catch {
857
- return encodedPath;
858
- }
859
- }
860
- return null;
861
- }
862
- function normalizeImporterFilePath(importer) {
863
- const nuxtVirtualPath = normalizeNuxtVirtualImporterPath(importer);
864
- if (nuxtVirtualPath) return nuxtVirtualPath;
865
- const request = classifyVitePluginRequest(importer);
866
- return request.normalizedFsId ?? request.strippedVirtualPath ?? request.vizeVirtualPath ?? request.normalizedVuePath ?? splitViteIdQuery(importer).request;
867
- }
868
882
  function isProjectLocalImporter(state, importer) {
869
883
  if (!importer) return false;
870
884
  const importerPath = normalizeImporterFilePath(importer);
@@ -964,6 +978,7 @@ function normalizeResolvedVuePath(id) {
964
978
  }
965
979
  async function resolveProjectVueRuntime(ctx, state, id, importer, isSsrRequest) {
966
980
  if (isSsrRequest || !isProjectVueRuntimeRequest(id) || !isProjectLocalImporter(state, importer)) return null;
981
+ const isBuild = state.server === null;
967
982
  const viteImporter = normalizeViteRequireBase(importer) ?? importer;
968
983
  if (isVuePeerRuntimeRequest(id)) {
969
984
  const nuxtPeerEntry = resolveProjectNuxtVuePeerRuntimeEntryWithNode(state, id);
@@ -971,6 +986,10 @@ async function resolveProjectVueRuntime(ctx, state, id, importer, isSsrRequest)
971
986
  state.logger.log(`resolveId: resolved Nuxt Vue peer runtime ${id} to ${nuxtPeerEntry}`);
972
987
  return nuxtPeerEntry;
973
988
  }
989
+ if (!isBuild && isProjectSourceImporter(state.root, importer)) {
990
+ state.logger.log(`resolveId: deferring source Vue peer runtime ${id} to Vite optimizer`);
991
+ return null;
992
+ }
974
993
  const projectLocalEntry = resolveVuePeerRuntimeEntryWithNode(state, id, viteImporter);
975
994
  if (projectLocalEntry) {
976
995
  state.logger.log(`resolveId: resolved project-local Vue peer runtime ${id} to ${projectLocalEntry}`);
@@ -1111,10 +1130,6 @@ async function resolveIdHook(ctx, state, id, importer, options) {
1111
1130
  state.logger.log(`resolveId: skipping vitepress-plugin-llms style import ${id}`);
1112
1131
  return null;
1113
1132
  }
1114
- if (!(state.mergedOptions.handleNodeModulesVue ?? true) && request.path.includes("node_modules")) {
1115
- state.logger.log(`resolveId: skipping node_modules style import ${id}`);
1116
- return null;
1117
- }
1118
1133
  return `${request.normalizedFsId ?? id}${request.styleVirtualSuffix}`;
1119
1134
  }
1120
1135
  if (isBuild && request.normalizedFsId) return request.normalizedFsId;
@@ -1146,6 +1161,11 @@ async function resolveIdHook(ctx, state, id, importer, options) {
1146
1161
  }
1147
1162
  if (!id.startsWith("./") && !id.startsWith("../") && !id.startsWith("/")) {
1148
1163
  const isVueRuntime = isVueRuntimeRequest(id);
1164
+ const isVuePeerRuntime = isVuePeerRuntimeRequest(id);
1165
+ if (!isBuild && isVuePeerRuntime && isProjectSourceImporter(state.root, importer)) {
1166
+ state.logger.log(`resolveId: deferring source Vue peer runtime ${id} to Vite optimizer`);
1167
+ return null;
1168
+ }
1149
1169
  if (isVueRuntime && isBuild) {
1150
1170
  const vueBundlerEntry = resolveVueBundlerEntryWithNode(state, id, cleanImporter);
1151
1171
  if (vueBundlerEntry) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.241.0",
3
+ "version": "0.242.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -40,9 +40,9 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@vizejs/native": "0.241.0",
43
+ "@vizejs/native": "0.242.0",
44
44
  "tinyglobby": "0.2.16",
45
- "vize": "0.241.0"
45
+ "vize": "0.242.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "25.9.2",