@ethisyscore/vite-plugin 1.105.0 → 1.107.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.cjs CHANGED
@@ -4,6 +4,7 @@ var fs = require('fs');
4
4
  var path = require('path');
5
5
  var protocol = require('@ethisyscore/protocol');
6
6
  var crypto = require('crypto');
7
+ var module$1 = require('module');
7
8
 
8
9
  // src/index.ts
9
10
  var KNOWN_PRIMITIVE_SET = new Set(protocol.KNOWN_PRIMITIVES);
@@ -1059,6 +1060,14 @@ function readManifest(options, root) {
1059
1060
  );
1060
1061
  }
1061
1062
  }
1063
+ function esbuildIsAvailable(root) {
1064
+ try {
1065
+ module$1.createRequire(path.resolve(root, "package.json")).resolve("esbuild");
1066
+ return true;
1067
+ } catch {
1068
+ return false;
1069
+ }
1070
+ }
1062
1071
  function makeDefaultBuild(viteBuild) {
1063
1072
  return async (ctx) => {
1064
1073
  const build = viteBuild ?? (await import('vite')).build;
@@ -1087,14 +1096,18 @@ function makeDefaultBuild(viteBuild) {
1087
1096
  // plugin opting out of console-stripping would also lose TS/JSX
1088
1097
  // transformation for any file its own plugins do not handle. An empty
1089
1098
  // options object keeps the transform and applies nothing.
1090
- esbuild: ctx.esbuild === false ? {} : ctx.esbuild ?? DEFAULT_ESBUILD,
1099
+ //
1100
+ // Omitted entirely where esbuild cannot be resolved: naming it would make
1101
+ // Vite 8 import an optional peer that is not installed. Minification still
1102
+ // happens there through oxc; only the esbuild-specific options are lost.
1103
+ ...esbuildIsAvailable(ctx.root) ? { esbuild: ctx.esbuild === false ? {} : ctx.esbuild ?? DEFAULT_ESBUILD } : {},
1091
1104
  build: {
1092
1105
  target: ctx.target,
1093
1106
  outDir: ctx.outDir,
1094
1107
  emptyOutDir: false,
1095
1108
  assetsDir: "",
1096
1109
  minify: ctx.minify,
1097
- cssMinify: ctx.cssMinify ?? "esbuild",
1110
+ cssMinify: ctx.cssMinify ?? true,
1098
1111
  reportCompressedSize: ctx.reportCompressedSize ?? false,
1099
1112
  sourcemap: ctx.sourcemap,
1100
1113
  rollupOptions: {
@@ -1206,7 +1219,7 @@ async function buildPlatformReactPages(options = {}) {
1206
1219
  sourcemap: options.sourcemap ?? "hidden",
1207
1220
  sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
1208
1221
  esbuild: options.esbuild ?? DEFAULT_ESBUILD,
1209
- cssMinify: options.cssMinify ?? "esbuild",
1222
+ cssMinify: options.cssMinify ?? true,
1210
1223
  reportCompressedSize: options.reportCompressedSize ?? false
1211
1224
  });
1212
1225
  }
@@ -1232,7 +1245,7 @@ async function buildPlatformReactPages(options = {}) {
1232
1245
  sourcemap: options.sourcemap ?? "hidden",
1233
1246
  sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
1234
1247
  esbuild: options.esbuild ?? DEFAULT_ESBUILD,
1235
- cssMinify: options.cssMinify ?? "esbuild",
1248
+ cssMinify: options.cssMinify ?? true,
1236
1249
  reportCompressedSize: options.reportCompressedSize ?? false
1237
1250
  });
1238
1251
  }