@ethisyscore/vite-plugin 1.105.0 → 1.106.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.cts CHANGED
@@ -529,7 +529,11 @@ interface BuildPlatformReactPagesOptions {
529
529
  * with it.
530
530
  */
531
531
  esbuild?: ESBuildOptions | false;
532
- /** Minify CSS before it is inlined into the bundle. Default `"esbuild"`. */
532
+ /**
533
+ * Minify CSS before it is inlined into the bundle. Default `true`, which lets
534
+ * Vite pick its own minifier. Naming `"esbuild"` would force Vite 8 to import
535
+ * an optional peer that need not be installed.
536
+ */
533
537
  cssMinify?: boolean | "esbuild" | "lightningcss";
534
538
  /**
535
539
  * Print the post-build gzip-size table. Default `false`: the numbers are
package/dist/index.d.ts CHANGED
@@ -529,7 +529,11 @@ interface BuildPlatformReactPagesOptions {
529
529
  * with it.
530
530
  */
531
531
  esbuild?: ESBuildOptions | false;
532
- /** Minify CSS before it is inlined into the bundle. Default `"esbuild"`. */
532
+ /**
533
+ * Minify CSS before it is inlined into the bundle. Default `true`, which lets
534
+ * Vite pick its own minifier. Naming `"esbuild"` would force Vite 8 to import
535
+ * an optional peer that need not be installed.
536
+ */
533
537
  cssMinify?: boolean | "esbuild" | "lightningcss";
534
538
  /**
535
539
  * Print the post-build gzip-size table. Default `false`: the numbers are
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { readFileSync, existsSync, rmSync, mkdirSync, readdirSync, writeFileSync
2
2
  import { isAbsolute, resolve, basename, relative, sep, dirname, normalize } from 'path';
3
3
  import { KNOWN_PRIMITIVES, KNOWN_OPERATORS, KNOWN_RULE_KINDS, SduiNode, ReactiveRule, IframeSandboxPageDeclaration, AssetDigest } from '@ethisyscore/protocol';
4
4
  import { createHash } from 'crypto';
5
+ import { createRequire } from 'module';
5
6
 
6
7
  // src/index.ts
7
8
  var KNOWN_PRIMITIVE_SET = new Set(KNOWN_PRIMITIVES);
@@ -1057,6 +1058,14 @@ function readManifest(options, root) {
1057
1058
  );
1058
1059
  }
1059
1060
  }
1061
+ function esbuildIsAvailable(root) {
1062
+ try {
1063
+ createRequire(resolve(root, "package.json")).resolve("esbuild");
1064
+ return true;
1065
+ } catch {
1066
+ return false;
1067
+ }
1068
+ }
1060
1069
  function makeDefaultBuild(viteBuild) {
1061
1070
  return async (ctx) => {
1062
1071
  const build = viteBuild ?? (await import('vite')).build;
@@ -1085,14 +1094,18 @@ function makeDefaultBuild(viteBuild) {
1085
1094
  // plugin opting out of console-stripping would also lose TS/JSX
1086
1095
  // transformation for any file its own plugins do not handle. An empty
1087
1096
  // options object keeps the transform and applies nothing.
1088
- esbuild: ctx.esbuild === false ? {} : ctx.esbuild ?? DEFAULT_ESBUILD,
1097
+ //
1098
+ // Omitted entirely where esbuild cannot be resolved: naming it would make
1099
+ // Vite 8 import an optional peer that is not installed. Minification still
1100
+ // happens there through oxc; only the esbuild-specific options are lost.
1101
+ ...esbuildIsAvailable(ctx.root) ? { esbuild: ctx.esbuild === false ? {} : ctx.esbuild ?? DEFAULT_ESBUILD } : {},
1089
1102
  build: {
1090
1103
  target: ctx.target,
1091
1104
  outDir: ctx.outDir,
1092
1105
  emptyOutDir: false,
1093
1106
  assetsDir: "",
1094
1107
  minify: ctx.minify,
1095
- cssMinify: ctx.cssMinify ?? "esbuild",
1108
+ cssMinify: ctx.cssMinify ?? true,
1096
1109
  reportCompressedSize: ctx.reportCompressedSize ?? false,
1097
1110
  sourcemap: ctx.sourcemap,
1098
1111
  rollupOptions: {
@@ -1204,7 +1217,7 @@ async function buildPlatformReactPages(options = {}) {
1204
1217
  sourcemap: options.sourcemap ?? "hidden",
1205
1218
  sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
1206
1219
  esbuild: options.esbuild ?? DEFAULT_ESBUILD,
1207
- cssMinify: options.cssMinify ?? "esbuild",
1220
+ cssMinify: options.cssMinify ?? true,
1208
1221
  reportCompressedSize: options.reportCompressedSize ?? false
1209
1222
  });
1210
1223
  }
@@ -1230,7 +1243,7 @@ async function buildPlatformReactPages(options = {}) {
1230
1243
  sourcemap: options.sourcemap ?? "hidden",
1231
1244
  sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
1232
1245
  esbuild: options.esbuild ?? DEFAULT_ESBUILD,
1233
- cssMinify: options.cssMinify ?? "esbuild",
1246
+ cssMinify: options.cssMinify ?? true,
1234
1247
  reportCompressedSize: options.reportCompressedSize ?? false
1235
1248
  });
1236
1249
  }