Skip to content

Commit a834c74

Browse files
devversionIgorMinar
authored andcommitted
test: bazel integration test should use angular npm packages (angular#28762)
PR Close angular#28762
1 parent 4131715 commit a834c74

File tree

7 files changed

+129
-36
lines changed

7 files changed

+129
-36
lines changed

integration/bazel/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package(default_visibility = ["//visibility:public"])
22

33
exports_files([
44
"protractor.conf.js",
5+
"angular-metadata.tsconfig.json",
56
])
67

78
# ts_library and ng_module use the `//:tsconfig.json` target

integration/bazel/WORKSPACE

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ node_repositories(
5656
# Install our npm dependencies into @npm
5757
yarn_install(
5858
name = "npm",
59-
# Need a reference to @angular here so that Bazel sets up the
60-
# external repository before calling yarn_install
61-
data = ["@angular//:LICENSE"],
59+
data = [
60+
# Needed because this tsconfig file is used in the "postinstall" script.
61+
"//:angular-metadata.tsconfig.json",
62+
# Need a reference to @angular here so that Bazel sets up the
63+
# external repository before calling yarn_install
64+
"@angular//:LICENSE",
65+
],
6266
package_json = "//src:package.json",
6367
yarn_lock = "//src:yarn.lock",
6468
)
@@ -94,7 +98,10 @@ load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
9498

9599
sass_repositories()
96100

97-
# Setup the angular toolchain
101+
# Setup the angular toolchain. This integration test no longer builds Angular from source,
102+
# but we still need to set up the "angular" workspace since some Bazel rules depend on
103+
# the "ngdeps" repository. This can be fixed if we switched the Angular repository to the
104+
# "npm" repository for the bazel managed dependencies.
98105
load("@angular//:index.bzl", "ng_setup_workspace")
99106

100107
ng_setup_workspace()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Workaround for https://github.com/angular/angular/issues/18810
2+
// This file is required because when using the Angular NPM packages and building
3+
// with AOT compilation, NGC needs the "ngsummary.json" files.
4+
{
5+
"compilerOptions": {
6+
"lib": [
7+
"dom",
8+
"es2015"
9+
],
10+
"experimentalDecorators": true,
11+
"types": []
12+
},
13+
"include": [
14+
"node_modules/@angular/**/*"
15+
],
16+
"exclude": [
17+
"node_modules/@angular/bazel/**",
18+
"node_modules/@angular/compiler-cli/**",
19+
"node_modules/@angular/**/testing/**"
20+
]
21+
}

integration/bazel/src/BUILD.bazel

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ ng_module(
1010
srcs = glob(["*.ts"]),
1111
deps = [
1212
"//src/hello-world",
13-
"@angular//packages/common/http",
14-
"@angular//packages/core",
15-
"@angular//packages/platform-browser",
13+
"@npm//@angular/common",
14+
"@npm//@angular/core",
15+
"@npm//@angular/platform-browser",
1616
"@npm//@types",
1717
],
1818
)
@@ -26,26 +26,37 @@ ts_devserver(
2626
"npm/node_modules/zone.js/dist",
2727
],
2828
entry_module = "bazel_integration_test/src/main",
29+
scripts = [
30+
"@npm//node_modules/@angular/common:bundles/common.umd.js",
31+
"@npm//node_modules/@angular/common:bundles/common-http.umd.js",
32+
"@npm//node_modules/@angular/core:bundles/core.umd.js",
33+
"@npm//node_modules/@angular/platform-browser:bundles/platform-browser.umd.js",
34+
],
2935
serving_path = "/bundle.min.js",
3036
static_files = [
3137
"@npm//node_modules/tslib:tslib.js",
3238
"@npm//node_modules/zone.js:dist/zone.min.js",
3339
"index.html",
3440
],
35-
deps = ["//src"],
41+
deps = [
42+
"//src",
43+
# This will be removed with https://github.com/angular/angular/pull/28720. This is the
44+
# only remaining dependency that we still build from source here.
45+
"@rxjs",
46+
],
3647
)
3748

3849
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "rollup_bundle")
3950

40-
filegroup(
41-
name = "empty_node_modules",
42-
)
43-
4451
rollup_bundle(
4552
name = "bundle",
4653
entry_point = "src/main",
47-
node_modules = ":empty_node_modules",
48-
deps = ["//src"],
54+
deps = [
55+
"//src",
56+
"@npm//@angular/common",
57+
"@npm//@angular/core",
58+
"@npm//@angular/platform-browser",
59+
],
4960
)
5061

5162
# Needed because the prodserver only loads static files that appear under this

