@ethisyscore/vite-plugin 1.104.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.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);
@@ -955,6 +956,19 @@ var DEFAULT_SRC_DIR = "src";
955
956
  var DEFAULT_ALIAS_PREFIX = "@";
956
957
  var SUMMARY_FILENAME = "platform-react-pages.json";
957
958
  var DIGEST_MAP_FILENAME = "platform-react-digest-map.json";
959
+ var DEFAULT_ESBUILD = {
960
+ // `pure`, not `drop: ["console"]`. A blanket drop removes `console.error` and
961
+ // `console.warn` too, and the SDK reports real failures through them from code
962
+ // bundled into every surface: a production URL-resolution failure in
963
+ // `plugin-ui/src/platform-react/surfaceUrl.ts`, and host-version skew in
964
+ // `useOrgFormatSync` and `useReportingCurrencySync`. Those would have failed
965
+ // silently in packaged bundles. Marking the noisy methods side-effect-free
966
+ // lets tree shaking remove them while diagnostics survive.
967
+ pure: ["console.log", "console.debug", "console.trace"],
968
+ drop: ["debugger"],
969
+ legalComments: "eof",
970
+ treeShaking: true
971
+ };
958
972
  function rewriteAliasedExternalImports() {
959
973
  return {
960
974
  name: "rewrite-aliased-external-imports",
@@ -1046,6 +1060,14 @@ function readManifest(options, root) {
1046
1060
  );
1047
1061
  }
1048
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
+ }
1049
1071
  function makeDefaultBuild(viteBuild) {
1050
1072
  return async (ctx) => {
1051
1073
  const build = viteBuild ?? (await import('vite')).build;
@@ -1066,12 +1088,27 @@ function makeDefaultBuild(viteBuild) {
1066
1088
  dedupe: [...ctx.dedupe],
1067
1089
  alias: ctx.alias
1068
1090
  },
1091
+ // Top-level, not under `build` — Vite feeds this to esbuild during
1092
+ // minification, which is where `drop` removes console/debugger calls.
1093
+ //
1094
+ // `false` is never forwarded. Vite reads `esbuild: false` as "drop the
1095
+ // esbuild transform plugin entirely", not as "apply no options", so a
1096
+ // plugin opting out of console-stripping would also lose TS/JSX
1097
+ // transformation for any file its own plugins do not handle. An empty
1098
+ // options object keeps the transform and applies nothing.
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 } : {},
1069
1104
  build: {
1070
1105
  target: ctx.target,
1071
1106
  outDir: ctx.outDir,
1072
1107
  emptyOutDir: false,
1073
1108
  assetsDir: "",
1074
1109
  minify: ctx.minify,
1110
+ cssMinify: ctx.cssMinify ?? true,
1111
+ reportCompressedSize: ctx.reportCompressedSize ?? false,
1075
1112
  sourcemap: ctx.sourcemap,
1076
1113
  rollupOptions: {
1077
1114
  input: { [ctx.pageId]: ctx.entryId },
@@ -1080,6 +1117,7 @@ function makeDefaultBuild(viteBuild) {
1080
1117
  output: {
1081
1118
  format: "es",
1082
1119
  inlineDynamicImports: true,
1120
+ sourcemapExcludeSources: ctx.sourcemapExcludeSources ?? true,
1083
1121
  entryFileNames: `${ctx.outputPrefix}/[name].js`,
1084
1122
  chunkFileNames: `${ctx.outputPrefix}/[name]-[hash].js`,
1085
1123
  assetFileNames: `${ctx.outputPrefix}/[name][extname]`
@@ -1176,9 +1214,13 @@ async function buildPlatformReactPages(options = {}) {
1176
1214
  dedupe,
1177
1215
  alias,
1178
1216
  plugins,
1179
- target: options.target ?? "es2022",
1180
- minify: options.minify ?? false,
1181
- sourcemap: options.sourcemap ?? true
1217
+ target: options.target ?? "esnext",
1218
+ minify: options.minify ?? true,
1219
+ sourcemap: options.sourcemap ?? "hidden",
1220
+ sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
1221
+ esbuild: options.esbuild ?? DEFAULT_ESBUILD,
1222
+ cssMinify: options.cssMinify ?? true,
1223
+ reportCompressedSize: options.reportCompressedSize ?? false
1182
1224
  });
1183
1225
  }
1184
1226
  if (overlay) {
@@ -1198,9 +1240,13 @@ async function buildPlatformReactPages(options = {}) {
1198
1240
  dedupe,
1199
1241
  alias,
1200
1242
  plugins,
1201
- target: options.target ?? "es2022",
1202
- minify: options.minify ?? false,
1203
- sourcemap: options.sourcemap ?? true
1243
+ target: options.target ?? "esnext",
1244
+ minify: options.minify ?? true,
1245
+ sourcemap: options.sourcemap ?? "hidden",
1246
+ sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
1247
+ esbuild: options.esbuild ?? DEFAULT_ESBUILD,
1248
+ cssMinify: options.cssMinify ?? true,
1249
+ reportCompressedSize: options.reportCompressedSize ?? false
1204
1250
  });
1205
1251
  }
1206
1252
  const summaryPages = pages.map((p) => ({
@@ -2194,6 +2240,15 @@ function ethisysManifestPlugin(options = {}) {
2194
2240
  }
2195
2241
  };
2196
2242
  }
2243
+ /**
2244
+ * esbuild options applied while minifying.
2245
+ *
2246
+ * `legalComments: "eof"`, not `"none"`: this builder bundles every non-external
2247
+ * dependency into each surface, so stripping `/*!` and `@preserve` banners would
2248
+ * distribute third-party code without the attribution its licence requires.
2249
+ * Collecting them at end of file keeps the notices while leaving the code itself
2250
+ * comment-free.
2251
+ */
2197
2252
 
2198
2253
  exports.CONTRACT_B_IMPORT_MAP_ALLOWLIST = CONTRACT_B_IMPORT_MAP_ALLOWLIST;
2199
2254
  exports.CONTRACT_B_RUNTIME_IMPORTS = CONTRACT_B_RUNTIME_IMPORTS;