mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
With the recent changes to the APF bundling rules, we turned on tree-shaking in rollup to support proper code splitting for FESM bundles. This resulted in Rollup re-ordering imports in the FESM bundles of `@angular/platform-browser-dynamic`— highlighting that over the past years, this package "accidentally" resulted in the side-effects of the compiler registering itself globally. This continues to be the case, and our changes generally didn't cause any issues in CLI applications because the CLI explicitly wires up the compiler (as expected) before `-dynamic` is even loaded. For custom setup, like Analog, this order change surfaced a breakage because e.g. `@angular/common` with its JIT decorators of e.g. directives/services are triggered before the compiler is actually loaded/made available. This commit fixes this. The explicit imports in practice are a noop because our FESM bundling doesn't recognize compiler as side-effects true; but marking the whole -dynamic package as having side-effects; prevents rollup from swapping the import order. Long-term, we should look into improving this by teaching `ng_package` that e.g. the compiler has side-effects; so that the `import @angular/compiler` statement is not dropped when constructing FESM bundles. PR Close #60458
75 lines
1.9 KiB
Text
75 lines
1.9 KiB
Text
load("//tools:defaults.bzl", "api_golden_test_npm_package", "generate_api_docs", "ng_module", "ng_package")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
ng_module(
|
|
name = "platform-browser-dynamic",
|
|
package_name = "@angular/platform-browser-dynamic",
|
|
srcs = glob(
|
|
[
|
|
"*.ts",
|
|
"src/**/*.ts",
|
|
],
|
|
),
|
|
deps = [
|
|
"//packages:types",
|
|
"//packages/common",
|
|
"//packages/compiler",
|
|
"//packages/core",
|
|
"//packages/platform-browser",
|
|
],
|
|
)
|
|
|
|
ng_package(
|
|
name = "npm_package",
|
|
srcs = [
|
|
"package.json",
|
|
],
|
|
side_effect_entry_points = [
|
|
"@angular/platform-browser-dynamic",
|
|
"@angular/platform-browser-dynamic/testing",
|
|
],
|
|
tags = [
|
|
"release-with-framework",
|
|
],
|
|
# Do not add more to this list.
|
|
# Dependencies on the full npm_package cause long re-builds.
|
|
visibility = [
|
|
"//adev:__pkg__",
|
|
"//integration:__subpackages__",
|
|
"//modules/ssr-benchmarks:__subpackages__",
|
|
"//packages/compiler-cli/integrationtest:__pkg__",
|
|
],
|
|
deps = [
|
|
":platform-browser-dynamic",
|
|
"//packages/platform-browser-dynamic/testing",
|
|
],
|
|
)
|
|
|
|
api_golden_test_npm_package(
|
|
name = "platform-browser-dynamic_api",
|
|
data = [
|
|
":npm_package",
|
|
"//goldens:public-api",
|
|
],
|
|
golden_dir = "angular/goldens/public-api/platform-browser-dynamic",
|
|
npm_package = "angular/packages/platform-browser-dynamic/npm_package",
|
|
)
|
|
|
|
filegroup(
|
|
name = "files_for_docgen",
|
|
srcs = glob([
|
|
"*.ts",
|
|
"src/**/*.ts",
|
|
]) + ["PACKAGE.md"],
|
|
)
|
|
|
|
generate_api_docs(
|
|
name = "platform-browser_dynamic_docs",
|
|
srcs = [
|
|
":files_for_docgen",
|
|
"//packages:common_files_and_deps_for_docs",
|
|
],
|
|
entry_point = ":index.ts",
|
|
module_name = "@angular/platform-browser-dynamic",
|
|
)
|