build: Use fine-grained node_module deps

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`
This commit is contained in:
Keen Yee Liau 2018-10-19 17:42:04 -07:00 committed by Keen Yee Liau
parent b38a13dc02
commit a3b05a0283
27 changed files with 1502 additions and 1866 deletions

2
.bazelignore Normal file
View File

@ -0,0 +1,2 @@
dist
node_modules

View File

@ -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

68
BUILD
View File

@ -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

View File

@ -1,4 +1,4 @@
workspace(name = "angular_devkit")
workspace(name = "angular_cli")
# We get Buildifier from here.
http_archive(
@ -8,56 +8,31 @@ 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 = {
@ -86,7 +61,18 @@ node_repositories(
},
)
local_repository(
name = "rxjs",
path = "node_modules/rxjs/src",
yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
data = [
"//:tools/yarn/check-yarn.js",
],
)
http_archive(
name = "rxjs",
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz",
strip_prefix = "package/src",
sha256 = "72b0b4e517f43358f554c125e40e39f67688cd2738a8998b4a266981ed32f403",
)

View File

@ -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",
@ -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",
@ -101,9 +103,14 @@
"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",
@ -111,6 +118,7 @@
"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"

View File

@ -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",
],
)

View File

@ -30,7 +30,7 @@ ts_library(
"//packages/angular_devkit/core",
"//packages/angular_devkit/schematics",
"@rxjs",
# @typings: node
"@npm//@types/node",
],
)

View File

@ -26,5 +26,6 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
"@npm//@types/node",
],
)

View File

@ -20,5 +20,7 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
"@npm//@types/node",
"@npm//@types/minimist",
],
)

View File

@ -27,7 +27,8 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
# @typings: node
"@npm//@types/node",
"@npm//@types/minimist",
],
)
@ -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",
],
)

View File

@ -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(
@ -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",
],
)

View File

@ -27,12 +27,12 @@ ts_library(
deps = [
"@rxjs",
"@rxjs//operators",
"@npm//@types/node",
"@npm//@types/source-map",
"@npm//ajv",
# @typings: es2015.core
# @typings: es2015.symbol.wellknown
# @typings: es2016.array.include
# @typings: ajv
# @typings: node
# @typings: source-map
],
)
@ -49,18 +49,25 @@ ts_library(
":node",
"@rxjs",
"@rxjs//operators",
# @typings: jasmine
# @typings: node
"@npm//@types/node",
"@npm//@types/jasmine",
],
data = [
"src/workspace/workspace-schema.json",
"src/workspace/test/test-workspace.json"
],
testonly = True,
tsconfig = "//:tsconfig-test.json",
)
jasmine_node_test(
name = "core_test",
srcs = [":core_test_lib"],
deps = [
"@npm//jasmine",
"@npm//source-map",
"@npm//chokidar",
],
)
@ -83,7 +90,7 @@ ts_library(
":core",
"@rxjs",
"@rxjs//operators",
# @typings: node
"@npm//@types/node",
],
)
@ -100,14 +107,23 @@ ts_library(
":node",
"@rxjs",
"@rxjs//operators",
# @typings: jasmine
# @typings: node
"@npm//@types/node",
"@npm//@types/jasmine",
],
testonly = True,
tsconfig = "//:tsconfig-test.json",
)
jasmine_node_test(
name = "node_test",
srcs = [":node_test_lib"],
deps = [
"@npm//jasmine",
"@npm//chokidar",
"@npm//source-map",
"@npm//temp",
"@npm//tslint",
],
)
@ -130,6 +146,7 @@ ts_library(
":node",
"@rxjs",
"@rxjs//operators",
# @typings: node
"@npm//@types/node",
"@npm//@types/jasmine",
],
)

View File

@ -260,6 +260,12 @@ export function resolve(x: string, options: ResolveOptions): string {
function nodeModulesPaths(start: string, opts: ResolveOptions) {
const modules = ['node_modules'];
if (process.env.BAZEL_TARGET) {
// When running test under Bazel, node_modules have to be resolved
// differently. node_modules are installed in the `npm` workspace.
// For more info, see `yarn_install` rule in WORKSPACE file.
modules.push(path.join('npm', 'node_modules'));
}
// ensure that `start` is an absolute path at this point,
// resolving against the process' current working directory

View File

@ -28,7 +28,7 @@ ts_library(
"//packages/angular_devkit/core:node", # TODO: get rid of this for 6.0
"@rxjs",
"@rxjs//operators",
# @typings: node
"@npm//@types/node",
],
)
@ -47,14 +47,21 @@ 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 = "schematics_test",
srcs = [":schematics_test_lib"],
deps = [
"@npm//jasmine",
"@npm//source-map",
"@npm//chokidar",
],
)
@ -79,9 +86,8 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
# @typings: node
# @typings: tslint
# @typings: typescript
"@npm//@types/node",
"@npm//tslint",
],
)
@ -105,9 +111,7 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
# @typings: node
# @typings: tslint
# @typings: typescript
"@npm//@types/node",
],
)
@ -133,15 +137,22 @@ ts_library(
"//packages/angular_devkit/core:node_testing",
"@rxjs",
"@rxjs//operators",
# @typings: jasmine
# @typings: node
"@npm//@types/node",
"@npm//@types/jasmine",
],
testonly = True,
tsconfig = "//:tsconfig-test.json",
)
jasmine_node_test(
name = "tasks_test",
srcs = [":tasks_test_lib"],
deps = [
"@npm//jasmine",
"@npm//source-map",
"@npm//chokidar",
],
)
@ -167,7 +178,7 @@ ts_library(
"//packages/angular_devkit/core:node",
"@rxjs",
"@rxjs//operators",
# @typings: node
"@npm//@types/node",
],
)
@ -190,14 +201,21 @@ ts_library(
"//tests/angular_devkit/schematics/tools/file-system-engine-host:file_system_engine_host_test_lib",
"@rxjs",
"@rxjs//operators",
# @typings: jasmine
# @typings: node
"@npm//@types/node",
"@npm//@types/jasmine",
],
testonly = True,
tsconfig = "//:tsconfig-test.json",
)
jasmine_node_test(
name = "tools_test",
srcs = [":tools_test_lib"],
deps = [
"@npm//jasmine",
"@npm//source-map",
"@npm//chokidar",
],
)
@ -218,5 +236,6 @@ ts_library(
"//packages/angular_devkit/core",
"@rxjs",
"@rxjs//operators",
"@npm//@types/node",
],
)

View File

@ -31,6 +31,7 @@ ts_library(
"//packages/angular_devkit/schematics:tools",
"@rxjs",
"@rxjs//operators",
# @typings: minimist
"@npm//@types/minimist",
"@npm//@types/node",
],
)

View File

@ -49,8 +49,8 @@ ts_library(
"//packages/angular_devkit/schematics:tasks",
"@rxjs",
"@rxjs//operators",
# @typings: typescript
# @typings: node
"@npm//@types/node",
"@npm//typescript",
],
)
@ -78,12 +78,20 @@ ts_library(
"//packages/angular_devkit/schematics:testing",
"@rxjs",
"@rxjs//operators",
# @typings: jasmine
# @typings: node
"@npm//@types/node",
"@npm//@types/jasmine",
"@npm//typescript",
],
testonly = True,
tsconfig = "//:tsconfig-test.json",
)
jasmine_node_test(
name = "angular_test",
srcs = [":angular_test_lib"],
deps = [
"@npm//jasmine",
"@npm//source-map",
"@npm//chokidar",
],
)

View File

@ -32,7 +32,7 @@ ts_library(
"//packages/angular_devkit/schematics:tasks",
"@rxjs",
"@rxjs//operators",
# @typings: node
"@npm//@types/node",
],
)
@ -76,9 +76,11 @@ ts_json_schema(
# "//packages/angular_devkit/schematics:testing",
# "@rxjs",
# "@rxjs//operators",
# # @typings: jasmine
# # @typings: node
# "@npm//@types/node",
# "@npm//@types/jasmine",
# ],
# testonly = True,
# tsconfig = "//:tsconfig-test.json",
# )
# jasmine_node_test(

View File

@ -29,7 +29,8 @@ ts_library(
"//packages/angular_devkit/schematics:tasks",
"@rxjs",
"@rxjs//operators",
# @typings: node
"@npm//@types/node",
"@npm//@types/semver",
],
)
@ -63,12 +64,22 @@ ts_library(
"//packages/angular_devkit/schematics:testing",
"@rxjs",
"@rxjs//operators",
# @typings: jasmine
# @typings: node
"@npm//@types/jasmine",
"@npm//@types/node",
"@npm//@types/semver",
"@npm//pacote",
],
testonly = True,
tsconfig = "//:tsconfig-test.json",
)
jasmine_node_test(
name = "update_test",
srcs = [":update_test_lib"],
deps = [
"@npm//jasmine",
"@npm//source-map",
"@npm//chokidar",
"@npm//npm-registry-client",
],
)

View File

@ -71,6 +71,7 @@ const ignoredPackages = [
'bitsyntax@0.0.4', // MIT but no license field in package.json
'pako@1.0.6', // MIT but broken license in package.json
'true-case-path@1.0.2', // Apache-2.0 but broken license in package.json
'uws@9.14.0', // zlib license
// * Other
'font-awesome@4.7.0', // (OFL-1.1 AND MIT)

View File

@ -19,13 +19,13 @@ ts_library(
include = ["**/collection.json"],
),
deps = [
"//packages/angular_devkit/schematics:schematics",
"//packages/angular_devkit/schematics",
# ":testing",
# "//packages/angular_devkit/core",
# "//packages/angular_devkit/core:node",
# "@rxjs",
# "@rxjs//operators",
# @typings: jasmine
# @typings: node
"@npm//@types/jasmine",
"@npm//@types/node",
],
)

View File

@ -10,10 +10,10 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
nodejs_binary(
name = 'quicktype_runner',
data = [
":quicktype_runner.js",
"quicktype_runner.js",
],
node_modules = "//:quicktype_node_modules",
entry_point = "angular_devkit/tools/quicktype_runner.js",
node_modules = "@npm//quicktype-core",
entry_point = "angular_cli/tools/quicktype_runner.js",
templated_args = [
# Needed so that node doesn't walk back to the source directory.
# From there, the relative imports would point to .ts files.

View File

@ -11,6 +11,9 @@ ts_library(
srcs = ["parse_bep.ts"],
deps = [
":build_event_stream",
"@npm//@types/node",
"@rxjs",
"@rxjs//operators",
],
)

View File

@ -71,6 +71,9 @@ def ts_json_schema(name, src, data = []):
ts_library(
name = name,
deps = [
"@npm//@types/node",
],
# Remove these to empty the rule, since those files are also compiled elsewhere.
# @external_begin
srcs = [

9
tsconfig-test.json Normal file
View File

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": [
"node",
"jasmine"
]
},
}

View File

@ -36,7 +36,6 @@
"./node_modules/@types"
],
"types": [
"jasmine",
"node"
],
"paths": {

2968
yarn.lock

File diff suppressed because it is too large Load Diff