integration/bazel/src/hello-world/BUILD.bazel

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ng_module(
1818
),
1919
assets = [":hello-world-styles"],
2020
deps = [
21-
"@angular//packages/core",
21+
"@npm//@angular/core",
2222
"@npm//@types",
2323
],
2424
)
@@ -35,18 +35,28 @@ ts_library(
3535
srcs = glob(["*.spec.ts"]),
3636
deps = [
3737
":hello-world",
38-
"@angular//packages/core",
39-
"@angular//packages/core/testing",
40-
"@angular//packages/platform-browser",
41-
"@angular//packages/platform-browser-dynamic/testing",
38+
"@npm//@angular/core",
39+
"@npm//@angular/platform-browser",
40+
"@npm//@angular/platform-browser-dynamic",
4241
"@npm//@types",
4342
"@npm//jasmine",
4443
],
4544
)
4645

4746
ts_web_test_suite(
4847
name = "test",
49-
srcs = ["@npm//node_modules/tslib:tslib.js"],
48+
srcs = [
49+
"@npm//node_modules/@angular/common:bundles/common.umd.js",
50+
"@npm//node_modules/@angular/compiler:bundles/compiler.umd.js",
51+
"@npm//node_modules/@angular/compiler:bundles/compiler-testing.umd.js",
52+
"@npm//node_modules/@angular/core:bundles/core.umd.js",
53+
"@npm//node_modules/@angular/core:bundles/core-testing.umd.js",
54+
"@npm//node_modules/@angular/platform-browser:bundles/platform-browser.umd.js",
55+
"@npm//node_modules/@angular/platform-browser:bundles/platform-browser-testing.umd.js",
56+
"@npm//node_modules/@angular/platform-browser-dynamic:bundles/platform-browser-dynamic.umd.js",
57+
"@npm//node_modules/@angular/platform-browser-dynamic:bundles/platform-browser-dynamic-testing.umd.js",
58+
"@npm//node_modules/tslib:tslib.js",
59+
],
5060
bootstrap = [
5161
"@npm//node_modules/zone.js:dist/zone-testing-bundle.js",
5262
"@npm//node_modules/reflect-metadata:Reflect.js",
@@ -59,5 +69,8 @@ ts_web_test_suite(
5969
],
6070
deps = [
6171
":test_lib",
72+
# This will be removed with https://github.com/angular/angular/pull/28720. This is the
73+
# only remaining dependency that we still build from source here.
74+
"@rxjs",
6275
],
6376
)

integration/bazel/src/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"version": "0.0.0",
55
"license": "MIT",
66
"dependencies": {
7+
"@angular/animations": "file:../angular/dist/packages-dist/animations",
8+
"@angular/common": "file:../angular/dist/packages-dist/common",
9+
"@angular/core": "file:../angular/dist/packages-dist/core",
10+
"@angular/platform-browser": "file:../angular/dist/packages-dist/platform-browser",
11+
"@angular/platform-browser-dynamic": "file:../angular/dist/packages-dist/platform-browser-dynamic",
712
"reflect-metadata": "0.1.12",
813
"rxjs": "6.3.3",
914
"tslib": "1.9.3",
@@ -21,6 +26,7 @@
2126
"typescript": "3.1.1"
2227
},
2328
"scripts": {
29+
"postinstall": "ngc -p ./angular-metadata.tsconfig.json",
2430
"//": "TODO(gregmagolan): figure out how to keep dependencies here up to date with the root package.json"
2531
}
26-
}
32+
}

integration/bazel/src/yarn.lock

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
rxjs "6.3.3"
3333
source-map "0.7.3"
3434

35-
"@angular-devkit/core@7.3.0":
36-
version "7.3.0"
37-
resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-7.3.0.tgz#fc272e39b4c307833e9a7db77007418a246f5410"
38-
integrity sha512-b0qtAUpgqLpWY8W6vWRv1aj6bXkZCP1rvywl8i8TbGMY67CWRcy5J3fNAMmjiZS+LJixFlIXYf4iOydglyJMfg==
35+
"@angular-devkit/core@7.3.1":
36+
version "7.3.1"
37+
resolved "https://registry.yarnpkg.com/@angular-devkit/core/-/core-7.3.1.tgz#d92f6545796579cabdcfc29579a2c977f7a96c6c"
38+
integrity sha512-56XDWWfIzOAkEk69lBLgmCYybPUA4yjunhmMlCk7vVdb7gbQUyzNjFD04Uj0GjlejatAQ5F76tRwygD9C+3RXQ==
3939
dependencies:
4040
ajv "6.7.0"
4141
chokidar "2.0.4"
@@ -51,29 +51,39 @@
5151
"@angular-devkit/core" "7.1.2"
5252
rxjs "6.3.3"
5353

