Skip to content

Commit 1bfd7bb

Browse files
devversionjosephperrott
authored andcommitted
build: prepare for compiler-cli to be using ts_project (#61237)
Prepare the compiler-cli package for being ready for migration to `ts_project`. PR Close #61237
1 parent a5002fd commit 1bfd7bb

File tree

18 files changed

+105
-118
lines changed

18 files changed

+105
-118
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ yarn_install(
8585
"//:tools/npm-patches/@angular+ng-dev+0.0.0-a6dcd24107d12114198251ee5d20cda814a1986a.patch",
8686
"//:tools/npm-patches/@bazel+jasmine+5.8.1.patch",
8787
"//tools:postinstall-patches.js",
88-
"//tools/esm-interop:patches/npm/@angular+build-tooling+0.0.0-d30a56c19bafaac67cf44e605ed8c2c0e45b0a51.patch",
88+
"//tools/esm-interop:patches/npm/@angular+build-tooling+0.0.0-2670abf637fa155971cdd1f7e570a7f234922a65.patch",
8989
"//tools/esm-interop:patches/npm/@bazel+concatjs+5.8.1.patch",
9090
"//tools/esm-interop:patches/npm/@bazel+esbuild+5.7.1.patch",
9191
"//tools/esm-interop:patches/npm/@bazel+protractor+5.7.1.patch",

adev/shared-docs/pipeline/api-gen/extraction/BUILD.bazel

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ esbuild_esm_bundle(
1616
target = "es2022",
1717
deps = [
1818
":extract_api_to_json_lib",
19-
"@angular//packages/compiler-cli",
20-
"@npm//typescript",
2119
],
2220
)
2321

@@ -44,17 +42,11 @@ ts_library(
4442
nodejs_binary(
4543
name = "extract_api_to_json",
4644
data = [
47-
":bin",
4845
"@angular//packages/compiler",
49-
"@angular//packages/compiler-cli",
46+
"@angular//packages/compiler-cli:npm_package",
5047
"@npm//typescript",
5148
],
5249
entry_point = "bin.mjs",
53-
# Note: Using the linker here as we need it for ESM. The linker is not
54-
# super reliably when running concurrently on Windows- but we have existing
55-
# actions using the linker. An alternative would be to:
56-
# - bundle the Angular compiler into a CommonJS bundle
57-
# - use the patched resolution- but also patch the ESM imports (similar to how FW does it).
5850
visibility = ["//visibility:public"],
5951
)
6052

devtools/tools/esbuild/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ js_library(
88
name = "esbuild_base",
99
srcs = ["esbuild-base.config.mjs"],
1010
deps = [
11+
"//packages:package_json",
1112
"//packages/compiler-cli/private",
1213
"@npm//@angular/build-tooling/shared-scripts/angular-optimization:js_lib",
1314
],

devtools/tools/esbuild/esbuild-base.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {createEsbuildAngularOptimizePlugin} from '@angular/build-tooling/shared-scripts/angular-optimization/esbuild-plugin.mjs';
10-
import {GLOBAL_DEFS_FOR_TERSER_WITH_AOT} from '@angular/compiler-cli/private/tooling.js';
9+
import {createEsbuildAngularOptimizePlugin} from '@angular/build-tooling/shared-scripts/angular-optimization/esbuild-plugin';
10+
import {GLOBAL_DEFS_FOR_TERSER_WITH_AOT} from '@angular/compiler-cli/private/tooling';
1111

1212
/** Converts an object to a string dictionary. */
1313
function convertObjectToStringDictionary(value) {

integration/ng-modules-importability/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ ts_library(
55
name = "test_lib",
66
testonly = True,
77
srcs = glob(["*.ts"]),
8+
data = [
9+
"//packages:package_json",
10+
],
811
deps = [
912
"//packages/compiler-cli",
1013
"@npm//typescript",

integration/ng-modules-importability/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {performCompilation} from '@angular/compiler-cli';
1+
import {performCompilation} from '../../packages/compiler-cli';
22
import * as fs from 'fs/promises';
33
import * as path from 'path';
44
import * as os from 'os';

packages/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
12
load("@aspect_rules_ts//ts:defs.bzl", rules_js_tsconfig = "ts_config")
23
load("//:packages.bzl", "DOCS_ENTRYPOINTS")
34
load("//adev/shared-docs/pipeline/api-gen/manifest:generate_api_manifest.bzl", "generate_api_manifest")
@@ -10,6 +11,11 @@ exports_files([
1011
"tsconfig.json",
1112
])
1213

14+
copy_to_bin(
15+
name = "package_json",
16+
srcs = ["package.json"],
17+
)
18+
1319
ts_library(
1420
name = "types",
1521
srcs = glob(["*.ts"]),

packages/bazel/src/ngc-wrapped/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ nodejs_binary(
2929
data = [
3030
":ngc_lib",
3131
"//packages/bazel/third_party/github.com/bazelbuild/bazel/src/main/protobuf:worker_protocol.proto",
32+
# Ensure compiler-cli `ts_project` `.js` files are picked up as ESM.
33+
# Notably this is temporary and compiler raw sources are not valid ESM anyway.
34+
# That is because there is no explicit import extensions.
35+
"//packages:package_json",
3236
],
3337
entry_point = ":ngc-wrapped-main.ts",
3438
# Disables the Bazel node modules linker. The node module linker is unreliable for the

packages/compiler-cli/BUILD.bazel

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
load("@npm//@bazel/esbuild:index.bzl", "esbuild", "esbuild_config")
22
load("//packages/bazel/src:ng_perf.bzl", "ng_perf_flag")
3-
load("//tools:defaults.bzl", "api_golden_test", "extract_types", "pkg_npm", "ts_config", "ts_library")
3+
load("//tools:defaults.bzl", "api_golden_test", "extract_types", "pkg_npm", "ts_library")
4+
load("//tools:defaults2.bzl", "ts_config")
45

56
package(default_visibility = ["//visibility:public"])
67

@@ -12,6 +13,25 @@ PUBLIC_TARGETS = [
1213
"//packages/compiler-cli/linker/babel",
1314
]
1415

16+
ts_config(
17+
name = "tsconfig_build",
18+
src = "tsconfig.json",
19+
deps = [
20+
"//:node_modules/@types/node",
21+
"//packages:tsconfig_build",
22+
],
23+
)
24+
25+
ts_config(
26+
name = "tsconfig_test",
27+
testonly = True,
28+
src = "tsconfig-test.json",
29+
deps = [
30+
":tsconfig_build",
31+
"//:node_modules/@types/jasmine",
32+
],
33+
)
34+
1535
esbuild_config(
1636
name = "esbuild_config",
1737
config_file = "esbuild.config.js",
@@ -51,12 +71,6 @@ esbuild(
5171
deps = PUBLIC_TARGETS,
5272
)
5373

54-
ts_config(
55-
name = "tsconfig",
56-
src = "tsconfig-build.json",
57-
deps = ["//packages:tsconfig-build.json"],
58-
)
59-
6074
ts_library(
6175
name = "compiler-cli",
6276
srcs = glob(
@@ -68,7 +82,6 @@ ts_library(
6882
"src/integrationtest/**/*.ts",
6983
],
7084
),
71-
tsconfig = ":tsconfig",
7285
deps = [
7386
"//packages/compiler",
7487
"//packages/compiler-cli/private",
@@ -112,13 +125,17 @@ pkg_npm(
112125
tags = [
113126
"release-with-framework",
114127
],
115-
# Do not add more to this list.
116-
# Dependencies on the full npm_package cause long re-builds.
117128
visibility = [
118129
"//adev:__pkg__",
130+
"//adev/shared-docs/pipeline/api-gen:__subpackages__",
119131
"//integration:__subpackages__",
132+
"//modules/benchmarks:__subpackages__",
133+
"//modules/playground:__subpackages__",
120134
"//modules/ssr-benchmarks:__subpackages__",
121135
"//packages/compiler-cli/integrationtest:__pkg__",
136+
"//packages/core/test/bundling:__subpackages__",
137+
"//packages/core/test/playground/zone-signal-input:__pkg__",
138+
"@npm//@angular/build-tooling/shared-scripts:__subpackages__",
122139
],
123140
deps = [
124141
":api_type_definitions",

packages/compiler-cli/test/compliance/partial/partial_compliance_goldens.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def partial_compliance_golden(filePath):
1111
data = [
1212
"//packages/compiler-cli/test/compliance/partial:generate_golden_partial_lib",
1313
"//packages/core:npm_package",
14+
"//packages:package_json",
1415
filePath,
1516
] + native.glob(["%s/*.ts" % path, "%s/**/*.html" % path, "%s/**/*.css" % path])
1617

0 commit comments

Comments
 (0)