Skip to content

Commit

Permalink
build: Use fine-grained node_module deps
Browse files Browse the repository at this point in the history
This commit updates the BUILD files to specify fine-grained node_module deps
by replacing "@typings" comments with actual @npm node module.

Moved tools/bazel.rc -> .bazelrc

Removed "jasmine" typings from base tsconfig.json

Added @bazel/karma to devDependencies, needed for `ts_web_test`
  • Loading branch information
kyliau authored and Keen Yee Liau committed Nov 1, 2018
1 parent b38a13d commit a3b05a0
Show file tree
Hide file tree
Showing 27 changed files with 1,502 additions and 1,866 deletions.
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
File renamed without changes.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
## IMPORTANT
# If you change the `docker_image` version, also change the `cache_key` suffix and the version of
# `com_github_bazelbuild_buildtools` in the `/WORKSPACE` file.
var_1: &docker_image angular/ngcontainer:0.5.0
var_2: &cache_key angular_devkit-{{ checksum "yarn.lock" }}-0.5.0
var_1: &docker_image angular/ngcontainer:0.7.0
var_2: &cache_key angular_devkit-{{ checksum "yarn.lock" }}-0.7.0
var_3: &node_8_docker_image angular/ngcontainer:0.3.3

# Settings common to each job
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
<<: *root_package_lock_key
paths:
- ~/.cache/yarn

lint:
<<: *defaults
steps:
Expand Down Expand Up @@ -89,12 +89,12 @@ jobs:
- store_artifacts:
path: /tmp/dist
destination: cli/new-production

e2e-node-8:
<<: *defaults
# Overwrite docker image to node 8.
docker:
- image: *node_8_docker_image
- image: *node_8_docker_image
environment:
BASH_ENV: ~/.profile
resource_class: xlarge
Expand Down
68 changes: 1 addition & 67 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,72 +9,6 @@ licenses(["notice"]) # MIT License
exports_files([
"LICENSE",
"tsconfig.json", # @external
"tsconfig-test.json", # @external
"tslint.base.json", # @external
])

# NOTE: this will move to node_modules/BUILD in a later release
# @external_begin
NODE_MODULES_EXCLUDE = [
# e.g. node_modules/adm-zip/test/assets/attributes_test/New folder/hidden.txt
"node_modules/**/test/**",
# e.g. node_modules/xpath/docs/function resolvers.md
"node_modules/**/docs/**",
# e.g. node_modules/puppeteer/.local-chromium/mac-536395/chrome-mac/Chromium.app/Contents/Versions/66.0.3347.0/Chromium Framework.framework/Chromium Framework
"node_modules/**/.*/**",
# Ignore paths with spaces.
"node_modules/**/* *",
]

filegroup(
name = "node_modules",
srcs = glob(
# Only include files we might use, to reduce the file count and surface size of
# filename problems.
[
"node_modules/**/*.js",
"node_modules/**/*.json",
"node_modules/**/*.d.ts",
],
exclude = NODE_MODULES_EXCLUDE,
) + glob(["node_modules/.bin/*"]),
)

# node_modules filegroup for tools/quicktype_runner, which contains quicktype-core and tslint.
QUICKTYPE_TRANSITIVE_DEPENDENCIES = [
"collection-utils",
"core-util-is",
"inherits",
"isarray",
"js-base64",
"pako",
"pluralize",
"process-nextick-args",
"quicktype-core",
"readable-stream",
"safe-buffer",
"stream-json",
"string-to-stream",
"tiny-inflate",
"unicode-properties",
"unicode-trie",
"urijs",
"util-deprecate",
"wordwrap",
]

filegroup(
name = "quicktype_node_modules",
srcs = glob(
[
"/".join([
"node_modules", "**", pkg, "**/*.js",
]) for pkg in QUICKTYPE_TRANSITIVE_DEPENDENCIES
] + [
"/".join([
"node_modules", "**", pkg, "**/*.json",
]) for pkg in QUICKTYPE_TRANSITIVE_DEPENDENCIES
],
exclude = NODE_MODULES_EXCLUDE,
)
)
# @external_end
82 changes: 34 additions & 48 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
workspace(name = "angular_devkit")
workspace(name = "angular_cli")

