@vizejs/vite-plugin 0.170.0 → 0.171.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
@@ -2,6 +2,10 @@ import { defineConfig, loadConfig, resolveConfigExport } from "vize";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region ../vize/src/types/generated.d.ts
5
+ /**
6
+ * Host Vue runtime version for opt-in compatibility modes
7
+ */
8
+ type VueVersion = 0.11 | 1 | 2 | 3 | "legacy";
5
9
  /**
6
10
  * Configuration file for vize - High-performance Vue.js toolchain
7
11
  */
@@ -52,6 +56,10 @@ interface CompilerConfig {
52
56
  * Enable Vapor mode compilation
53
57
  */
54
58
  vapor?: boolean;
59
+ /**
60
+ * Treat lowercase non-HTML tags as custom renderer elements
61
+ */
62
+ customRenderer?: boolean;
55
63
  /**
56
64
  * Enable SSR mode
57
65
  */
@@ -92,6 +100,33 @@ interface CompilerConfig {
92
100
  * Global variable name for runtime (IIFE builds)
93
101
  */
94
102
  runtimeGlobalName?: string;
103
+ compatibility?: CompilerCompatibilityConfig;
104
+ }
105
+ /**
106
+ * Opt-in compatibility features for unsupported host/runtime combinations
107
+ */
108
+ interface CompilerCompatibilityConfig {
109
+ vueVersion?: VueVersion;
110
+ /**
111
+ * Delegate .vue compilation to the host Vue compiler for legacy Vue runtimes
112
+ */
113
+ hostCompiler?: boolean;
114
+ /**
115
+ * Enable <script setup> when emitting function-body output for CDN/global Vue usage
116
+ */
117
+ scriptSetupInStandalone?: boolean;
118
+ /**
119
+ * Allow Vapor output for Options API SFCs when Vapor mode is enabled
120
+ */
121
+ optionsApiVapor?: boolean;
122
+ /**
123
+ * Host Nuxt major version for compatibility bridges
124
+ */
125
+ nuxtVersion?: 2 | 3 | 4;
126
+ /**
127
+ * Host Webpack major version for compatibility bridges
128
+ */
129
+ webpackVersion?: 4 | 5;
95
130
  }
96
131
  /**
97
132
  * Vite plugin options
@@ -593,6 +628,33 @@ interface MacroArtifact {
593
628
  end: number;
594
629
  }
595
630
  type VizeVueVersion = 0.11 | 1 | 2 | 3 | "legacy";
631
+ interface VizeCompatibilityOptions {
632
+ /**
633
+ * Host Vue version. Vue 0.11/1/2 opt into host-compiler compatibility.
634
+ */
635
+ vueVersion?: VizeVueVersion;
636
+ /**
637
+ * Keep .vue files on the existing Vue compiler for legacy Vue runtimes.
638
+ * @default true when vueVersion is 0.11, 1, 2, or "legacy"
639
+ */
640
+ hostCompiler?: boolean;
641
+ /**
642
+ * Enable function-body output for CDN/global Vue evaluation.
643
+ */
644
+ scriptSetupInStandalone?: boolean;
645
+ /**
646
+ * Allow Vapor output for Options API SFCs when vapor is enabled.
647
+ */
648
+ optionsApiVapor?: boolean;
649
+ /**
650
+ * Override the host Nuxt major when this option object is shared with Nuxt.
651
+ */
652
+ nuxtVersion?: 2 | 3 | 4;
653
+ /**
654
+ * Override the host Webpack major when this option object is shared with unplugin.
655
+ */
656
+ webpackVersion?: 4 | 5;
657
+ }
596
658
  interface VizeOptions {
597
659
  /**
598
660
  * Inline shared Vize config for Vite Plus-first projects.
@@ -610,6 +672,25 @@ interface VizeOptions {
610
672
  * @default 3
611
673
  */
612
674
  vueVersion?: VizeVueVersion;
675
+ /**
676
+ * Opt-in compatibility features for unsupported host/runtime combinations.
677
+ */
678
+ compatibility?: VizeCompatibilityOptions;
679
+ /**
680
+ * Compilation output mode. Use "function" for CDN/global Vue evaluation.
681
+ * @default "module"
682
+ */
683
+ mode?: "module" | "function";
684
+ /**
685
+ * Module name for runtime imports.
686
+ * @default "vue"
687
+ */
688
+ runtimeModuleName?: string;
689
+ /**
690
+ * Global variable name for function/standalone output.
691
+ * @default "Vue"
692
+ */
693
+ runtimeGlobalName?: string;
613
694
  /**
614
695
  * Override the public base used for dev-time asset URLs such as /@fs paths.
615
696
  * Useful for frameworks like Nuxt that serve Vite from a subpath (e.g. /_nuxt/).
@@ -762,4 +843,4 @@ declare const __internal: {
762
843
  rewriteStaticAssetUrls: typeof rewriteStaticAssetUrls;
763
844
  };
764
845
  //#endregion
765
- export { type CompiledModule, type LoadConfigOptions, type MacroArtifact, type ResolvedVizeConfig, type UserConfigExport, type VizeConfig, type VizeOptions, type VizeVueVersion, __internal, rewriteStaticAssetUrls as __internal_rewriteStaticAssetUrls, vize as default, vize, defineConfig, loadConfig, resolveConfigExport, vizeConfigStore };
846
+ export { type CompiledModule, type LoadConfigOptions, type MacroArtifact, type ResolvedVizeConfig, type UserConfigExport, type VizeCompatibilityOptions, type VizeConfig, type VizeOptions, type VizeVueVersion, __internal, rewriteStaticAssetUrls as __internal_rewriteStaticAssetUrls, vize as default, vize, defineConfig, loadConfig, resolveConfigExport, vizeConfigStore };
package/dist/index.mjs CHANGED
@@ -282,20 +282,28 @@ const vizeConfigStore = /* @__PURE__ */ new Map();
282
282
  function buildCompileFileOptions(filePath, options) {
283
283
  return {
284
284
  filename: filePath,
285
+ mode: options.mode,
285
286
  sourceMap: options.sourceMap,
286
287
  ssr: options.ssr,
287
288
  vapor: options.vapor,
288
289
  customRenderer: options.customRenderer ?? false,
289
290
  vueParserQuirks: options.vueParserQuirks ?? false,
291
+ runtimeModuleName: options.runtimeModuleName,
292
+ runtimeGlobalName: options.runtimeGlobalName,
293
+ vueVersion: options.vueVersion == null ? void 0 : String(options.vueVersion),
290
294
  scopeId: `data-v-${generateScopeId(filePath)}`
291
295
  };
292
296
  }
293
297
  function buildCompileBatchOptions(options) {
294
298
  return {
299
+ mode: options.mode,
295
300
  ssr: options.ssr,
296
301
  vapor: options.vapor,
297
302
  customRenderer: options.customRenderer ?? false,
298
- vueParserQuirks: options.vueParserQuirks ?? false
303
+ vueParserQuirks: options.vueParserQuirks ?? false,
304
+ runtimeModuleName: options.runtimeModuleName,
305
+ runtimeGlobalName: options.runtimeGlobalName,
306
+ vueVersion: options.vueVersion == null ? void 0 : String(options.vueVersion)
299
307
  };
300
308
  }
301
309
  //#endregion
@@ -409,13 +417,18 @@ function getEnvironmentCache(state, ssr) {
409
417
  return ssr ? state.ssrCache : state.cache;
410
418
  }
411
419
  function getCompileOptionsForRequest(state, ssr) {
412
- return {
420
+ const options = {
413
421
  sourceMap: state.mergedOptions?.sourceMap ?? !state.isProduction,
414
422
  ssr,
415
423
  vapor: !ssr && (state.mergedOptions?.vapor ?? false),
416
424
  customRenderer: state.mergedOptions?.customRenderer ?? false,
417
425
  vueParserQuirks: state.mergedOptions?.vueParserQuirks ?? false
418
426
  };
427
+ if (state.mergedOptions?.mode !== void 0) options.mode = state.mergedOptions.mode;
428
+ if (state.mergedOptions?.runtimeModuleName !== void 0) options.runtimeModuleName = state.mergedOptions.runtimeModuleName;
429
+ if (state.mergedOptions?.runtimeGlobalName !== void 0) options.runtimeGlobalName = state.mergedOptions.runtimeGlobalName;
430
+ if (state.mergedOptions?.vueVersion !== void 0) options.vueVersion = state.mergedOptions.vueVersion;
431
+ return options;
419
432
  }
420
433
  function syncCollectedCssForFile(state, filePath, compiled) {
421
434
  if (!compiled || !state.extractCss) return;
@@ -500,8 +513,12 @@ async function compileAll(state) {
500
513
  const result = compileBatch(fileContents, state.cache, {
501
514
  ssr: false,
502
515
  vapor: state.mergedOptions.vapor ?? false,
516
+ mode: state.mergedOptions.mode,
503
517
  customRenderer: state.mergedOptions.customRenderer ?? false,
504
- vueParserQuirks: state.mergedOptions.vueParserQuirks ?? false
518
+ vueParserQuirks: state.mergedOptions.vueParserQuirks ?? false,
519
+ runtimeModuleName: state.mergedOptions.runtimeModuleName,
520
+ runtimeGlobalName: state.mergedOptions.runtimeGlobalName,
521
+ vueVersion: state.mergedOptions.vueVersion
505
522
  });
506
523
  const chunkFailedCount = result.results.filter((fileResult) => fileResult.errors.length > 0).length;
507
524
  failedCount += chunkFailedCount;
@@ -1602,20 +1619,20 @@ function createPostTransformPlugin(state) {
1602
1619
  }
1603
1620
  //#endregion
1604
1621
  //#region src/plugin/unocss.ts
1605
- const bridgePatched = Symbol("vize.unocssBridgePatched");
1606
- const VIZE_SSR_PREFIX = "\0vize-ssr:";
1607
- const plainSsrPrefix = VIZE_SSR_PREFIX.slice(1);
1608
- function stripBridgePrefix(id) {
1609
- if (id.startsWith(VIZE_SSR_PREFIX)) return id.slice(10);
1610
- if (id.startsWith(plainSsrPrefix)) return id.slice(plainSsrPrefix.length);
1622
+ const bridgePatched$1 = Symbol("vize.unocssBridgePatched");
1623
+ const VIZE_SSR_PREFIX$1 = "\0vize-ssr:";
1624
+ const plainSsrPrefix$1 = VIZE_SSR_PREFIX$1.slice(1);
1625
+ function stripBridgePrefix$1(id) {
1626
+ if (id.startsWith(VIZE_SSR_PREFIX$1)) return id.slice(10);
1627
+ if (id.startsWith(plainSsrPrefix$1)) return id.slice(plainSsrPrefix$1.length);
1611
1628
  if (id.startsWith("\0")) return id.slice(1);
1612
1629
  return id;
1613
1630
  }
1614
1631
  function isUnoCssBridgeModuleId(id) {
1615
- return /\.vue\.ts(?:\?|$)/.test(stripBridgePrefix(id));
1632
+ return /\.vue\.ts(?:\?|$)/.test(stripBridgePrefix$1(id));
1616
1633
  }
1617
1634
  function normalizeUnoCssBridgeModuleId(id) {
1618
- return stripBridgePrefix(id).replace(/\.ts(?=\?|$)/, "");
1635
+ return stripBridgePrefix$1(id).replace(/\.ts(?=\?|$)/, "");
1619
1636
  }
1620
1637
  function appendOriginalVueSourceForUnoCss(code, normalizedId) {
1621
1638
  const sourcePath = normalizedId.split("?")[0];
@@ -1633,7 +1650,7 @@ function appendOriginalVueSourceForUnoCss(code, normalizedId) {
1633
1650
  }
1634
1651
  function patchUnoCssBridge(plugins) {
1635
1652
  for (const plugin of plugins) {
1636
- if (!plugin.name?.startsWith("unocss:") || typeof plugin.transform !== "function" || plugin[bridgePatched]) continue;
1653
+ if (!plugin.name?.startsWith("unocss:") || typeof plugin.transform !== "function" || plugin[bridgePatched$1]) continue;
1637
1654
  const originalTransform = plugin.transform;
1638
1655
  const isExtractionOnly = plugin.name.startsWith("unocss:global");
1639
1656
  plugin.transform = function(code, id, ...args) {
@@ -1643,6 +1660,38 @@ function patchUnoCssBridge(plugins) {
1643
1660
  if (isExtractionOnly) effectiveCode = appendOriginalVueSourceForUnoCss(code, normalizedId);
1644
1661
  return originalTransform.call(this, effectiveCode, normalizedId, ...args);
1645
1662
  };
1663
+ plugin[bridgePatched$1] = true;
1664
+ }
1665
+ }
1666
+ //#endregion
1667
+ //#region src/plugin/quasar.ts
1668
+ const bridgePatched = Symbol("vize.quasarBridgePatched");
1669
+ const VIZE_SSR_PREFIX = "\0vize-ssr:";
1670
+ const LEGACY_VIZE_PREFIX = "\0vize:";
1671
+ const plainSsrPrefix = VIZE_SSR_PREFIX.slice(1);
1672
+ const plainLegacyPrefix = LEGACY_VIZE_PREFIX.slice(1);
1673
+ function stripBridgePrefix(id) {
1674
+ if (id.startsWith(VIZE_SSR_PREFIX)) return id.slice(10);
1675
+ if (id.startsWith(LEGACY_VIZE_PREFIX)) return id.slice(6);
1676
+ if (id.startsWith(plainSsrPrefix)) return id.slice(plainSsrPrefix.length);
1677
+ if (id.startsWith(plainLegacyPrefix)) return id.slice(plainLegacyPrefix.length);
1678
+ if (id.startsWith("\0")) return id.slice(1);
1679
+ return id;
1680
+ }
1681
+ function isQuasarBridgeModuleId(id) {
1682
+ return /\.vue\.ts(?:[?#]|$)/.test(stripBridgePrefix(id));
1683
+ }
1684
+ function normalizeQuasarBridgeModuleId(id) {
1685
+ return stripBridgePrefix(id).replace(/\.vue\.ts(?=[?#]|$)/, ".vue");
1686
+ }
1687
+ function patchQuasarBridge(plugins) {
1688
+ for (const plugin of plugins) {
1689
+ if (plugin.name !== "vite:quasar:script" || typeof plugin.transform !== "function" || plugin[bridgePatched]) continue;
1690
+ const originalTransform = plugin.transform;
1691
+ plugin.transform = function(code, id, ...args) {
1692
+ if (!isQuasarBridgeModuleId(id)) return originalTransform.call(this, code, id, ...args);
1693
+ return originalTransform.call(this, code, normalizeQuasarBridgeModuleId(id), ...args);
1694
+ };
1646
1695
  plugin[bridgePatched] = true;
1647
1696
  }
1648
1697
  }
@@ -1675,8 +1724,12 @@ function installVirtualAssetMiddleware(devServer, state) {
1675
1724
  }
1676
1725
  //#endregion
1677
1726
  //#region src/plugin/vue-version.ts
1727
+ function isLegacyVueVersion(version) {
1728
+ return version === "legacy" || version === .11 || version === 1 || version === 2;
1729
+ }
1678
1730
  function isLegacyVueCompatibilityMode(options) {
1679
- return options.vueVersion !== void 0 && options.vueVersion !== 3;
1731
+ const vueVersion = options.vueVersion ?? options.compatibility?.vueVersion;
1732
+ return (options.compatibility?.hostCompiler ?? isLegacyVueVersion(vueVersion)) && isLegacyVueVersion(vueVersion);
1680
1733
  }
1681
1734
  function createLegacyVueCompatibilityPlugin(options) {
1682
1735
  return {
@@ -1739,6 +1792,15 @@ function shouldExtractCssForBuild(state, context) {
1739
1792
  if (environmentName === "ssr" || environmentName === "server") return false;
1740
1793
  return state.extractCss;
1741
1794
  }
1795
+ function resolveCompatibilityOptions(options, compilerConfig = {}) {
1796
+ const compatibility = {
1797
+ ...compilerConfig.compatibility,
1798
+ ...options.compatibility
1799
+ };
1800
+ const vueVersion = options.vueVersion ?? compatibility.vueVersion ?? 3;
1801
+ if (compatibility.hostCompiler === void 0 && isLegacyVueVersion(vueVersion)) compatibility.hostCompiler = true;
1802
+ return compatibility;
1803
+ }
1742
1804
  function vize(options = {}) {
1743
1805
  if (isLegacyVueCompatibilityMode(options)) return [createLegacyVueCompatibilityPlugin(options)];
1744
1806
  const state = {
@@ -1828,6 +1890,9 @@ function vize(options = {}) {
1828
1890
  if (sharedConfig) vizeConfigStore.set(state.root, sharedConfig);
1829
1891
  const viteConfig = sharedConfig?.vite ?? {};
1830
1892
  const compilerConfig = sharedConfig?.compiler ?? {};
1893
+ const compatibility = resolveCompatibilityOptions(options, compilerConfig);
1894
+ const vueVersion = options.vueVersion ?? compatibility.vueVersion ?? 3;
1895
+ const mode = options.mode ?? compilerConfig.mode ?? (compatibility.scriptSetupInStandalone === true ? "function" : "module");
1831
1896
  state.mergedOptions = {
1832
1897
  ...options,
1833
1898
  ssr: options.ssr ?? compilerConfig.ssr ?? false,
@@ -1835,6 +1900,11 @@ function vize(options = {}) {
1835
1900
  vapor: options.vapor ?? compilerConfig.vapor ?? false,
1836
1901
  customRenderer: options.customRenderer ?? compilerConfig.customRenderer ?? false,
1837
1902
  vueParserQuirks: options.vueParserQuirks ?? compilerConfig.vueParserQuirks ?? false,
1903
+ compatibility,
1904
+ vueVersion,
1905
+ mode,
1906
+ runtimeModuleName: options.runtimeModuleName ?? compilerConfig.runtimeModuleName ?? "vue",
1907
+ runtimeGlobalName: options.runtimeGlobalName ?? compilerConfig.runtimeGlobalName ?? "Vue",
1838
1908
  include: options.include ?? viteConfig.include,
1839
1909
  exclude: options.exclude ?? viteConfig.exclude,
1840
1910
  scanPatterns: options.scanPatterns ?? viteConfig.scanPatterns,
@@ -1862,11 +1932,17 @@ function vize(options = {}) {
1862
1932
  });
1863
1933
  }
1864
1934
  state.cssAliasRules.sort((a, b) => aliasSortKey(b.find) - aliasSortKey(a.find));
1865
- state.filter = createFilter(state.mergedOptions.include, state.mergedOptions.exclude);
1866
- state.scanPatterns = state.mergedOptions.scanPatterns ?? ["**/*.vue"];
1935
+ if (isLegacyVueCompatibilityMode(state.mergedOptions)) {
1936
+ state.filter = () => false;
1937
+ state.scanPatterns = [];
1938
+ } else {
1939
+ state.filter = createFilter(state.mergedOptions.include, state.mergedOptions.exclude);
1940
+ state.scanPatterns = state.mergedOptions.scanPatterns ?? ["**/*.vue"];
1941
+ }
1867
1942
  state.precompileBatchSize = normalizePrecompileBatchSize(state.mergedOptions.precompileBatchSize);
1868
1943
  state.ignorePatterns = state.mergedOptions.ignorePatterns ?? [...DEFAULT_PRECOMPILE_IGNORE_PATTERNS];
1869
1944
  patchUnoCssBridge(resolvedConfig.plugins);
1945
+ patchQuasarBridge(resolvedConfig.plugins);
1870
1946
  state.initialized = true;
1871
1947
  },
1872
1948
  configureServer(devServer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.170.0",
3
+ "version": "0.171.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -39,9 +39,9 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@vizejs/native": "0.170.0",
42
+ "@vizejs/native": "0.171.0",
43
43
  "tinyglobby": "0.2.16",
44
- "vize": "0.170.0"
44
+ "vize": "0.171.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "25.7.0",