Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 86e795e

Browse files
committed
Build angular from source
1 parent 8a734f1 commit 86e795e

File tree

10 files changed

+74
-281
lines changed

10 files changed

+74
-281
lines changed

BUILD.bazel

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,24 @@ exports_files([
1818
# NOTE: this will move to node_modules/BUILD in a later release
1919
filegroup(
2020
name = "node_modules",
21-
# NB: rxjs is not in this list, because we build it from sources using the
22-
# label @rxjs//:rxjs
21+
# NB: angular & rxjs are not in this list, because we build them from sources
2322
srcs = glob(["/".join([
2423
"node_modules",
2524
pkg,
2625
"**",
2726
ext,
2827
]) for pkg in [
29-
"@angular",
3028
"@ngrx",
3129
"@types",
3230
"protractor",
3331
"tsickle",
32+
"tslib",
3433
"tsutils",
3534
"typescript",
35+
"zone.js",
3636
] for ext in [
3737
"*.js",
3838
"*.json",
3939
"*.d.ts",
4040
]]),
4141
)
42-
43-
ANGULAR_TESTING = [
44-
"node_modules/@angular/*/bundles/*-testing.umd.js",
45-
# We use AOT, so the compiler and the dynamic platform-browser should be
46-
# visible only in tests
47-
"node_modules/@angular/compiler/bundles/*.umd.js",
48-
"node_modules/@angular/platform-browser-dynamic/bundles/*.umd.js",
49-
]
50-
51-
filegroup(
52-
name = "angular_bundles",
53-
srcs = glob(
54-
["node_modules/@angular/*/bundles/*.umd.js"],
55-
exclude = ANGULAR_TESTING,
56-
),
57-
)
58-
59-
filegroup(
60-
name = "angular_test_bundles",
61-
testonly = 1,
62-
srcs = glob(ANGULAR_TESTING),
63-
)

WORKSPACE

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ workspace(name = "angular_bazel_example")
1414
# Allows Bazel to run tooling in Node.js
1515
http_archive(
1616
name = "build_bazel_rules_nodejs",
17-
urls = ["https://github.com/bazelbuild/rules_nodejs/archive/0.10.0.zip"],
18-
strip_prefix = "rules_nodejs-0.10.0",
19-
sha256 = "2f77623311da8b5009b1c7eade12de8e15fa3cd2adf9dfcc9f87cb2082b2211f",
17+
url = "https://github.com/gregmagolan/rules_nodejs/archive/08740c1e4b551377c7ca025428e0b81a28e7f3df.zip",
18+
strip_prefix = "rules_nodejs-08740c1e4b551377c7ca025428e0b81a28e7f3df",
19+
sha256 = "81cc5e0fb0aaf089308a7847cdb86fd8c3048c0a8e4d49c6ffa7710c36faf134",
2020
)
2121

2222
# The Bazel buildtools repo contains tools like the BUILD file formatter, buildifier
@@ -35,9 +35,9 @@ http_archive(
3535
# Runs the TypeScript compiler
3636
http_archive(
3737
name = "build_bazel_rules_typescript",
38-
url = "https://github.com/bazelbuild/rules_typescript/archive/0.15.0.zip",
39-
strip_prefix = "rules_typescript-0.15.0",
40-
sha256 = "1aa75917330b820cb239b3c10a936a10f0a46fe215063d4492dd76dc6e1616f4",
38+
url = "https://github.com/gregmagolan/rules_typescript/archive/38bc5c1d806ce559ee683c69cf1869de659cab8c.zip",
39+
strip_prefix = "rules_typescript-38bc5c1d806ce559ee683c69cf1869de659cab8c",
40+
sha256 = "d4bd763afc1c3a802f314cbda6f18cfd16a9831f9f83aa5ff11addb790ebf44c",
4141
)
4242

4343
# Used by the ts_web_test_suite rule to provision browsers
@@ -63,15 +63,17 @@ http_archive(
6363
sha256 = "f70c35a8c779bb92f7521ecb5a1c6604e9c3edd431e50b6376d7497abc8ad3c1",
6464
)
6565

66-
####################################
67-
# Tell Bazel about some workspaces that were installed from npm.
68-
6966
# The @angular repo contains rule for building Angular applications
70-
local_repository(
67+
http_archive(
7168
name = "angular",
72-
path = "node_modules/@angular/bazel",
69+
url = "https://github.com/gregmagolan/angular/archive/9b24d965bee572ce171fc2882ec93b2557d6e9e1.zip",
70+
strip_prefix = "angular-9b24d965bee572ce171fc2882ec93b2557d6e9e1",
71+
sha256 = "1585317cf52a953e51cdfcdf896ee8337bbcceb23bc847aea9782e9431ae802b",
7372
)
7473

74+
####################################
75+
# Tell Bazel about some workspaces that were installed from npm.
76+
7577
# The @rxjs repo contains targets for building rxjs with bazel
7678
local_repository(
7779
name = "rxjs",
@@ -106,6 +108,14 @@ load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")
106108

107109
sass_repositories()
108110

111+
#
112+
# Load and install our dependencies from local repositories
113+
#
114+
115+
load("@angular//:index.bzl", "ng_setup_workspace")
116+
117+
ng_setup_workspace()
118+
109119
####################################
110120
# Setup our local toolchain
111121

package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,19 @@
44
"description": "Demo of bazel rules for angular",
55
"license": "Apache 2.0",
66
"dependencies": {
7-
"@angular/animations": "6.0.4",
8-
"@angular/common": "6.0.4",
9-
"@angular/core": "6.0.4",
10-
"@angular/forms": "6.0.4",
11-
"@angular/platform-browser": "6.0.4",
12-
"@angular/router": "6.0.4",
13-
"@angular/upgrade": "6.0.4",
147
"@ngrx/store": "6.0.1",
158
"rxjs": "6.2.1",
9+
"tslib": "1.9.2",
1610
"zone.js": "0.8.26"
1711
},
1812
"devDependencies": {
19-
"@angular/bazel": "6.0.4",
20-
"@angular/compiler": "6.0.4",
21-
"@angular/compiler-cli": "6.0.4",
22-
"@angular/platform-browser-dynamic": "6.0.4",
13+
"@angular/compiler": "6.0.6",
14+
"@angular/compiler-cli": "6.0.6",
15+
"@angular/core": "6.0.6",
2316
"@bazel/benchmark-runner": "0.1.0",
2417
"@bazel/ibazel": "0.4.0",
2518
"@types/jasmine": "2.8.8",
19+
"@types/node": "6.0.88",
2620
"clang-format": "1.2.3",
2721
"concurrently": "3.5.1",
2822
"husky": "0.14.3",

postinstall.tsconfig.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@
1111
"types": []
1212
},
1313
"include": [
14-
"node_modules/@angular/**/*",
1514
"node_modules/@ngrx/**/*"
1615
],
1716
"exclude": [
18-
"node_modules/@angular/bazel/**",
19-
"node_modules/@angular/compiler-cli/**",
20-
"node_modules/@angular/tsc-wrapped/**",
21-
"node_modules/@angular/*/testing/**",
2217
"node_modules/@ngrx/store/migrations/**",
2318
"node_modules/@ngrx/store/schematics/**",
2419
"node_modules/@ngrx/store/schematics-core/**"

src/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ng_module(
1212
deps = [
1313
"//src/hello-world",
1414
"//src/todos",
15+
"@angular//packages/core",
16+
"@angular//packages/router",
1517
],
1618
)
1719

@@ -21,16 +23,17 @@ ts_devserver(
2123
name = "devserver",
2224
additional_root_paths = [
2325
"angular_bazel_example/node_modules/zone.js/dist",
26+
"angular_bazel_example/node_modules/tslib",
2427
"angular_bazel_example/node_modules/@ngrx/store/bundles",
2528
],
2629
entry_module = "angular_bazel_example/src/main",
2730
scripts = [
2831
":require.config.js",
29-
"//:angular_bundles",
3032
],
3133
serving_path = "/bundle.min.js",
3234
static_files = [
3335
"//:node_modules/zone.js/dist/zone.min.js",
36+
"//:node_modules/tslib/tslib.js",
3437
"//:node_modules/@ngrx/store/bundles/store.umd.min.js",
3538
"index.html",
3639
],

src/hello-world/BUILD.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,32 @@ ng_module(
2424
deps = [
2525
"//src/lib",
2626
"@rxjs",
27+
"@angular//packages/core",
2728
],
2829
)
2930

3031
ts_library(
3132
name = "test_lib",
3233
testonly = 1,
3334
srcs = glob(["*.spec.ts"]),
34-
deps = [":hello-world"],
35+
deps = [
36+
":hello-world",
37+
"@angular//packages/core",
38+
"@angular//packages/core/testing",
39+
"@angular//packages/platform-browser",
40+
"@angular//packages/platform-browser-dynamic/testing",
41+
],
3542
)
3643

3744
ts_web_test_suite(
3845
name = "test",
3946
bootstrap = ["//:node_modules/zone.js/dist/zone-testing-bundle.js"],
47+
srcs = ["//:node_modules/tslib/tslib.js"],
4048
browsers = [
4149
"@io_bazel_rules_webtesting//browsers:chromium-local",
4250
"@io_bazel_rules_webtesting//browsers:firefox-local",
4351
],
4452
deps = [
4553
":test_lib",
46-
"//:angular_bundles",
47-
"//:angular_test_bundles",
4854
],
4955
)

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'tslib';
2+
13
import {platformBrowser} from '@angular/platform-browser';
24
import {AppModuleNgFactory} from './app.module.ngfactory';
35

src/todos/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ ng_module(
2525
"//src/lib",
2626
"//src/reducers",
2727
"@rxjs",
28+
"@angular//packages/core",
29+
"@angular//packages/common",
30+
"@angular//packages/forms",
2831
],
2932
)

tools/bazel.rc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ build --strategy=AngularTemplateCompile=worker
1212
build --symlink_prefix=dist/
1313

1414
test --test_output=errors
15+
16+
################################
17+
# Temporary Settings for Ivy #
18+
################################
19+
build --define=compile=legacy

0 commit comments

Comments
 (0)