Refactors the `ng_rollup_bundle` rule to a macro that relies on the `@bazel/rollup` package. This means that the rule no longer deals with custom ESM5 flavour output, but rather only builds prodmode ES2015 output. This matches the common build output in Angular projects, and optimizations done in CLI where ES2015 is the default optimization input. The motiviation for this change is: * Not duplicating rollup Bazel rules. Instead leveraging the official rollup rule. * Not dealing with a third TS output flavor in Bazel.The ESM5 flavour has the potential of slowing down local development (as it requires compilation replaying) * Updating the rule to be aligned with current CLI optimizations. This also _fixes_ a bug that surfaced in the old rollup bundle rule. Code that is unused, is not removed properly. The new rule fixes this by setting the `toplevel` flag. This instructs terser to remove unused definitions at top-level. This matches the optimization applied in CLI projects. Notably the CLI doesn't need this flag, as code is always wrapped by Webpack. Hence, the unused code eliding runs by default. PR Close #37623
26 lines
847 B
Python
26 lines
847 B
Python
load("//dev-infra/benchmark/ng_rollup_bundle:ng_rollup_bundle.bzl", "ng_rollup_bundle")
|
|
|
|
def ls_rollup_bundle(name, **kwargs):
|
|
"""
|
|
A variant of ng_rollup_bundle for the language-service bundle that
|
|
outputs in AMD format.
|
|
"""
|
|
visibility = kwargs.pop("visibility", None)
|
|
|
|
# Note: the output file is called "umd.js" because of historical reasons.
|
|
# The format is actually AMD and not UMD, but we are afraid to rename
|
|
# the file because that would likely break the IDE and other integrations that
|
|
# have the path hardcoded in them.
|
|
ng_rollup_bundle(
|
|
name = name + ".umd",
|
|
build_optimizer = False,
|
|
format = "amd",
|
|
visibility = visibility,
|
|
**kwargs
|
|
)
|
|
native.alias(
|
|
name = name,
|
|
actual = name + ".umd",
|
|
visibility = visibility,
|
|
)
|