@ethisyscore/vite-plugin 1.104.0 → 1.105.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
@@ -955,6 +955,19 @@ var DEFAULT_SRC_DIR = "src";
955
955
  var DEFAULT_ALIAS_PREFIX = "@";
956
956
  var SUMMARY_FILENAME = "platform-react-pages.json";
957
957
  var DIGEST_MAP_FILENAME = "platform-react-digest-map.json";
958
+ var DEFAULT_ESBUILD = {
959
+ // `pure`, not `drop: ["console"]`. A blanket drop removes `console.error` and
960
+ // `console.warn` too, and the SDK reports real failures through them from code
961
+ // bundled into every surface: a production URL-resolution failure in
962
+ // `plugin-ui/src/platform-react/surfaceUrl.ts`, and host-version skew in
963
+ // `useOrgFormatSync` and `useReportingCurrencySync`. Those would have failed
964
+ // silently in packaged bundles. Marking the noisy methods side-effect-free
965
+ // lets tree shaking remove them while diagnostics survive.
966
+ pure: ["console.log", "console.debug", "console.trace"],
967
+ drop: ["debugger"],
968
+ legalComments: "eof",
969
+ treeShaking: true
970
+ };
958
971
  function rewriteAliasedExternalImports() {
959
972
  return {
960
973
  name: "rewrite-aliased-external-imports",
@@ -1066,12 +1079,23 @@ function makeDefaultBuild(viteBuild) {
1066
1079
  dedupe: [...ctx.dedupe],
1067
1080
  alias: ctx.alias
1068
1081
  },
1082
+ // Top-level, not under `build` — Vite feeds this to esbuild during
1083
+ // minification, which is where `drop` removes console/debugger calls.
1084
+ //
1085
+ // `false` is never forwarded. Vite reads `esbuild: false` as "drop the
1086
+ // esbuild transform plugin entirely", not as "apply no options", so a
1087
+ // plugin opting out of console-stripping would also lose TS/JSX
1088
+ // transformation for any file its own plugins do not handle. An empty
1089
+ // options object keeps the transform and applies nothing.
1090
+ esbuild: ctx.esbuild === false ? {} : ctx.esbuild ?? DEFAULT_ESBUILD,
1069
1091
  build: {
1070
1092
  target: ctx.target,
1071
1093
  outDir: ctx.outDir,
1072
1094
  emptyOutDir: false,
1073
1095
  assetsDir: "",
1074
1096
  minify: ctx.minify,
1097
+ cssMinify: ctx.cssMinify ?? "esbuild",
1098
+ reportCompressedSize: ctx.reportCompressedSize ?? false,
1075
1099
  sourcemap: ctx.sourcemap,
1076
1100
  rollupOptions: {
1077
1101
  input: { [ctx.pageId]: ctx.entryId },
@@ -1080,6 +1104,7 @@ function makeDefaultBuild(viteBuild) {
1080
1104
  output: {
1081
1105
  format: "es",
1082
1106
  inlineDynamicImports: true,
1107
+ sourcemapExcludeSources: ctx.sourcemapExcludeSources ?? true,
1083
1108
  entryFileNames: `${ctx.outputPrefix}/[name].js`,
1084
1109
  chunkFileNames: `${ctx.outputPrefix}/[name]-[hash].js`,
1085
1110
  assetFileNames: `${ctx.outputPrefix}/[name][extname]`
@@ -1176,9 +1201,13 @@ async function buildPlatformReactPages(options = {}) {
1176
1201
  dedupe,
1177
1202
  alias,
1178
1203
  plugins,
1179
- target: options.target ?? "es2022",
1180
- minify: options.minify ?? false,
1181
- sourcemap: options.sourcemap ?? true
1204
+ target: options.target ?? "esnext",
1205
+ minify: options.minify ?? true,
1206
+ sourcemap: options.sourcemap ?? "hidden",
1207
+ sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
1208
+ esbuild: options.esbuild ?? DEFAULT_ESBUILD,
1209
+ cssMinify: options.cssMinify ?? "esbuild",
1210
+ reportCompressedSize: options.reportCompressedSize ?? false
1182
1211
  });
1183
1212
  }
1184
1213
  if (overlay) {
@@ -1198,9 +1227,13 @@ async function buildPlatformReactPages(options = {}) {
1198
1227
  dedupe,
1199
1228
  alias,
1200
1229
  plugins,
1201
- target: options.target ?? "es2022",
1202
- minify: options.minify ?? false,
1203
- sourcemap: options.sourcemap ?? true
1230
+ target: options.target ?? "esnext",
1231
+ minify: options.minify ?? true,
1232
+ sourcemap: options.sourcemap ?? "hidden",
1233
+ sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
1234
+ esbuild: options.esbuild ?? DEFAULT_ESBUILD,
1235
+ cssMinify: options.cssMinify ?? "esbuild",
1236
+ reportCompressedSize: options.reportCompressedSize ?? false
1204
1237
  });
1205
1238
  }
1206
1239
  const summaryPages = pages.map((p) => ({
@@ -2194,6 +2227,15 @@ function ethisysManifestPlugin(options = {}) {
2194
2227
  }
2195
2228
  };
2196
2229
  }
2230
+ /**
2231
+ * esbuild options applied while minifying.
2232
+ *
2233
+ * `legalComments: "eof"`, not `"none"`: this builder bundles every non-external
2234
+ * dependency into each surface, so stripping `/*!` and `@preserve` banners would
2235
+ * distribute third-party code without the attribution its licence requires.
2236
+ * Collecting them at end of file keeps the notices while leaving the code itself
2237
+ * comment-free.
2238
+ */
2197
2239
 
2198
2240
  exports.CONTRACT_B_IMPORT_MAP_ALLOWLIST = CONTRACT_B_IMPORT_MAP_ALLOWLIST;
2199
2241
  exports.CONTRACT_B_RUNTIME_IMPORTS = CONTRACT_B_RUNTIME_IMPORTS;