mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
a3908bd0fc
Enables code spitting for ESBuild bundling of the localize/tools entry point. When we initially configured ESBuild as part of APF v13, we left this option disabled as code splitting is marked experimental. The ESM splitting mechanism in ESBuild seems very solid so far (judging subjectively and by experience/reports in the ESBuild repo), so we should give it a shot, in order to significantly reduce the size of the NPM package, and simplify debugging (by not having duplicated code portions for all the different entry points). To clarify: Code splitting is helpful as we have multiple entry-points that currently duplicate code. With code splitting these entry-points would share common code instead. PR Close #43932
72 lines
1.5 KiB
Python
72 lines
1.5 KiB
Python
load("@npm//@bazel/esbuild:index.bzl", "esbuild", "esbuild_config")
|
|
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
|
|
load("//tools:extract_typings_rule.bzl", "extract_typings")
|
|
|
|
ts_library(
|
|
name = "tools",
|
|
srcs = glob(
|
|
[
|
|
"**/*.ts",
|
|
],
|
|
),
|
|
visibility = ["//packages/localize/tools:__subpackages__"],
|
|
deps = [
|
|
"//packages/compiler",
|
|
"//packages/compiler-cli/private",
|
|
"//packages/localize",
|
|
"@npm//@babel/core",
|
|
"@npm//@types/babel__core",
|
|
"@npm//@types/babel__traverse",
|
|
"@npm//@types/glob",
|
|
"@npm//@types/node",
|
|
"@npm//@types/yargs",
|
|
"@npm//glob",
|
|
],
|
|
)
|
|
|
|
esbuild_config(
|
|
name = "esbuild_config",
|
|
config_file = "esbuild.config.js",
|
|
)
|
|
|
|
esbuild(
|
|
name = "bundles",
|
|
config = ":esbuild_config",
|
|
entry_points = [
|
|
":index.ts",
|
|
":src/extract/cli.ts",
|
|
":src/migrate/cli.ts",
|
|
":src/translate/cli.ts",
|
|
],
|
|
external = [
|
|
"@angular/localize",
|
|
"@angular/compiler",
|
|
"@angular/compiler-cli/private/localize",
|
|
"@babel/core",
|
|
"yargs",
|
|
"glob",
|
|
],
|
|
format = "esm",
|
|
platform = "node",
|
|
splitting = True,
|
|
target = "node12",
|
|
deps = [
|
|
":tools",
|
|
],
|
|
)
|
|
|
|
extract_typings(
|
|
name = "api_type_definitions",
|
|
deps = [":tools"],
|
|
)
|
|
|
|
pkg_npm(
|
|
name = "npm_package",
|
|
srcs = ["README.md"],
|
|
visibility = ["//packages/localize:__pkg__"],
|
|
deps = [
|
|
":api_type_definitions",
|
|
":bundles",
|
|
],
|
|
)
|