Skip to content

Commit 3804801

Browse files
authored
build: update bazel setup to latest dev-infra and rules_nodejs version (#23990)
Updates the Bazel setup to the latest dev-infra and rules_nodejs version. This includes: * The removal of the spec-bundling code as that has been moved over to the shared dev-infra code. * The remoal of the AMD esbuild and devmode JS source extraction as these rules have been moved to the shared dev-infra logic. * The removal of the Angular linker ESBuild plugin creation as this logic is now exposed as shared script in the shared dev-infra package.
1 parent c49b0e7 commit 3804801

22 files changed

+258
-553
lines changed

.github/workflows/dev-infra.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: angular/dev-infra/github-actions/commit-message-based-labels@589f402fa601c4c8ab006bdfb337564b3ea32338
12+
- uses: angular/dev-infra/github-actions/commit-message-based-labels@f0f363cb4ce5b5faf14e3d3bb7eeb7c7aee72da7
1313
with:
1414
angular-robot-key: ${{ secrets.ANGULAR_ROBOT_PRIVATE_KEY }}

.github/workflows/lock-closed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
lock_closed:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: angular/dev-infra/github-actions/lock-closed@3f4646c252bc54b2ae93b4e322ebde9030de30b2
12+
- uses: angular/dev-infra/github-actions/lock-closed@f0f363cb4ce5b5faf14e3d3bb7eeb7c7aee72da7
1313
with:
1414
lock-bot-key: ${{ secrets.LOCK_BOT_PRIVATE_KEY }}

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
99
http_archive(
1010
name = "build_bazel_rules_nodejs",
1111
patches = ["//tools:multiple-node-versions.patch"],
12-
sha256 = "3635797a96c7bfcd0d265dacd722a07335e64d6ded9834af8d3f1b7ba5a25bba",
13-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.3.0/rules_nodejs-4.3.0.tar.gz"],
12+
sha256 = "f7037c8e295fdc921f714962aee7c496110052511e2b14076bd8e2d46bc9819c",
13+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.4.5/rules_nodejs-4.4.5.tar.gz"],
1414
)
1515

1616
# Add sass rules

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,24 @@
7272
"@angular/bazel": "13.0.1",
7373
"@angular/cli": "13.0.2",
7474
"@angular/compiler-cli": "13.0.1",
75-
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#2cfe4b98a157927b319a3a00b467ff6233dc3337",
75+
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#c55a3937d45945489714273bfbbe9b803ceff89e",
7676
"@angular/localize": "13.0.1",
7777
"@angular/platform-browser-dynamic": "13.0.1",
7878
"@angular/platform-server": "13.0.1",
7979
"@angular/router": "13.0.1",
8080
"@axe-core/webdriverjs": "^4.1.0",
8181
"@babel/core": "^7.16.0",
8282
"@bazel/bazelisk": "1.10.1",
83-
"@bazel/buildifier": "4.2.1",
84-
"@bazel/concatjs": "4.3.0",
85-
"@bazel/esbuild": "4.3.0",
83+
"@bazel/buildifier": "4.2.3",
84+
"@bazel/concatjs": "4.4.5",
85+
"@bazel/esbuild": "4.4.5",
8686
"@bazel/ibazel": "0.15.10",
87-
"@bazel/jasmine": "4.2.0",
88-
"@bazel/protractor": "4.3.0",
89-
"@bazel/rollup": "4.3.0",
90-
"@bazel/runfiles": "4.3.0",
91-
"@bazel/terser": "4.3.0",
92-
"@bazel/typescript": "4.3.0",
87+
"@bazel/jasmine": "4.4.5",
88+
"@bazel/protractor": "4.4.5",
89+
"@bazel/rollup": "4.4.5",
90+
"@bazel/runfiles": "4.4.5",
91+
"@bazel/terser": "4.4.5",
92+
"@bazel/typescript": "4.4.5",
9393
"@firebase/app-types": "^0.6.1",
9494
"@material/animation": "14.0.0-canary.1af7c1c4a.0",
9595
"@material/auto-init": "14.0.0-canary.1af7c1c4a.0",

scripts/create-legacy-tests-bundle.mjs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env node
22

3-
import {ConsoleLogger, LogLevel, NodeJSFileSystem} from '@angular/compiler-cli';
4-
import {createEs2015LinkerPlugin} from '@angular/compiler-cli/linker/babel';
5-
import {transformAsync} from '@babel/core';
3+
import {createLinkerEsbuildPlugin} from '@angular/dev-infra-private/shared-scripts/angular-linker/esbuild-plugin.mjs';
64
import child_process from 'child_process';
75
import esbuild from 'esbuild';
86
import fs from 'fs';
@@ -37,7 +35,7 @@ async function main() {
3735
await compileProjectWithNgtsc();
3836

3937
const specEntryPointFile = await createEntryPointSpecFile();
40-
const esbuildLinkerPlugin = await createLinkerEsbuildPlugin();
38+
const esbuildLinkerPlugin = await createLinkerEsbuildPlugin(/fesm2020/, false);
4139
const esbuildResolvePlugin = await createResolveEsbuildPlugin();
4240

4341
const result = await esbuild.build({
@@ -175,33 +173,6 @@ async function createResolveEsbuildPlugin() {
175173
};
176174
}
177175

178-
/** Creates an ESBuild plugin that runs the Angular linker on framework packages. */
179-
async function createLinkerEsbuildPlugin() {
180-
const linkerBabelPlugin = createEs2015LinkerPlugin({
181-
fileSystem: new NodeJSFileSystem(),
182-
logger: new ConsoleLogger(LogLevel.warn),
183-
// We enable JIT mode as unit tests also will rely on the linked ESM files.
184-
linkerJitMode: true,
185-
});
186-
187-
return {
188-
name: 'ng-linker-esbuild',
189-
setup: build => {
190-
build.onLoad({filter: /fesm2020/}, async args => {
191-
const filePath = args.path;
192-
const content = await fs.promises.readFile(filePath, 'utf8');
193-
const {code} = await transformAsync(content, {
194-
filename: filePath,
195-
filenameRelative: filePath,
196-
plugins: [linkerBabelPlugin],
197-
sourceMaps: 'inline',
198-
});
199-
return {contents: code};
200-
});
201-
},
202-
};
203-
}
204-
205176
/**
206177
* Retrieves the `fs.Stats` results for the given path gracefully.
207178
* If the file does not exist, returns `null`.

src/cdk/testing/tests/webdriver-test.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
load("//tools:defaults.bzl", "jasmine_node_test")
1+
load("//tools:defaults.bzl", "jasmine_node_test", "spec_bundle")
22
load("@io_bazel_rules_webtesting//web:web.bzl", "web_test")
33
load("//tools/server-test:index.bzl", "server_test")
4-
load("//tools/spec-bundling:index.bzl", "spec_bundle")
54

65
def webdriver_test(name, deps, tags = [], **kwargs):
76
spec_bundle(

src/dev-app/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web")
2-
load("//tools:defaults.bzl", "ng_module", "sass_binary")
2+
load("//tools:defaults.bzl", "devmode_esbuild", "esbuild_config", "ng_module", "sass_binary")
33
load("//tools/dev-server:index.bzl", "dev_server")
4-
load("//tools/esbuild:index.bzl", "esbuild", "esbuild_config")
54
load("//src/components-examples:config.bzl", "ALL_EXAMPLES")
65
load("//tools/angular:index.bzl", "LINKER_PROCESSED_FW_PACKAGES")
76

@@ -111,7 +110,7 @@ esbuild_config(
111110
config_file = "esbuild.config.mjs",
112111
)
113112

114-
esbuild(
113+
devmode_esbuild(
115114
name = "bundles",
116115
config = ":esbuild_config",
117116
entry_points = [":main.ts"] + ["%s:index.ts" % e for e in ALL_EXAMPLES],

src/e2e-app/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
load("//tools/dev-server:index.bzl", "dev_server")
2-
load("//tools:defaults.bzl", "ng_module", "sass_binary")
3-
load("//tools/esbuild:index.bzl", "esbuild", "esbuild_config")
2+
load("//tools:defaults.bzl", "devmode_esbuild", "esbuild_config", "ng_module", "sass_binary")
43
load("//src/components-examples:config.bzl", "ALL_EXAMPLES")
54
load("//tools/angular:index.bzl", "LINKER_PROCESSED_FW_PACKAGES")
65

@@ -103,7 +102,7 @@ esbuild_config(
103102
config_file = "esbuild.config.mjs",
104103
)
105104

106-
esbuild(
105+
devmode_esbuild(
107106
name = "bundles",
108107
testonly = True,
109108
config = ":esbuild_config",

src/universal-app/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ load("//src/cdk:config.bzl", "CDK_TARGETS")
33
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_TARGETS")
44
load("//src/material:config.bzl", "MATERIAL_TARGETS")
55
load("//src/material-experimental:config.bzl", "MATERIAL_EXPERIMENTAL_TARGETS")
6-
load("//tools:defaults.bzl", "ng_module", "sass_binary", "ts_library")
7-
load("//tools/esbuild:index.bzl", "esbuild")
6+
load("//tools:defaults.bzl", "devmode_esbuild", "ng_module", "sass_binary", "ts_library")
87
load("//tools/angular:index.bzl", "LINKER_PROCESSED_FW_PACKAGES")
98

109
package(default_visibility = ["//visibility:public"])
@@ -56,7 +55,7 @@ sass_binary(
5655
],
5756
)
5857

59-
esbuild(
58+
devmode_esbuild(
6059
name = "server_bundle",
6160
entry_point = ":prerender.ts",
6261
platform = "node",

tools/angular/BUILD.bazel

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
2-
load("//tools/esbuild:index.bzl", "esbuild_config")
1+
load("@npm//@angular/dev-infra-private/bazel/esbuild:index.bzl", "esbuild_config")
32
load(":index.bzl", "create_angular_bundle_targets")
43

54
package(default_visibility = ["//visibility:public"])
65

7-
js_library(
8-
name = "create_linker_esbuild_plugin",
9-
srcs = ["create_linker_esbuild_plugin.mjs"],
10-
deps = [
11-
"@npm//@angular/compiler-cli",
12-
"@npm//@babel/core",
13-
],
14-
)
15-
166
esbuild_config(
177
name = "esbuild_config",
188
config_file = "esbuild.config.mjs",
199
deps = [
20-
":create_linker_esbuild_plugin",
10+
"@npm//@angular/dev-infra-private/shared-scripts/angular-linker:js_lib",
2111
],
2212
)
2313

0 commit comments

Comments
 (0)