54-
"@angular-devkit/schematics@^7.3.0-rc.0":
55-
version "7.3.0"
56-
resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-7.3.0.tgz#112c1f59ff2778157aff6fb7484a6c132d4156ac"
57-
integrity sha512-glOduymftH0LmJhITWgWUJK8QCDUltgTZ943/OyArIvLXTLL/8zCb+G6xL+3k33EQjwJicgQ3WIjonJmeTK/Ww==
54+
"@angular-devkit/schematics@^7.0.4":
55+
version "7.3.1"
56+
resolved "https://registry.yarnpkg.com/@angular-devkit/schematics/-/schematics-7.3.1.tgz#7dc704005b966ea6c1ee62f380120183bb76eee6"
57+
integrity sha512-cd7usiasfSgw75INz72/VssrLr9tiVRYfo1TEdvr9ww0GuQbuQpB33xbV8W135eAV8+wzQ3Ce8ohaDHibvj6Yg==
5858
dependencies:
59-
"@angular-devkit/core" "7.3.0"
59+
"@angular-devkit/core" "7.3.1"
6060
rxjs "6.3.3"
6161

62+
"@angular/animations@file:../angular/dist/packages-dist/animations":
63+
version "0.0.0"
64+
dependencies:
65+
tslib "^1.9.0"
66+
6267
"@angular/bazel@file:../angular/dist/packages-dist/bazel":
63-
version "8.0.0-beta.2"
68+
version "0.0.0"
6469
dependencies:
6570
"@angular-devkit/architect" "^0.10.6"
6671
"@angular-devkit/core" "^7.0.4"
67-
"@angular-devkit/schematics" "^7.3.0-rc.0"
68-
"@bazel/typescript" "^0.23.2"
72+
"@angular-devkit/schematics" "^7.0.4"
73+
"@bazel/typescript" "^0.21.0"
6974
"@schematics/angular" "^7.0.4"
7075
"@types/node" "6.0.84"
7176
semver "^5.6.0"
7277
shelljs "0.8.2"
7378
tsickle "0.34.0"
7479

80+
"@angular/common@file:../angular/dist/packages-dist/common":
81+
version "0.0.0"
82+
dependencies:
83+
tslib "^1.9.0"
84+
7585
"@angular/compiler-cli@file:../angular/dist/packages-dist/compiler-cli":
76-
version "8.0.0-beta.2"
86+
version "0.0.0"
7787
dependencies:
7888
canonical-path "1.0.0"
7989
chokidar "^1.4.2"
@@ -88,7 +98,22 @@
8898
yargs "9.0.1"
8999

90100
"@angular/compiler@file:../angular/dist/packages-dist/compiler":
91-
version "8.0.0-beta.2"
101+
version "0.0.0"
102+
dependencies:
103+
tslib "^1.9.0"
104+
105+
"@angular/core@file:../angular/dist/packages-dist/core":
106+
version "0.0.0"
107+
dependencies:
108+
tslib "^1.9.0"
109+
110+
"@angular/platform-browser-dynamic@file:../angular/dist/packages-dist/platform-browser-dynamic":
111+
version "0.0.0"
112+
dependencies:
113+
tslib "^1.9.0"
114+
115+
"@angular/platform-browser@file:../angular/dist/packages-dist/platform-browser":
116+
version "0.0.0"
92117
dependencies:
93118
tslib "^1.9.0"
94119

@@ -109,7 +134,7 @@
109134
semver "5.6.0"
110135
tmp "0.0.33"
111136

112-
"@bazel/typescript@0.23.2", "@bazel/typescript@^0.23.2":
137+
"@bazel/typescript@0.23.2":
113138
version "0.23.2"
114139
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.23.2.tgz#a3ff199880855259d84216cb41644c1d9a0fad14"
115140
integrity sha512-GrTyDW6Fvp/rgnxZGYampB5/QmDWvxtLEtUyMCPa/QXFR1OVxaMWeHxxuFEcES2UKJegqBDKAA8IzX21x4UbEw==
@@ -120,6 +145,15 @@
120145
source-map-support "0.5.9"
121146
tsutils "2.27.2"
122147

148+
"@bazel/typescript@^0.21.0":
149+
version "0.21.0"
150+
resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.21.0.tgz#41c304f77a42c6a016280d0f4c20e0749c3f4b2a"
151+
integrity sha512-ASXj0RFybmqoa3LwqkTU3gNkX9bY9wL/VDNo5hlp9pynYWl4RMpe9V3m/qDIdtSuLJ+qD+Z3FKT/OcpWQHMlYA==
152+
dependencies:
153+
protobufjs "5.0.3"
154+
source-map-support "0.5.9"
155+
tsutils "2.27.2"
156+
123157
"@schematics/angular@^7.0.4":
124158
version "7.1.2"
125159
resolved "https://registry.yarnpkg.com/@schematics/angular/-/angular-7.1.2.tgz#b3eefbc81d12b0b53816896f6172eb613885826c"

0 commit comments

Comments
 (0)