@vizejs/vite-plugin 0.235.0 → 0.237.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 +28 -17
  2. package/package.json +5 -4
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import fs from "node:fs";
7
7
  import { glob } from "tinyglobby";
8
8
  import path from "node:path";
9
9
  import { pathToFileURL } from "node:url";
10
- import { transformWithOxc } from "vite";
10
+ import * as vite from "vite";
11
11
  //#region src/hmr.ts
12
12
  function hasHmrChanges(prev, next) {
13
13
  return hasViteHmrChanges(toHmrHashes(prev), toHmrHashes(next));
@@ -978,14 +978,10 @@ async function resolveProjectVueRuntime(ctx, state, id, importer, isSsrRequest)
978
978
  }
979
979
  return null;
980
980
  }
981
- const pnpmHoistedEntry = resolveVueBundlerEntryFromPnpmHoist(state, id, viteImporter);
982
- if (pnpmHoistedEntry) {
983
- state.logger.log(`resolveId: resolved project pnpm-hoisted Vue runtime to ${pnpmHoistedEntry}`);
984
- return pnpmHoistedEntry;
985
- }
986
981
  try {
987
982
  const resolved = await resolveWithVite(ctx, state, id, viteImporter, { skipSelf: true });
988
- if (resolved && !isOptimizedVueDependency(resolved.id)) {
983
+ if (resolved && isOptimizedVueDependency(resolved.id)) return null;
984
+ if (resolved) {
989
985
  const projectLocalEntry = resolveProjectLocalPnpmVueRuntime(state, resolved.id);
990
986
  if (projectLocalEntry) {
991
987
  state.logger.log(`resolveId: resolved project-local Vue runtime to ${projectLocalEntry}`);
@@ -993,6 +989,11 @@ async function resolveProjectVueRuntime(ctx, state, id, importer, isSsrRequest)
993
989
  }
994
990
  }
995
991
  } catch {}
992
+ const pnpmHoistedEntry = resolveVueBundlerEntryFromPnpmHoist(state, id, viteImporter);
993
+ if (pnpmHoistedEntry) {
994
+ state.logger.log(`resolveId: resolved project pnpm-hoisted Vue runtime to ${pnpmHoistedEntry}`);
995
+ return pnpmHoistedEntry;
996
+ }
996
997
  const importerLocalEntry = resolveVueBundlerEntryWithNode(state, id, viteImporter);
997
998
  const projectLocalEntry = importerLocalEntry ? resolveProjectLocalPnpmVueRuntime(state, importerLocalEntry) : null;
998
999
  if (projectLocalEntry) {
@@ -1320,6 +1321,22 @@ async function resolveIdHook(ctx, state, id, importer, options) {
1320
1321
  return null;
1321
1322
  }
1322
1323
  //#endregion
1324
+ //#region src/plugin/vite-transform.ts
1325
+ function createVirtualTypeScriptTransformer(viteApi) {
1326
+ return async (code, id) => {
1327
+ if (typeof viteApi.transformWithOxc === "function") return viteApi.transformWithOxc(code, id, {
1328
+ lang: "ts",
1329
+ sourcemap: false
1330
+ });
1331
+ if (typeof viteApi.transformWithEsbuild === "function") return viteApi.transformWithEsbuild(code, id, {
1332
+ loader: "ts",
1333
+ sourcemap: false
1334
+ });
1335
+ throw new Error("Installed Vite does not expose transformWithOxc or transformWithEsbuild");
1336
+ };
1337
+ }
1338
+ const transformVirtualTypeScript = createVirtualTypeScriptTransformer(vite);
1339
+ //#endregion
1323
1340
  //#region src/plugin/load.ts
1324
1341
  const SERVER_PLACEHOLDER_CODE = `import { createElementBlock, defineComponent } from "vue";
1325
1342
  export default defineComponent({
@@ -1469,7 +1486,7 @@ function loadHook(state, id, loadOptions) {
1469
1486
  };
1470
1487
  }
1471
1488
  if (fallbackCompiled?.css) return resolveCssImports(fallbackCompiled.css, realPath, state.cssAliasRules, state.server !== null, currentBase);
1472
- return "";
1489
+ return null;
1473
1490
  }
1474
1491
  if (id !== "\0vize:all-styles.css" && !id.startsWith("\0") && !pluginVisibleVirtualPath && !loadableVueSfcPath) return null;
1475
1492
  if (id.startsWith("\0") && request.hasDefinePageQuery) {
@@ -1557,10 +1574,7 @@ async function transformHook(state, code, id, options) {
1557
1574
  if (request.isVizeVirtual || request.isMacroVirtualId || pluginVisibleVirtualPath) {
1558
1575
  const realPath = request.isMacroVirtualId ? request.strippedVirtualPath ?? "" : request.vizeVirtualPath ?? pluginVisibleVirtualPath ?? "";
1559
1576
  try {
1560
- const result = await transformWithOxc(code, realPath, {
1561
- lang: "ts",
1562
- sourcemap: false
1563
- });
1577
+ const result = await transformVirtualTypeScript(code, realPath);
1564
1578
  const defines = getVirtualModuleDefines(state, options?.ssr ?? false);
1565
1579
  let transformed = result.code;
1566
1580
  transformed = applyDefineReplacements(transformed, defines);
@@ -1789,16 +1803,13 @@ function createPostTransformPlugin(state) {
1789
1803
  ...state,
1790
1804
  extractCss
1791
1805
  }, id, compiled);
1792
- const result = await transformWithOxc(generateOutput(compiled, {
1806
+ const result = await transformVirtualTypeScript(generateOutput(compiled, {
1793
1807
  isProduction: state.isProduction,
1794
1808
  isDev: state.server !== null,
1795
1809
  ssr: isSsr,
1796
1810
  extractCss,
1797
1811
  filePath: id
1798
- }), id, {
1799
- lang: "ts",
1800
- sourcemap: false
1801
- });
1812
+ }), id);
1802
1813
  const defines = transformOptions?.ssr ? state.serverViteDefine : state.clientViteDefine;
1803
1814
  let transformed = result.code;
1804
1815
  if (Object.keys(defines).length > 0) transformed = applyDefineReplacements(transformed, defines);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.235.0",
3
+ "version": "0.237.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -32,16 +32,17 @@
32
32
  "exports": {
33
33
  ".": {
34
34
  "types": "./index.d.mts",
35
- "import": "./dist/index.mjs"
35
+ "import": "./dist/index.mjs",
36
+ "default": "./dist/index.mjs"
36
37
  }
37
38
  },
38
39
  "publishConfig": {
39
40
  "access": "public"
40
41
  },
41
42
  "dependencies": {
42
- "@vizejs/native": "0.235.0",
43
+ "@vizejs/native": "0.237.0",
43
44
  "tinyglobby": "0.2.16",
44
- "vize": "0.235.0"
45
+ "vize": "0.237.0"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@types/node": "25.9.2",