build: upgrade to latest bazel rules (#18733)

PR Close #18733
This commit is contained in:
Alex Eagle 2017-08-22 16:56:29 -07:00 committed by Miško Hevery
parent 47220997e1
commit f2f5286020
13 changed files with 69 additions and 61 deletions

View File

@ -41,7 +41,7 @@ jobs:
- restore_cache: - restore_cache:
key: angular-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }} key: angular-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }}
- run: bazel run @build_bazel_rules_typescript_node//:bin/npm install - run: bazel run @nodejs//:npm install
- run: bazel build packages/... - run: bazel build packages/...
- save_cache: - save_cache:
key: angular-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }} key: angular-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }}

View File

@ -1,17 +1,21 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository( git_repository(
name = "build_bazel_rules_nodejs",
remote = "https://github.com/bazelbuild/rules_nodejs.git",
tag = "0.0.2",
)
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
node_repositories(package_json = ["//:package.json"])
local_repository(
name = "build_bazel_rules_typescript", name = "build_bazel_rules_typescript",
remote = "https://github.com/bazelbuild/rules_typescript.git", path = "node_modules/@bazel/typescript",
tag = "0.0.6",
) )
load("@build_bazel_rules_typescript//:defs.bzl", "node_repositories") local_repository(
name = "angular",
node_repositories(package_json = "//:package.json") path = "packages/bazel",
git_repository(
name = "build_bazel_rules_angular",
remote = "https://github.com/bazelbuild/rules_angular.git",
tag = "0.0.1",
) )

View File

@ -432,8 +432,6 @@ if [[ ${BUILD_TOOLS} == true || ${BUILD_ALL} == true ]]; then
updateVersionReferences dist/packages-dist/tsc-wrapped updateVersionReferences dist/packages-dist/tsc-wrapped
rsync -a packages/bazel/ ./dist/packages-dist/bazel rsync -a packages/bazel/ ./dist/packages-dist/bazel
# Re-write nodejs import paths
perl -p -i -e "s#__main__/packages/bazel#angular#g" $(grep -ril __main__ dist/packages-dist/bazel) < /dev/null 2> /dev/null
# Remove BEGIN-INTERNAL...END-INTERAL blocks # Remove BEGIN-INTERNAL...END-INTERAL blocks
# https://stackoverflow.com/questions/24175271/how-can-i-match-multi-line-patterns-in-the-command-line-with-perl-style-regex # https://stackoverflow.com/questions/24175271/how-can-i-match-multi-line-patterns-in-the-command-line-with-perl-style-regex
perl -0777 -n -i -e "s/(?m)^.*BEGIN-INTERNAL[\w\W]*END-INTERNAL.*\n//g; print" $(grep -ril BEGIN-INTERNAL dist/packages-dist/bazel) < /dev/null 2> /dev/null perl -0777 -n -i -e "s/(?m)^.*BEGIN-INTERNAL[\w\W]*END-INTERNAL.*\n//g; print" $(grep -ril BEGIN-INTERNAL dist/packages-dist/bazel) < /dev/null 2> /dev/null

View File

@ -1,16 +1,22 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository( git_repository(
name = "build_bazel_rules_typescript", name = "build_bazel_rules_nodejs",
remote = "https://github.com/bazelbuild/rules_typescript.git", remote = "https://github.com/bazelbuild/rules_nodejs.git",
tag = "0.0.6", tag = "0.0.2",
)
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")
node_repositories(package_json = ["//:package.json"])
local_repository(
name = "build_bazel_rules_typescript",
path = "node_modules/@bazel/typescript",
) )
load("@build_bazel_rules_typescript//:defs.bzl", "node_repositories")
node_repositories(package_json = "//:package.json")
local_repository( local_repository(
name = "angular", name = "angular",
path = "node_modules/@angular/bazel" path = "node_modules/@angular/bazel",
) )
git_repository( git_repository(

View File

@ -16,6 +16,8 @@
"exclude": [ "exclude": [
"node_modules/@angular/bazel/**", "node_modules/@angular/bazel/**",
"node_modules/@angular/compiler-cli/**", "node_modules/@angular/compiler-cli/**",
// Workaround bug introduced by 079d884
"node_modules/@angular/common/i18n_data*",
"node_modules/@angular/tsc-wrapped/**" "node_modules/@angular/tsc-wrapped/**"
] ]
} }

View File

