@vizejs/vite-plugin 0.112.0 → 0.114.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 +14 -12
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -567,8 +567,16 @@ function isPotentialVizeResolveId(id) {
567
567
  function isPotentialVizeImporter(importer) {
568
568
  return importer !== void 0 && (importer.startsWith("\0") || importer.startsWith("vize:"));
569
569
  }
570
+ function shouldCompileVueSfcRequest(request) {
571
+ if (!request.isVueSfcPath || request.isVueStyleQuery || request.hasMacroQuery || request.hasDefinePageQuery) return false;
572
+ if (!request.querySuffix) return true;
573
+ const params = new URLSearchParams(request.querySuffix.slice(1));
574
+ if (params.has("raw") || params.has("url") || params.has("worker") || params.has("sharedworker")) return false;
575
+ return params.has("nuxt_component");
576
+ }
570
577
  async function resolveAliasedVueImport(ctx, state, id, importer, isSsrRequest, handleNodeModules) {
571
578
  if (path.isAbsolute(id)) return null;
579
+ const request = classifyVitePluginRequest(id);
572
580
  const viteImporter = normalizeViteRequireBase(importer) ?? importer;
573
581
  const viteResolved = await ctx.resolve(id, viteImporter, { skipSelf: true });
574
582
  const realPath = viteResolved ? normalizeResolvedVuePath(viteResolved.id) : null;
@@ -584,7 +592,7 @@ async function resolveAliasedVueImport(ctx, state, id, importer, isSsrRequest, h
584
592
  }
585
593
  if (state.cache.has(realPath) || fs.existsSync(realPath)) {
586
594
  state.logger.log(`resolveId: resolved via Vite fallback ${id} to ${realPath}`);
587
- return toVirtualId(realPath, isSsrRequest);
595
+ return `${toVirtualId(realPath, isSsrRequest)}${request.querySuffix}`;
588
596
  }
589
597
  return null;
590
598
  }
@@ -767,13 +775,14 @@ async function resolveIdHook(ctx, state, id, importer, options) {
767
775
  return null;
768
776
  }
769
777
  }
770
- if (id.endsWith(".vue")) {
778
+ if (shouldCompileVueSfcRequest(request)) {
771
779
  const handleNodeModules = state.initialized ? state.mergedOptions.handleNodeModulesVue ?? true : true;
772
- if (!handleNodeModules && id.includes("node_modules")) {
780
+ const vueRequestPath = request.path;
781
+ if (!handleNodeModules && vueRequestPath.includes("node_modules")) {
773
782
  state.logger.log(`resolveId: skipping node_modules import ${id}`);
774
783
  return null;
775
784
  }
776
- const resolved = resolveVuePath(state, id, importer);
785
+ const resolved = resolveVuePath(state, vueRequestPath, importer);
777
786
  const fileExists = fs.existsSync(resolved);
778
787
  if (!fileExists) {
779
788
  const aliased = await resolveAliasedVueImport(ctx, state, id, importer, isSsrRequest, handleNodeModules);
@@ -790,7 +799,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
790
799
  }
791
800
  const hasCache = state.cache.has(resolved);
792
801
  state.logger.log(`resolveId: id=${id}, resolved=${resolved}, hasCache=${hasCache}, fileExists=${fileExists}, importer=${importer ?? "none"}`);
793
- if (hasCache || fileExists) return toVirtualId(resolved, isSsrRequest);
802
+ if (hasCache || fileExists) return `${toVirtualId(resolved, isSsrRequest)}${request.querySuffix}`;
794
803
  }
795
804
  return null;
796
805
  }
@@ -903,13 +912,6 @@ function loadHook(state, id, loadOptions) {
903
912
  if (request.isVueSfcPath) {
904
913
  const artifactLoad = loadDefinePageMetaArtifact(state, realPath, !!loadOptions?.ssr);
905
914
  if (artifactLoad) return artifactLoad;
906
- if (fs.existsSync(realPath)) {
907
- const setupMatch = fs.readFileSync(realPath, "utf-8").match(/<script\s+setup[^>]*>([\s\S]*?)<\/script>/);
908
- if (setupMatch) return {
909
- code: `${setupMatch[1]}\nexport default {}`,
910
- map: null
911
- };
912
- }
913
915
  return {
914
916
  code: "export default {}",
915
917
  map: null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.112.0",
3
+ "version": "0.114.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.112.0",
40
+ "@vizejs/native": "0.114.0",
41
41
  "tinyglobby": "0.2.16",
42
- "vize": "0.112.0"
42
+ "vize": "0.114.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "25.7.0",