# We get Buildifier from here.
http_archive(
Expand All @@ -8,85 +8,71 @@ http_archive(
sha256 = "76d1837a86fa6ef5b4a07438f8489f00bfa1b841e5643b618e01232ba884b1fe",
)

load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies")
buildifier_dependencies()

# The Go toolchain is used for Buildifier.
# rules_typescript_dependencies() also tries to load it but we add it explicitely so we
# don't have hidden dependencies.
# This also means we need to load it before rules_typescript_dependencies().
http_archive(
name = "io_bazel_rules_go",
url = "https://github.com/bazelbuild/rules_go/archive/0.14.0.zip",
strip_prefix = "rules_go-0.14.0",
sha256 = "9bd7c2743f014e4e112b671098ba1da6aec036fe07093b10ca39a9f81ec5cc33",
)

load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains()

# We need a minimum of this version to include https://github.com/bazelbuild/rules_nodejs/pull/281.
http_archive(
name = "build_bazel_rules_nodejs",
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.12.4.zip",
strip_prefix = "rules_nodejs-0.12.4",
sha256 = "c482700e032b4df60425cb9a6f8f28152fb1c4c947a9d61e6132fc59ce332b16",
)

# Load the TypeScript rules, its dependencies, and setup the workspace.
http_archive(
name = "build_bazel_rules_typescript",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.16.1.zip",
strip_prefix = "rules_typescript-0.16.1",
sha256 = "5b2b0bc63cfcffe7bf97cad2dad3b26a73362f806de66207051f66c87956a995",
url = "https://github.com/bazelbuild/rules_typescript/archive/0.20.3.zip",
strip_prefix = "rules_typescript-0.20.3",
)

load("@build_bazel_rules_typescript//:package.bzl", "rules_typescript_dependencies")
# build_bazel_rules_nodejs is loaded transitively through rules_typescript_dependencies.
rules_typescript_dependencies()

load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies")
buildifier_dependencies()

load("@io_bazel_rules_go//go:def.bzl", "go_register_toolchains", "go_rules_dependencies")
go_rules_dependencies()
go_register_toolchains()

load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace")
ts_setup_workspace()

# Load the nodejs dependencies, check minimum Bazel version, and define the local node_modules.
load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dependencies")
rules_nodejs_dependencies()

load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories")
check_bazel_version("0.15.0")
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
# 0.18.0 is needed for .bazelignore
check_bazel_version("0.18.0")
node_repositories(
package_json = ["//:package.json"],
preserve_symlinks = True,
node_version = "10.9.0",
yarn_version = "1.9.2",
node_repositories = {
"10.9.0-darwin_amd64": (
"node-v10.9.0-darwin-x64.tar.gz",
"node-v10.9.0-darwin-x64",
"node-v10.9.0-darwin-x64.tar.gz",
"node-v10.9.0-darwin-x64",
"3c4fe75dacfcc495a432a7ba2dec9045cff359af2a5d7d0429c84a424ef686fc"
),
"10.9.0-linux_amd64": (
"node-v10.9.0-linux-x64.tar.xz",
"node-v10.9.0-linux-x64",
"node-v10.9.0-linux-x64.tar.xz",
"node-v10.9.0-linux-x64",
"c5acb8b7055ee0b6ac653dc4e458c5db45348cecc564b388f4ed1def84a329ff"
),
"10.9.0-windows_amd64": (
"node-v10.9.0-win-x64.zip",
"node-v10.9.0-win-x64",
"node-v10.9.0-win-x64.zip",
"node-v10.9.0-win-x64",
"6a75cdbb69d62ed242d6cbf0238a470bcbf628567ee339d4d098a5efcda2401e"
),
},
yarn_repositories = {
"1.9.2": (
"yarn-v1.9.2.tar.gz",
"yarn-v1.9.2",
"yarn-v1.9.2.tar.gz",
"yarn-v1.9.2",
"3ad69cc7f68159a562c676e21998eb21b44138cae7e8fe0749a7d620cf940204"
),
},
)

local_repository(
yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
data = [
"//:tools/yarn/check-yarn.js",
],
)

http_archive(
name = "rxjs",
path = "node_modules/rxjs/src",
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz",
strip_prefix = "package/src",
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403",
)
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"devDependencies": {
"@angular/compiler": "^7.0.0-rc.0",
"@angular/compiler-cli": "^7.0.0-rc.0",
"@bazel/typescript": "0.16.1",
"@bazel/karma": "^0.20.3",
"@bazel/typescript": "0.20.3",
"@ngtools/json-schema": "^1.1.0",
"@types/copy-webpack-plugin": "^4.4.1",
"@types/express": "^4.16.0",
Expand All @@ -92,6 +93,7 @@
"@types/webpack": "^4.4.11",
"@types/webpack-dev-server": "^3.1.0",
"@types/webpack-sources": "^0.1.5",
"ajv": "6.5.3",
"common-tags": "^1.8.0",
"conventional-changelog": "^1.1.0",
"conventional-commits-parser": "^3.0.0",
Expand All @@ -101,16 +103,22 @@
"istanbul": "^0.4.5",
"jasmine": "^2.6.0",
"jasmine-spec-reporter": "^3.2.0",
"karma-jasmine-html-reporter": "^0.2.2",
"license-checker": "^20.1.0",
"minimatch": "^3.0.4",
"minimist": "^1.2.0",
"npm-registry-client": "^8.6.0",
"pacote": "^9.2.3",
"pidtree": "^0.3.0",
"pidusage": "^2.0.17",
"rxjs": "~6.3.0",
"semver": "^5.3.0",
"source-map": "^0.5.6",
"source-map-support": "^0.5.0",
"spdx-satisfies": "^4.0.0",
"tar": "^4.4.4",
"through2": "^2.0.3",
"tree-kill": "^1.2.0",
"ts-node": "^5.0.0",
"tslint-no-circular-imports": "^0.5.0",
"tslint-sonarts": "^1.7.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ ts_library(
"//packages/angular_devkit/schematics",
"//packages/angular_devkit/schematics:tools",
# @typings: es2017.object
# @typings: inquirer
# @typings: node
# @typings: semver
"@npm//@types/node",
"@npm//@types/inquirer",
"@npm//@types/semver",
],
)