@ -15,8 +15,7 @@
"devDependencies": { "devDependencies": {
"@angular/bazel": "file:../../dist/packages-dist/bazel", "@angular/bazel": "file:../../dist/packages-dist/bazel",
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", "@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@types/node": "^7.0.18", "@bazel/typescript": "0.0.7",
"protobufjs": "5.0.0",
"typescript": "~2.3.1" "typescript": "~2.3.1"
}, },
"scripts": { "scripts": {

View File

@ -1,7 +1,18 @@
{ {
"name": "angular-srcs", "name": "angular-srcs",
"version": "5.0.0-beta.0", "version": "5.0.0-beta.4",
"dependencies": { "dependencies": {
"@bazel/typescript": {
"version": "0.0.7",
"dependencies": {
"@types/node": {
"version": "7.0.18"
},
"tsickle": {
"version": "0.23.6"
}
}
},
"@types/angularjs": { "@types/angularjs": {
"version": "1.5.13-alpha" "version": "1.5.13-alpha"
}, },

19
npm-shrinkwrap.json generated
View File

@ -1,7 +1,24 @@
{ {
"name": "angular-srcs", "name": "angular-srcs",
"version": "5.0.0-beta.0", "version": "5.0.0-beta.4",
"dependencies": { "dependencies": {
"@bazel/typescript": {
"version": "0.0.7",
"from": "@bazel/typescript@latest",
"resolved": "https://registry.npmjs.org/@bazel/typescript/-/typescript-0.0.7.tgz",
"dependencies": {
"@types/node": {
"version": "7.0.18",
"from": "@types/node@7.0.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.18.tgz"
},
"tsickle": {
"version": "0.23.6",
"from": "tsickle@0.23.6",
"resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.23.6.tgz"
}
}
},
"@types/angularjs": { "@types/angularjs": {
"version": "1.5.13-alpha", "version": "1.5.13-alpha",
"from": "@types/angularjs@latest", "from": "@types/angularjs@latest",

View File

@ -31,6 +31,7 @@
"fsevents": "^1.0.14" "fsevents": "^1.0.14"
}, },
"devDependencies": { "devDependencies": {
"@bazel/typescript": "0.0.7",
"@types/angularjs": "^1.5.13-alpha", "@types/angularjs": "^1.5.13-alpha",
"@types/base64-js": "^1.2.5", "@types/base64-js": "^1.2.5",
"@types/fs-extra": "0.0.22-alpha", "@types/fs-extra": "0.0.22-alpha",
@ -80,7 +81,6 @@
"nan": "^2.4.0", "nan": "^2.4.0",
"node-uuid": "1.4.x", "node-uuid": "1.4.x",
"parse5": "^3.0.1", "parse5": "^3.0.1",
"protobufjs": "^5.0.0",
"protractor": "^4.0.14", "protractor": "^4.0.14",
"react": "^0.14.0", "react": "^0.14.0",
"rewire": "^2.3.3", "rewire": "^2.3.3",

View File

@ -7,15 +7,3 @@
# We take the name "angular" so that users can write # We take the name "angular" so that users can write
# load("@angular//:index.bzl", "ng_module") # load("@angular//:index.bzl", "ng_module")
workspace(name = "angular") workspace(name = "angular")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "build_bazel_rules_typescript",
remote = "https://github.com/bazelbuild/rules_typescript.git",
tag = "0.0.6",
)
load("@build_bazel_rules_typescript//:defs.bzl", "node_repositories")
node_repositories(package_json = ":package.json")

View File

@ -1,4 +1,5 @@
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "nodejs_binary") load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
licenses(["notice"]) # Apache 2.0 licenses(["notice"]) # Apache 2.0
@ -9,7 +10,7 @@ ts_library(
# BEGIN-INTERNAL # BEGIN-INTERNAL
# Only needed when compiling within the Angular repo. # Only needed when compiling within the Angular repo.
# Users will get this dependency from node_modules. # Users will get this dependency from node_modules.
"//packages/compiler-cli", "@//packages/compiler-cli",
# END-INTERNAL # END-INTERNAL
"@build_bazel_rules_typescript//internal/tsc_wrapped" "@build_bazel_rules_typescript//internal/tsc_wrapped"
], ],
@ -18,7 +19,9 @@ ts_library(
nodejs_binary( nodejs_binary(
name = "ngc-wrapped", name = "ngc-wrapped",
entry_point = "__main__/packages/bazel/src/ngc-wrapped/index.js", # Entry point assumes the user is outside this WORKSPACE,
# and references our rules with @angular//src/ngc-wrapped
entry_point = "angular/src/ngc-wrapped/index.js",
data = [":ngc_lib"], data = [":ngc_lib"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )

View File

@ -5,15 +5,10 @@
* Use of this source code is governed by an MIT-style license that can be * Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
// TODO(chuckj): Remove the requirment for a fake 'reflect` implementation from
// the compiler
import 'reflect-metadata'; // from //third_party/javascript/node_modules/reflect_decorators:ts
import * as ng from '@angular/compiler-cli'; import * as ng from '@angular/compiler-cli';
import {CompilerHost, UncachedFileLoader, parseTsconfig} from '@bazel/typescript';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
// Note, the tsc_wrapped module comes from rules_typescript, not from npm
import {CompilerHost, UncachedFileLoader, parseTsconfig} from 'tsc_wrapped';
import * as tsickle from 'tsickle'; import * as tsickle from 'tsickle';
import * as ts from 'typescript'; import * as ts from 'typescript';

View File

@ -1,28 +1,13 @@
package(default_visibility=["//visibility:public"]) package(default_visibility=["//visibility:public"])
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
ts_library( load("@angular//:index.bzl", "ng_module")
ng_module(
name = "core", name = "core",
srcs = glob(["**/*.ts"], exclude=[ srcs = glob(["**/*.ts"], exclude=[
"test/**", "test/**",
"testing/**", "testing/**",
]), ]),
module_name = "@angular/core", module_name = "@angular/core",
deps = [],
tsconfig = ":tsconfig-build.json", tsconfig = ":tsconfig-build.json",
) )
load("@build_bazel_rules_angular//:defs.bzl", "ng_module")
ng_module(
name = "core_ng_module",
srcs = glob(["**/*.ts"], exclude=[
"test/**",
"testing/**",
]),
# Needed to allow (ts_library,ng_module) pair
write_ng_outputs_only = True,
module_name = "@angular/core",
tsconfig = ":tsconfig-build.json",
compiler = "//packages/bazel/src/ngc-wrapped"
)