build: switch from rollup and terser to esbuild for creating contract bundle (#55705)

This commit implements the replacement of rollup and terser with esbuild for generating the contract_bundle binary. The transition is facilitated by optimizations aimed at reducing the bundle size.

PR Close #55705
This commit is contained in:
Alan Agius
2024-05-07 07:37:15 +00:00
committed by Andrew Scott
parent 0cb50317e1
commit ef029b8d00
3 changed files with 13 additions and 34 deletions
+1 -1
View File
@@ -148,5 +148,5 @@ genrule(
name = "event_dispatch_contract_binary",
srcs = ["//packages/core/primitives/event-dispatch:contract_bundle_min"],
outs = ["event-dispatch-contract.min.js"],
cmd = "cat $< >> $@",
cmd = "cp $< $@",
)
@@ -1,6 +1,4 @@
load("//tools:defaults.bzl", "ts_library", "tsec_test")
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
load("@npm//@bazel/terser:index.bzl", "terser_minified")
load("//tools:defaults.bzl", "esbuild", "ts_library", "tsec_test")
package(default_visibility = ["//visibility:public"])
@@ -29,17 +27,18 @@ filegroup(
visibility = ["//visibility:public"],
)
rollup_bundle(
name = "contract_bundle",
args = ["--no-sourcemap"],
esbuild(
name = "contract_bundle_min",
args = {
"sourcemap": False,
"resolveExtensions": [
".mjs",
],
"legalComments": "none",
},
entry_point = ":contract_binary.ts",
format = "iife",
minify = True,
sourcemap = "inline",
deps = [":event-dispatch"],
)
terser_minified(
name = "contract_bundle_min",
src = ":contract_bundle",
config_file = ":terser.config.json",
sourcemap = False,
)
@@ -1,20 +0,0 @@
{
"ecma": "es2020",
"compress": {
"toplevel": true,
"passes": 2,
"pure_getters": true
},
"mangle": {
"toplevel": true,
"properties": false,
"keep_classnames": false,
"keep_fnames": false
},
"format": {
"ecma": "es2020",
"ascii_only": true,
"wrap_func_args": false,
"comments": false
}
}