diff --git a/.circleci/config.yml b/.circleci/config.yml index 7efbf2cb79..56f2797b9b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,7 +41,7 @@ jobs: - restore_cache: 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/... - save_cache: key: angular-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }} diff --git a/WORKSPACE b/WORKSPACE index 57803226a9..5a09dc0376 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,17 +1,21 @@ 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", + name = "build_bazel_rules_nodejs", + remote = "https://github.com/bazelbuild/rules_nodejs.git", + tag = "0.0.2", ) -load("@build_bazel_rules_typescript//:defs.bzl", "node_repositories") +load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") -node_repositories(package_json = "//:package.json") +node_repositories(package_json = ["//:package.json"]) -git_repository( - name = "build_bazel_rules_angular", - remote = "https://github.com/bazelbuild/rules_angular.git", - tag = "0.0.1", +local_repository( + name = "build_bazel_rules_typescript", + path = "node_modules/@bazel/typescript", +) + +local_repository( + name = "angular", + path = "packages/bazel", ) \ No newline at end of file diff --git a/build.sh b/build.sh index b587140875..f88db9b0be 100755 --- a/build.sh +++ b/build.sh @@ -432,8 +432,6 @@ if [[ ${BUILD_TOOLS} == true || ${BUILD_ALL} == true ]]; then updateVersionReferences dist/packages-dist/tsc-wrapped 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 # 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 diff --git a/integration/bazel/WORKSPACE b/integration/bazel/WORKSPACE index 57e7580e73..4fe6e6e167 100644 --- a/integration/bazel/WORKSPACE +++ b/integration/bazel/WORKSPACE @@ -1,16 +1,22 @@ 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", + 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", + path = "node_modules/@bazel/typescript", ) -load("@build_bazel_rules_typescript//:defs.bzl", "node_repositories") -node_repositories(package_json = "//:package.json") local_repository( name = "angular", - path = "node_modules/@angular/bazel" + path = "node_modules/@angular/bazel", ) git_repository( diff --git a/integration/bazel/angular.tsconfig.json b/integration/bazel/angular.tsconfig.json index b080935ebf..f0b402dc0e 100644 --- a/integration/bazel/angular.tsconfig.json +++ b/integration/bazel/angular.tsconfig.json @@ -16,6 +16,8 @@ "exclude": [ "node_modules/@angular/bazel/**", "node_modules/@angular/compiler-cli/**", + // Workaround bug introduced by 079d884 + "node_modules/@angular/common/i18n_data*", "node_modules/@angular/tsc-wrapped/**" ] } diff --git a/integration/bazel/package.json b/integration/bazel/package.json index 716f073811..4579e0f29d 100644 --- a/integration/bazel/package.json +++ b/integration/bazel/package.json @@ -15,8 +15,7 @@ "devDependencies": { "@angular/bazel": "file:../../dist/packages-dist/bazel", "@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", - "@types/node": "^7.0.18", - "protobufjs": "5.0.0", + "@bazel/typescript": "0.0.7", "typescript": "~2.3.1" }, "scripts": { diff --git a/npm-shrinkwrap.clean.json b/npm-shrinkwrap.clean.json index edbe15e785..f973941057 100644 --- a/npm-shrinkwrap.clean.json +++ b/npm-shrinkwrap.clean.json @@ -1,7 +1,18 @@ { "name": "angular-srcs", - "version": "5.0.0-beta.0", + "version": "5.0.0-beta.4", "dependencies": { + "@bazel/typescript": { + "version": "0.0.7", + "dependencies": { + "@types/node": { + "version": "7.0.18" + }, + "tsickle": { + "version": "0.23.6" + } + } + }, "@types/angularjs": { "version": "1.5.13-alpha" }, diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 8f066b3fd3..96d352989d 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,7 +1,24 @@ { "name": "angular-srcs", - "version": "5.0.0-beta.0", + "version": "5.0.0-beta.4", "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": { "version": "1.5.13-alpha", "from": "@types/angularjs@latest", diff --git a/package.json b/package.json index eaf31926d8..ea35ff37f3 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "fsevents": "^1.0.14" }, "devDependencies": { + "@bazel/typescript": "0.0.7", "@types/angularjs": "^1.5.13-alpha", "@types/base64-js": "^1.2.5", "@types/fs-extra": "0.0.22-alpha", @@ -80,7 +81,6 @@ "nan": "^2.4.0", "node-uuid": "1.4.x", "parse5": "^3.0.1", - "protobufjs": "^5.0.0", "protractor": "^4.0.14", "react": "^0.14.0", "rewire": "^2.3.3", diff --git a/packages/bazel/WORKSPACE b/packages/bazel/WORKSPACE index 873e7584e7..0951b51139 100644 --- a/packages/bazel/WORKSPACE +++ b/packages/bazel/WORKSPACE @@ -7,15 +7,3 @@ # We take the name "angular" so that users can write # load("@angular//:index.bzl", "ng_module") 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") diff --git a/packages/bazel/src/ngc-wrapped/BUILD.bazel b/packages/bazel/src/ngc-wrapped/BUILD.bazel index b5f1368870..5f5d0b5fbd 100644 --- a/packages/bazel/src/ngc-wrapped/BUILD.bazel +++ b/packages/bazel/src/ngc-wrapped/BUILD.bazel @@ -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 @@ -9,7 +10,7 @@ ts_library( # BEGIN-INTERNAL # Only needed when compiling within the Angular repo. # Users will get this dependency from node_modules. - "//packages/compiler-cli", + "@//packages/compiler-cli", # END-INTERNAL "@build_bazel_rules_typescript//internal/tsc_wrapped" ], @@ -18,7 +19,9 @@ ts_library( nodejs_binary( 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"], visibility = ["//visibility:public"], ) \ No newline at end of file diff --git a/packages/bazel/src/ngc-wrapped/index.ts b/packages/bazel/src/ngc-wrapped/index.ts index a5d26bfeda..48893d2b2f 100644 --- a/packages/bazel/src/ngc-wrapped/index.ts +++ b/packages/bazel/src/ngc-wrapped/index.ts @@ -5,15 +5,10 @@ * 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 */ -// 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 {CompilerHost, UncachedFileLoader, parseTsconfig} from '@bazel/typescript'; import * as fs from 'fs'; 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 ts from 'typescript'; diff --git a/packages/core/BUILD.bazel b/packages/core/BUILD.bazel index 1c2d80e76d..90001f97b3 100644 --- a/packages/core/BUILD.bazel +++ b/packages/core/BUILD.bazel @@ -1,28 +1,13 @@ package(default_visibility=["//visibility:public"]) -load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") -ts_library( - name = "core", - srcs = glob(["**/*.ts"], exclude=[ - "test/**", - "testing/**", - ]), - module_name = "@angular/core", - deps = [], - tsconfig = ":tsconfig-build.json", -) - -load("@build_bazel_rules_angular//:defs.bzl", "ng_module") +load("@angular//:index.bzl", "ng_module") ng_module( - name = "core_ng_module", + name = "core", 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" ) \ No newline at end of file