Expand Down
2 changes: 1 addition & 1 deletion packages/angular/pwa/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ts_library(
"//packages/angular_devkit/core",
"//packages/angular_devkit/schematics",
"@rxjs",
# @typings: node
"@npm//@types/node",
],
)

Expand Down
1 change: 1 addition & 0 deletions packages/angular_devkit/architect/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
"@npm//@types/node",
],
)
2 changes: 2 additions & 0 deletions packages/angular_devkit/architect_cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
"@npm//@types/node",
"@npm//@types/minimist",
],
)
20 changes: 16 additions & 4 deletions packages/angular_devkit/benchmark/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
# @typings: node
"@npm//@types/node",
"@npm//@types/minimist",
],
)

Expand All @@ -50,12 +51,23 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
# @typings: jasmine
# @typings: node
"@npm//@types/node",
"@npm//@types/jasmine",
],
testonly = True,
tsconfig = "//:tsconfig-test.json",
)

jasmine_node_test(
name = "benchmark_test",
srcs = [":benchmark_test_lib"],
)
deps = [
"@npm//jasmine",
"@npm//source-map",
"@npm//minimist",
"@npm//pidusage",
"@npm//pidtree",
"@npm//tree-kill",
"@npm//temp",
],
)
20 changes: 16 additions & 4 deletions packages/angular_devkit/build_optimizer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ ts_library(
"src/**/*_benchmark.ts",
],
),
deps = [],
deps = [
"@npm//@types/node",
"@npm//@types/source-map",
"@npm//typescript",
"@npm//@types/webpack",
],
)

ts_library(
Expand All @@ -37,12 +42,19 @@ ts_library(
deps = [
":build_optimizer",
"//packages/angular_devkit/core",
# @typings: jasmine
# @typings: node
"@npm//@types/node",
"@npm//@types/jasmine",
"@npm//@types/source-map",
],
testonly = True,
tsconfig = "//:tsconfig-test.json",
)

jasmine_node_test(
name = "build_optimizer_test",
srcs = [":build_optimizer_test_lib"],
)
deps = [
"@npm//jasmine",
"@npm//source-map",
],
)
Loading

0 comments on commit a3b05a0

Please sign in to comment.