@vizejs/vite-plugin 0.236.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 +21 -11
  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));
@@ -1321,6 +1321,22 @@ async function resolveIdHook(ctx, state, id, importer, options) {
1321
1321
  return null;
1322
1322
  }
1323
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
1324
1340
  //#region src/plugin/load.ts
1325
1341
  const SERVER_PLACEHOLDER_CODE = `import { createElementBlock, defineComponent } from "vue";
1326
1342
  export default defineComponent({
@@ -1470,7 +1486,7 @@ function loadHook(state, id, loadOptions) {
1470
1486
  };
1471
1487
  }
1472
1488
  if (fallbackCompiled?.css) return resolveCssImports(fallbackCompiled.css, realPath, state.cssAliasRules, state.server !== null, currentBase);
1473
- return "";
1489
+ return null;
1474
1490
  }
1475
1491
  if (id !== "\0vize:all-styles.css" && !id.startsWith("\0") && !pluginVisibleVirtualPath && !loadableVueSfcPath) return null;
1476
1492
  if (id.startsWith("\0") && request.hasDefinePageQuery) {
@@ -1558,10 +1574,7 @@ async function transformHook(state, code, id, options) {
1558
1574
  if (request.isVizeVirtual || request.isMacroVirtualId || pluginVisibleVirtualPath) {
1559
1575
  const realPath = request.isMacroVirtualId ? request.strippedVirtualPath ?? "" : request.vizeVirtualPath ?? pluginVisibleVirtualPath ?? "";
1560
1576
  try {
1561
- const result = await transformWithOxc(code, realPath, {
1562
- lang: "ts",
1563
- sourcemap: false
1564
- });
1577
+ const result = await transformVirtualTypeScript(code, realPath);
1565
1578
  const defines = getVirtualModuleDefines(state, options?.ssr ?? false);
1566
1579
  let transformed = result.code;
1567
1580
  transformed = applyDefineReplacements(transformed, defines);
@@ -1790,16 +1803,13 @@ function createPostTransformPlugin(state) {
1790
1803
  ...state,
1791
1804
  extractCss
1792
1805
  }, id, compiled);
1793
- const result = await transformWithOxc(generateOutput(compiled, {
1806
+ const result = await transformVirtualTypeScript(generateOutput(compiled, {
1794
1807
  isProduction: state.isProduction,
1795
1808
  isDev: state.server !== null,
1796
1809
  ssr: isSsr,
1797
1810
  extractCss,
1798
1811
  filePath: id
1799
- }), id, {
1800
- lang: "ts",
1801
- sourcemap: false
1802
- });
1812
+ }), id);
1803
1813
  const defines = transformOptions?.ssr ? state.serverViteDefine : state.clientViteDefine;
1804
1814
  let transformed = result.code;
1805
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.236.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.236.0",
43
+ "@vizejs/native": "0.237.0",
43
44
  "tinyglobby": "0.2.16",
44
- "vize": "0.236.0"
45
+ "vize": "0.237.0"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@types/node": "25.9.2",