Skip to content

Commit 59d3840

Browse files
crisbetojelbourn
andauthored
build: fix errors against latest @angular/bazel version (#20779)
* build: fix errors against latest @angular/bazel version Fixes some errors that were introduced in the latest `@angular/bazel` version. * test: unlink tscompat symlinks before deleting With Angular 11.0.0-next.6, trying to `rm` the symlink here without unlinking it fails for ViewEngine. Co-authored-by: Jeremy Elbourn <[email protected]>
1 parent 0909bc9 commit 59d3840

File tree

11 files changed

+333
-267
lines changed

11 files changed

+333
-267
lines changed

WORKSPACE

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
88
# Add NodeJS rules
99
http_archive(
1010
name = "build_bazel_rules_nodejs",
11-
sha256 = "84abf7ac4234a70924628baa9a73a5a5cbad944c4358cf9abdb4aab29c9a5b77",
12-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.7.0/rules_nodejs-1.7.0.tar.gz"],
11+
sha256 = "4952ef879704ab4ad6729a29007e7094aef213ea79e9f2e94cbe1c9a753e63ef",
12+
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/2.2.0/rules_nodejs-2.2.0.tar.gz"],
1313
)
1414

1515
# Add sass rules
@@ -67,15 +67,14 @@ yarn_install(
6767
# Install all bazel dependencies of the @ngdeps npm packages
6868
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
6969

70-
install_bazel_dependencies()
71-
72-
# Setup TypeScript Bazel workspace
73-
load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")
74-
75-
ts_setup_workspace()
70+
install_bazel_dependencies(
71+
# TODO(crisbeto): supress warnings for now so everything works like it has until now.
72+
# Eventually we should remove it and re-test everything.
73+
suppress_warning = True,
74+
)
7675

7776
# Fetch transitive dependencies which are needed to use the karma rules.
78-
load("@npm_bazel_karma//:package.bzl", "npm_bazel_karma_dependencies")
77+
load("@npm//@bazel/karma:package.bzl", "npm_bazel_karma_dependencies")
7978

8079
npm_bazel_karma_dependencies()
8180

integration/size-test/index.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test")
22
load("@bazel_skylib//lib:paths.bzl", "paths")
3-
load("@npm_bazel_rollup//:index.bzl", "rollup_bundle")
4-
load("@npm_bazel_terser//:index.bzl", "terser_minified")
3+
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
4+
load("@npm//@bazel/terser:index.bzl", "terser_minified")
55
load("//tools:defaults.bzl", "ng_module")
66
load("//tools:expand_template.bzl", "expand_template")
77

integration/ts-compat/helpers.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const {relative, sep, join} = require('path');
2-
const {readdirSync, readFileSync, existsSync} = require('fs');
2+
const {readdirSync, readFileSync, existsSync, unlinkSync} = require('fs');
33
const {set, ln, rm, mkdir} = require('shelljs');
44
const {fork} = require('child_process');
55
const runfiles = require(process.env.BAZEL_NODE_RUNFILES_HELPER);
@@ -30,7 +30,7 @@ exports.runTypeScriptCompatibilityTest = async (tscBinPath) => {
3030
// be compiled without path mappings (simulating a real project).
3131
for (const {name, pkgPath} of npmPackages) {
3232
console.info(`Linking "@angular/${name}" into node modules..`);
33-
ln('-s', pkgPath, join(angularDir, name));
33+
ln('-sf', pkgPath, join(angularDir, name));
3434
}
3535

3636
const tscArgs = [
@@ -49,7 +49,8 @@ exports.runTypeScriptCompatibilityTest = async (tscBinPath) => {
4949
// Remove symlinks to keep a clean repository state.
5050
for (const {name} of npmPackages) {
5151
console.info(`Removing link for "@angular/${name}"..`);
52-
rm(join(angularDir, name));
52+
unlinkSync(join(angularDir, name));
53+
rm('-rf', join(angularDir, name));
5354
}
5455
exitCode === 0 ? resolve() : reject();
5556
});

package.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
},
5151
"version": "11.0.0-next.1",
5252
"dependencies": {
53-
"@angular/animations": "^11.0.0-next.5",
54-
"@angular/common": "^11.0.0-next.5",
55-
"@angular/compiler": "^11.0.0-next.5",
56-
"@angular/core": "^11.0.0-next.5",
57-
"@angular/elements": "^11.0.0-next.5",
58-
"@angular/forms": "^11.0.0-next.5",
59-
"@angular/platform-browser": "^11.0.0-next.5",
53+
"@angular/animations": "^11.0.0-next.6",
54+
"@angular/common": "^11.0.0-next.6",
55+
"@angular/compiler": "^11.0.0-next.6",
56+
"@angular/core": "^11.0.0-next.6",
57+
"@angular/elements": "^11.0.0-next.6",
58+
"@angular/forms": "^11.0.0-next.6",
59+
"@angular/platform-browser": "^11.0.0-next.6",
6060
"@types/googlemaps": "^3.39.3",
6161
"@types/youtube": "^0.0.38",
6262
"@webcomponents/custom-elements": "^1.1.0",
@@ -69,28 +69,28 @@
6969
"zone.js": "~0.10.3"
7070
},
7171
"devDependencies": {
72-
"@angular-devkit/build-optimizer": "^0.1100.0-next.5",
73-
"@angular-devkit/core": "^11.0.0-next.5",
74-
"@angular-devkit/schematics": "^11.0.0-next.5",
75-
"@angular/bazel": "^11.0.0-next.5",
72+
"@angular-devkit/build-optimizer": "^0.1100.0-next.6",
73+
"@angular-devkit/core": "^11.0.0-next.6",
74+
"@angular-devkit/schematics": "^11.0.0-next.6",
75+
"@angular/bazel": "^11.0.0-next.6",
7676
"@angular/benchpress": "0.2.1",
77-
"@angular/compiler-cli": "^11.0.0-next.5",
77+
"@angular/compiler-cli": "^11.0.0-next.6",
7878
"@angular/dev-infra-private": "https://github.com/angular/dev-infra-private-builds.git#f8bc880d554d45ca8bf881b8a776f00f61b918fb",
79-
"@angular/platform-browser-dynamic": "^11.0.0-next.5",
80-
"@angular/platform-server": "^11.0.0-next.5",
81-
"@angular/router": "^11.0.0-next.5",
79+
"@angular/platform-browser-dynamic": "^11.0.0-next.6",
80+
"@angular/platform-server": "^11.0.0-next.6",
81+
"@angular/router": "^11.0.0-next.6",
8282
"@bazel/bazelisk": "^1.4.0",
8383
"@bazel/buildifier": "^2.2.1",
8484
"@bazel/ibazel": "^0.13.0",
85-
"@bazel/jasmine": "^1.7.0",
86-
"@bazel/karma": "^1.7.0",
87-
"@bazel/protractor": "^1.7.0",
88-
"@bazel/rollup": "^1.7.0",
89-
"@bazel/terser": "^1.7.0",
90-
"@bazel/typescript": "^1.7.0",
85+
"@bazel/jasmine": "^2.2.0",
86+
"@bazel/karma": "^2.2.0",
87+
"@bazel/protractor": "^2.2.0",
88+
"@bazel/rollup": "^2.2.0",
89+
"@bazel/terser": "^2.2.0",
90+
"@bazel/typescript": "^2.2.0",
9191
"@firebase/app-types": "^0.3.2",
9292
"@octokit/rest": "16.28.7",
93-
"@schematics/angular": "^11.0.0-next.5",
93+
"@schematics/angular": "^11.0.0-next.6",
9494
"@types/autoprefixer": "^9.7.2",
9595
"@types/browser-sync": "^2.26.1",
9696
"@types/fs-extra": "^4.0.3",
@@ -128,6 +128,7 @@
128128
"highlight.js": "^9.11.0",
129129
"husky": "^4.3.0",
130130
"inquirer": "^7.1.0",
131+
"jasmine": "^3.5.0",
131132
"jasmine-core": "^3.5.0",
132133
"kagekiri": "^1.0.18",
133134
"karma": "^4.4.1",

src/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@npm_bazel_typescript//:index.bzl", "ts_config")
1+
load("@npm//@bazel/typescript:index.bzl", "ts_config")
22
load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS")
33
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS")
44
load("//tools/dgeni:index.bzl", "dgeni_api_docs")

src/cdk/schematics/testing/resolve-bazel-path.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ export function resolveBazelPath(parent: string, relativePath: string) {
3333
for (const projectDir of projectDirs) {
3434
const relativeParent = path.relative(projectDir, parent);
3535
const workspacePath = path.join(relativeParent, relativePath).replace(/\\/g, '/');
36-
const result = runfiles.resolveWorkspaceRelative(workspacePath);
37-
if (result) {
38-
return result;
39-
}
36+
37+
try {
38+
// In newer versions `resolveWorkspaceRelative` throws an error if it doesn't succeed.
39+
const result = runfiles.resolveWorkspaceRelative(workspacePath);
40+
41+
if (result) {
42+
return result;
43+
}
44+
} catch {}
4045
}
4146

4247
throw Error(`Could not resolve path. Looked in: ${projectDirs.join(', ')}`);

src/components-examples/material/datepicker/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@npm_bazel_typescript//:index.bzl", "ts_config")
1+
load("@npm//@bazel/typescript:index.bzl", "ts_config")
22
load("//tools:defaults.bzl", "ng_module")
33

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

src/e2e-app/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@npm_bazel_typescript//:index.bzl", "ts_devserver")
1+
load("@npm//@bazel/typescript:index.bzl", "ts_devserver")
22
load("//:packages.bzl", "getAngularUmdTargets")
33
load("//tools:defaults.bzl", "ng_module", "sass_binary")
44

src/material-moment-adapter/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@npm_bazel_typescript//:index.bzl", "ts_config")
1+
load("@npm//@bazel/typescript:index.bzl", "ts_config")
22
load("//tools:defaults.bzl", "ng_module", "ng_package", "ng_test_library", "ng_web_test_suite")
33

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

tools/defaults.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Re-export of Bazel rules with repository-wide defaults
22

33
load("@io_bazel_rules_sass//:defs.bzl", _sass_binary = "sass_binary", _sass_library = "sass_library")
4-
load("@npm_angular_bazel//:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
5-
load("@npm_bazel_jasmine//:index.bzl", _jasmine_node_test = "jasmine_node_test")
6-
load("@npm_bazel_karma//:index.bzl", _karma_web_test = "karma_web_test", _karma_web_test_suite = "karma_web_test_suite")
7-
load("@npm_bazel_protractor//:index.bzl", _protractor_web_test_suite = "protractor_web_test_suite")
8-
load("@npm_bazel_typescript//:index.bzl", _ts_library = "ts_library")
4+
load("@npm//@angular/bazel:index.bzl", _ng_module = "ng_module", _ng_package = "ng_package")
5+
load("@npm//@bazel/jasmine:index.bzl", _jasmine_node_test = "jasmine_node_test")
6+
load("@npm//@bazel/karma:index.bzl", _karma_web_test = "karma_web_test", _karma_web_test_suite = "karma_web_test_suite")
7+
load("@npm//@bazel/protractor:index.bzl", _protractor_web_test_suite = "protractor_web_test_suite")
8+
load("@npm//@bazel/typescript:index.bzl", _ts_library = "ts_library")
99
load("//:packages.bzl", "VERSION_PLACEHOLDER_REPLACEMENTS", "getAngularUmdTargets")
1010
load("//:rollup-globals.bzl", "ROLLUP_GLOBALS")
1111
load("//tools/markdown-to-html:index.bzl", _markdown_to_html = "markdown_to_html")

0 commit comments

Comments
 (0)