@ethisyscore/vite-plugin 1.103.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 +48 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -8
- package/dist/index.d.ts +65 -8
- package/dist/index.js +48 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, InlineConfig } from 'vite';
|
|
1
|
+
import { Plugin, ESBuildOptions, InlineConfig } from 'vite';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Reference from the plugin manifest to an SDUI resource JSON file.
|
|
@@ -440,8 +440,18 @@ interface PlatformReactBuildContext {
|
|
|
440
440
|
alias: PlatformReactAlias[];
|
|
441
441
|
plugins: Plugin[];
|
|
442
442
|
target: string;
|
|
443
|
-
minify: boolean;
|
|
444
|
-
sourcemap: boolean;
|
|
443
|
+
minify: boolean | "esbuild" | "terser";
|
|
444
|
+
sourcemap: boolean | "inline" | "hidden";
|
|
445
|
+
/**
|
|
446
|
+
* Optional so an existing consumer constructing this context keeps compiling.
|
|
447
|
+
* This type is exported through the `PlatformReactViteBuild` seam, so a
|
|
448
|
+
* required field here is a breaking change for anyone who builds one by hand.
|
|
449
|
+
* The orchestrator always sets them; the defaults below only cover that case.
|
|
450
|
+
*/
|
|
451
|
+
sourcemapExcludeSources?: boolean;
|
|
452
|
+
esbuild?: ESBuildOptions | false;
|
|
453
|
+
cssMinify?: boolean | "esbuild" | "lightningcss";
|
|
454
|
+
reportCompressedSize?: boolean;
|
|
445
455
|
}
|
|
446
456
|
/** Low-level Vite `build` function. Defaults to a dynamic `import("vite")`. */
|
|
447
457
|
type ViteBuildFn = (config: InlineConfig) => Promise<unknown>;
|
|
@@ -474,12 +484,59 @@ interface BuildPlatformReactPagesOptions {
|
|
|
474
484
|
srcDir?: string;
|
|
475
485
|
/** Alias prefix manifest `src/…` paths are rewritten to. Default `@` (→ `@/…`). */
|
|
476
486
|
aliasPrefix?: string;
|
|
477
|
-
/**
|
|
487
|
+
/**
|
|
488
|
+
* Rollup build target. Default `esnext`.
|
|
489
|
+
*
|
|
490
|
+
* Only worth it alongside minification. Measured across 50 finance surfaces,
|
|
491
|
+
* `esnext` on unminified output cost 10% MORE gzipped than `es2022`, because
|
|
492
|
+
* it skips the esbuild pass that also normalises emitted code. Lower the
|
|
493
|
+
* target too if minification is ever turned off.
|
|
494
|
+
*/
|
|
478
495
|
target?: string;
|
|
479
|
-
/**
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
496
|
+
/**
|
|
497
|
+
* Minify output. Default `true`, worth roughly 31% of gzipped transfer.
|
|
498
|
+
*
|
|
499
|
+
* DEPLOYMENT ORDER: a minified bundle only mounts on a host whose module
|
|
500
|
+
* registry walks the import prologue. The earlier rewriter was line-anchored
|
|
501
|
+
* and matched an import only when it sat on its own line; a minifier puts the
|
|
502
|
+
* whole prologue on line one, where nothing matched, so `react` and
|
|
503
|
+
* `@mui/material` reached the browser as unresolvable bare specifiers and the
|
|
504
|
+
* surface threw at mount. A plugin built with this default must therefore not
|
|
505
|
+
* be promoted ahead of that host change.
|
|
506
|
+
*/
|
|
507
|
+
minify?: boolean | "esbuild" | "terser";
|
|
508
|
+
/**
|
|
509
|
+
* Sourcemap mode. Default `"hidden"`: the map is emitted but no
|
|
510
|
+
* `sourceMappingURL` comment is written into the bundle, so a browser never
|
|
511
|
+
* fetches it and cannot 404 on a map stripped before deploy.
|
|
512
|
+
*/
|
|
513
|
+
sourcemap?: boolean | "inline" | "hidden";
|
|
514
|
+
/**
|
|
515
|
+
* Omit `sourcesContent` from emitted maps. Default `true`. The map keeps the
|
|
516
|
+
* `mappings` needed to rewrite a stack trace, but carries no source bodies —
|
|
517
|
+
* which both shrinks it by roughly 80% and removes the source-in-map leak path.
|
|
518
|
+
*/
|
|
519
|
+
sourcemapExcludeSources?: boolean;
|
|
520
|
+
/**
|
|
521
|
+
* esbuild options applied while minifying. The default drops `console` and
|
|
522
|
+
* `debugger` calls, so diagnostic logging a developer left in a page never
|
|
523
|
+
* reaches a packaged bundle. Pass `false` to keep them — a plugin that
|
|
524
|
+
* reports failures through `console.error` must move to the runtime logger
|
|
525
|
+
* before relying on the default.
|
|
526
|
+
*
|
|
527
|
+
* `false` means "apply no esbuild options". It does NOT disable esbuild: Vite
|
|
528
|
+
* would read that as removing the transform plugin, taking TS and JSX handling
|
|
529
|
+
* with it.
|
|
530
|
+
*/
|
|
531
|
+
esbuild?: ESBuildOptions | false;
|
|
532
|
+
/** Minify CSS before it is inlined into the bundle. Default `"esbuild"`. */
|
|
533
|
+
cssMinify?: boolean | "esbuild" | "lightningcss";
|
|
534
|
+
/**
|
|
535
|
+
* Print the post-build gzip-size table. Default `false`: the numbers are
|
|
536
|
+
* informational, and producing them compresses every chunk a second time —
|
|
537
|
+
* once per sub-build, so the cost scales with surface count.
|
|
538
|
+
*/
|
|
539
|
+
reportCompressedSize?: boolean;
|
|
483
540
|
/** Wipe `outDir` before building. Default `true`. */
|
|
484
541
|
clean?: boolean;
|
|
485
542
|
/** Progress logger. Default `console`. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, InlineConfig } from 'vite';
|
|
1
|
+
import { Plugin, ESBuildOptions, InlineConfig } from 'vite';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Reference from the plugin manifest to an SDUI resource JSON file.
|
|
@@ -440,8 +440,18 @@ interface PlatformReactBuildContext {
|
|
|
440
440
|
alias: PlatformReactAlias[];
|
|
441
441
|
plugins: Plugin[];
|
|
442
442
|
target: string;
|
|
443
|
-
minify: boolean;
|
|
444
|
-
sourcemap: boolean;
|
|
443
|
+
minify: boolean | "esbuild" | "terser";
|
|
444
|
+
sourcemap: boolean | "inline" | "hidden";
|
|
445
|
+
/**
|
|
446
|
+
* Optional so an existing consumer constructing this context keeps compiling.
|
|
447
|
+
* This type is exported through the `PlatformReactViteBuild` seam, so a
|
|
448
|
+
* required field here is a breaking change for anyone who builds one by hand.
|
|
449
|
+
* The orchestrator always sets them; the defaults below only cover that case.
|
|
450
|
+
*/
|
|
451
|
+
sourcemapExcludeSources?: boolean;
|
|
452
|
+
esbuild?: ESBuildOptions | false;
|
|
453
|
+
cssMinify?: boolean | "esbuild" | "lightningcss";
|
|
454
|
+
reportCompressedSize?: boolean;
|
|
445
455
|
}
|
|
446
456
|
/** Low-level Vite `build` function. Defaults to a dynamic `import("vite")`. */
|
|
447
457
|
type ViteBuildFn = (config: InlineConfig) => Promise<unknown>;
|
|
@@ -474,12 +484,59 @@ interface BuildPlatformReactPagesOptions {
|
|
|
474
484
|
srcDir?: string;
|
|
475
485
|
/** Alias prefix manifest `src/…` paths are rewritten to. Default `@` (→ `@/…`). */
|
|
476
486
|
aliasPrefix?: string;
|
|
477
|
-
/**
|
|
487
|
+
/**
|
|
488
|
+
* Rollup build target. Default `esnext`.
|
|
489
|
+
*
|
|
490
|
+
* Only worth it alongside minification. Measured across 50 finance surfaces,
|
|
491
|
+
* `esnext` on unminified output cost 10% MORE gzipped than `es2022`, because
|
|
492
|
+
* it skips the esbuild pass that also normalises emitted code. Lower the
|
|
493
|
+
* target too if minification is ever turned off.
|
|
494
|
+
*/
|
|
478
495
|
target?: string;
|
|
479
|
-
/**
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
496
|
+
/**
|
|
497
|
+
* Minify output. Default `true`, worth roughly 31% of gzipped transfer.
|
|
498
|
+
*
|
|
499
|
+
* DEPLOYMENT ORDER: a minified bundle only mounts on a host whose module
|
|
500
|
+
* registry walks the import prologue. The earlier rewriter was line-anchored
|
|
501
|
+
* and matched an import only when it sat on its own line; a minifier puts the
|
|
502
|
+
* whole prologue on line one, where nothing matched, so `react` and
|
|
503
|
+
* `@mui/material` reached the browser as unresolvable bare specifiers and the
|
|
504
|
+
* surface threw at mount. A plugin built with this default must therefore not
|
|
505
|
+
* be promoted ahead of that host change.
|
|
506
|
+
*/
|
|
507
|
+
minify?: boolean | "esbuild" | "terser";
|
|
508
|
+
/**
|
|
509
|
+
* Sourcemap mode. Default `"hidden"`: the map is emitted but no
|
|
510
|
+
* `sourceMappingURL` comment is written into the bundle, so a browser never
|
|
511
|
+
* fetches it and cannot 404 on a map stripped before deploy.
|
|
512
|
+
*/
|
|
513
|
+
sourcemap?: boolean | "inline" | "hidden";
|
|
514
|
+
/**
|
|
515
|
+
* Omit `sourcesContent` from emitted maps. Default `true`. The map keeps the
|
|
516
|
+
* `mappings` needed to rewrite a stack trace, but carries no source bodies —
|
|
517
|
+
* which both shrinks it by roughly 80% and removes the source-in-map leak path.
|
|
518
|
+
*/
|
|
519
|
+
sourcemapExcludeSources?: boolean;
|
|
520
|
+
/**
|
|
521
|
+
* esbuild options applied while minifying. The default drops `console` and
|
|
522
|
+
* `debugger` calls, so diagnostic logging a developer left in a page never
|
|
523
|
+
* reaches a packaged bundle. Pass `false` to keep them — a plugin that
|
|
524
|
+
* reports failures through `console.error` must move to the runtime logger
|
|
525
|
+
* before relying on the default.
|
|
526
|
+
*
|
|
527
|
+
* `false` means "apply no esbuild options". It does NOT disable esbuild: Vite
|
|
528
|
+
* would read that as removing the transform plugin, taking TS and JSX handling
|
|
529
|
+
* with it.
|
|
530
|
+
*/
|
|
531
|
+
esbuild?: ESBuildOptions | false;
|
|
532
|
+
/** Minify CSS before it is inlined into the bundle. Default `"esbuild"`. */
|
|
533
|
+
cssMinify?: boolean | "esbuild" | "lightningcss";
|
|
534
|
+
/**
|
|
535
|
+
* Print the post-build gzip-size table. Default `false`: the numbers are
|
|
536
|
+
* informational, and producing them compresses every chunk a second time —
|
|
537
|
+
* once per sub-build, so the cost scales with surface count.
|
|
538
|
+
*/
|
|
539
|
+
reportCompressedSize?: boolean;
|
|
483
540
|
/** Wipe `outDir` before building. Default `true`. */
|
|
484
541
|
clean?: boolean;
|
|
485
542
|
/** Progress logger. Default `console`. */
|
package/dist/index.js
CHANGED
|
@@ -953,6 +953,19 @@ var DEFAULT_SRC_DIR = "src";
|
|
|
953
953
|
var DEFAULT_ALIAS_PREFIX = "@";
|
|
954
954
|
var SUMMARY_FILENAME = "platform-react-pages.json";
|
|
955
955
|
var DIGEST_MAP_FILENAME = "platform-react-digest-map.json";
|
|
956
|
+
var DEFAULT_ESBUILD = {
|
|
957
|
+
// `pure`, not `drop: ["console"]`. A blanket drop removes `console.error` and
|
|
958
|
+
// `console.warn` too, and the SDK reports real failures through them from code
|
|
959
|
+
// bundled into every surface: a production URL-resolution failure in
|
|
960
|
+
// `plugin-ui/src/platform-react/surfaceUrl.ts`, and host-version skew in
|
|
961
|
+
// `useOrgFormatSync` and `useReportingCurrencySync`. Those would have failed
|
|
962
|
+
// silently in packaged bundles. Marking the noisy methods side-effect-free
|
|
963
|
+
// lets tree shaking remove them while diagnostics survive.
|
|
964
|
+
pure: ["console.log", "console.debug", "console.trace"],
|
|
965
|
+
drop: ["debugger"],
|
|
966
|
+
legalComments: "eof",
|
|
967
|
+
treeShaking: true
|
|
968
|
+
};
|
|
956
969
|
function rewriteAliasedExternalImports() {
|
|
957
970
|
return {
|
|
958
971
|
name: "rewrite-aliased-external-imports",
|
|
@@ -1064,12 +1077,23 @@ function makeDefaultBuild(viteBuild) {
|
|
|
1064
1077
|
dedupe: [...ctx.dedupe],
|
|
1065
1078
|
alias: ctx.alias
|
|
1066
1079
|
},
|
|
1080
|
+
// Top-level, not under `build` — Vite feeds this to esbuild during
|
|
1081
|
+
// minification, which is where `drop` removes console/debugger calls.
|
|
1082
|
+
//
|
|
1083
|
+
// `false` is never forwarded. Vite reads `esbuild: false` as "drop the
|
|
1084
|
+
// esbuild transform plugin entirely", not as "apply no options", so a
|
|
1085
|
+
// plugin opting out of console-stripping would also lose TS/JSX
|
|
1086
|
+
// transformation for any file its own plugins do not handle. An empty
|
|
1087
|
+
// options object keeps the transform and applies nothing.
|
|
1088
|
+
esbuild: ctx.esbuild === false ? {} : ctx.esbuild ?? DEFAULT_ESBUILD,
|
|
1067
1089
|
build: {
|
|
1068
1090
|
target: ctx.target,
|
|
1069
1091
|
outDir: ctx.outDir,
|
|
1070
1092
|
emptyOutDir: false,
|
|
1071
1093
|
assetsDir: "",
|
|
1072
1094
|
minify: ctx.minify,
|
|
1095
|
+
cssMinify: ctx.cssMinify ?? "esbuild",
|
|
1096
|
+
reportCompressedSize: ctx.reportCompressedSize ?? false,
|
|
1073
1097
|
sourcemap: ctx.sourcemap,
|
|
1074
1098
|
rollupOptions: {
|
|
1075
1099
|
input: { [ctx.pageId]: ctx.entryId },
|
|
@@ -1078,6 +1102,7 @@ function makeDefaultBuild(viteBuild) {
|
|
|
1078
1102
|
output: {
|
|
1079
1103
|
format: "es",
|
|
1080
1104
|
inlineDynamicImports: true,
|
|
1105
|
+
sourcemapExcludeSources: ctx.sourcemapExcludeSources ?? true,
|
|
1081
1106
|
entryFileNames: `${ctx.outputPrefix}/[name].js`,
|
|
1082
1107
|
chunkFileNames: `${ctx.outputPrefix}/[name]-[hash].js`,
|
|
1083
1108
|
assetFileNames: `${ctx.outputPrefix}/[name][extname]`
|
|
@@ -1174,9 +1199,13 @@ async function buildPlatformReactPages(options = {}) {
|
|
|
1174
1199
|
dedupe,
|
|
1175
1200
|
alias,
|
|
1176
1201
|
plugins,
|
|
1177
|
-
target: options.target ?? "
|
|
1178
|
-
minify: options.minify ??
|
|
1179
|
-
sourcemap: options.sourcemap ??
|
|
1202
|
+
target: options.target ?? "esnext",
|
|
1203
|
+
minify: options.minify ?? true,
|
|
1204
|
+
sourcemap: options.sourcemap ?? "hidden",
|
|
1205
|
+
sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
|
|
1206
|
+
esbuild: options.esbuild ?? DEFAULT_ESBUILD,
|
|
1207
|
+
cssMinify: options.cssMinify ?? "esbuild",
|
|
1208
|
+
reportCompressedSize: options.reportCompressedSize ?? false
|
|
1180
1209
|
});
|
|
1181
1210
|
}
|
|
1182
1211
|
if (overlay) {
|
|
@@ -1196,9 +1225,13 @@ async function buildPlatformReactPages(options = {}) {
|
|
|
1196
1225
|
dedupe,
|
|
1197
1226
|
alias,
|
|
1198
1227
|
plugins,
|
|
1199
|
-
target: options.target ?? "
|
|
1200
|
-
minify: options.minify ??
|
|
1201
|
-
sourcemap: options.sourcemap ??
|
|
1228
|
+
target: options.target ?? "esnext",
|
|
1229
|
+
minify: options.minify ?? true,
|
|
1230
|
+
sourcemap: options.sourcemap ?? "hidden",
|
|
1231
|
+
sourcemapExcludeSources: options.sourcemapExcludeSources ?? true,
|
|
1232
|
+
esbuild: options.esbuild ?? DEFAULT_ESBUILD,
|
|
1233
|
+
cssMinify: options.cssMinify ?? "esbuild",
|
|
1234
|
+
reportCompressedSize: options.reportCompressedSize ?? false
|
|
1202
1235
|
});
|
|
1203
1236
|
}
|
|
1204
1237
|
const summaryPages = pages.map((p) => ({
|
|
@@ -2192,6 +2225,15 @@ function ethisysManifestPlugin(options = {}) {
|
|
|
2192
2225
|
}
|
|
2193
2226
|
};
|
|
2194
2227
|
}
|
|
2228
|
+
/**
|
|
2229
|
+
* esbuild options applied while minifying.
|
|
2230
|
+
*
|
|
2231
|
+
* `legalComments: "eof"`, not `"none"`: this builder bundles every non-external
|
|
2232
|
+
* dependency into each surface, so stripping `/*!` and `@preserve` banners would
|
|
2233
|
+
* distribute third-party code without the attribution its licence requires.
|
|
2234
|
+
* Collecting them at end of file keeps the notices while leaving the code itself
|
|
2235
|
+
* comment-free.
|
|
2236
|
+
*/
|
|
2195
2237
|
|
|
2196
2238
|
export { CONTRACT_B_IMPORT_MAP_ALLOWLIST, CONTRACT_B_RUNTIME_IMPORTS, CONTRACT_B_SEMANTIC_PRIMITIVES, EHX_PLUGIN_CSS_SCOPE, EHX_PLUGIN_ROOT_SCOPE, EHX_PLUGIN_SCOPE_ROOTS, EHX_SCOPED_CSS_LAYERS, PLATFORM_REACT_DEDUPE, PLATFORM_REACT_EXTERNALS, buildIframeSandboxPages, buildPlatformReactPages, computePlatformReactPages, ethisysContractAPlugin, ethisysContractBPlugin, ethisysIframeSandboxPlugin, ethisysManifestPlugin, ethisysPlatformReactPagesPlugin, ethisysPlatformReactPlugin, findUnscopedSelectors, formatUnscopedSelectorError, generatePlatformReactManifest, isScopableCssId, parseExportedNames, parsePlatformReactPages, rewriteAliasedExternalImports, scopePluginCss, scopePluginCssPlugin, validateDeclarativeResource, validateReactiveRule, virtualPageEntry };
|
|
2197
2239
|
//# sourceMappingURL=index.js.map
|