diff --git a/WORKSPACE b/WORKSPACE index 5a09dc037671f..ca542ac43fba2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,9 +1,11 @@ +workspace(name = "angular_src") + load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( name = "build_bazel_rules_nodejs", remote = "https://github.com/bazelbuild/rules_nodejs.git", - tag = "0.0.2", + tag = "0.1.6", ) load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories") diff --git a/package.json b/package.json index d9b080ff9d934..cfc0ad0bf7a88 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "fsevents": "1.1.2" }, "devDependencies": { - "@bazel/typescript": "0.1.x", + "@bazel/typescript": "0.2.x", "@types/angularjs": "1.5.14-alpha", "@types/base64-js": "1.2.5", "@types/chokidar": "1.7.3", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel new file mode 100644 index 0000000000000..1efbd1300587c --- /dev/null +++ b/packages/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["tsconfig-build.json"]) diff --git a/packages/bazel/package.json b/packages/bazel/package.json index 1360531fba29a..0e3948f22ecfd 100644 --- a/packages/bazel/package.json +++ b/packages/bazel/package.json @@ -9,7 +9,7 @@ "typescript": "^2.4.2" }, "dependencies": { - "@bazel/typescript": "0.1.x", + "@bazel/typescript": "0.2.x", "@types/node": "6.0.84" }, "repository": { diff --git a/packages/bazel/src/ng_module.bzl b/packages/bazel/src/ng_module.bzl index 9f96f2046a78c..9dee09338e125 100644 --- a/packages/bazel/src/ng_module.bzl +++ b/packages/bazel/src/ng_module.bzl @@ -6,6 +6,7 @@ load(":rules_typescript.bzl", "tsc_wrapped_tsconfig", "COMMON_ATTRIBUTES", + "COMMON_OUTPUTS", "compile_ts", "DEPS_ASPECTS", "ts_providers_dict_to_struct", @@ -189,4 +190,5 @@ ng_module = rule( default = Label("@//:node_modules") ), }, -) \ No newline at end of file + outputs = COMMON_OUTPUTS, +) diff --git a/packages/bazel/src/ngc-wrapped/index.ts b/packages/bazel/src/ngc-wrapped/index.ts index d1aa46c7df19c..f48e059d15104 100644 --- a/packages/bazel/src/ngc-wrapped/index.ts +++ b/packages/bazel/src/ngc-wrapped/index.ts @@ -8,7 +8,7 @@ // TODO(tbosch): figure out why we need this as it breaks node code within ngc-wrapped /// import * as ng from '@angular/compiler-cli'; -import {BazelOptions, CachedFileLoader, CompilerHost, FileCache, FileLoader, UncachedFileLoader, constructManifest, debug, parseTsconfig, runAsWorker, runWorkerLoop} from '@bazel/typescript'; +import {BazelOptions, CachedFileLoader, CompilerHost, FileCache, FileLoader, UncachedFileLoader, constructManifest, debug, fixUmdModuleDeclarations, parseTsconfig, runAsWorker, runWorkerLoop} from '@bazel/typescript'; import * as fs from 'fs'; import * as path from 'path'; import * as tsickle from 'tsickle'; @@ -163,7 +163,10 @@ export function compile( program, bazelHost, bazelHost, compilerOpts, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, { beforeTs: customTransformers.before, - afterTs: customTransformers.after, + afterTs: [ + ...(customTransformers.after || []), + fixUmdModuleDeclarations((sf: ts.SourceFile) => bazelHost.amdModuleName(sf)), + ], }); const {diagnostics, emitResult, program} = ng.performCompilation( diff --git a/packages/bazel/src/rules_typescript.bzl b/packages/bazel/src/rules_typescript.bzl index 77f37b9abb351..99fff5cca4ba5 100644 --- a/packages/bazel/src/rules_typescript.bzl +++ b/packages/bazel/src/rules_typescript.bzl @@ -1,9 +1,12 @@ # Allows different paths for these imports in google3 load("@build_bazel_rules_typescript//internal:build_defs.bzl", "tsc_wrapped_tsconfig") -load( - "@build_bazel_rules_typescript//internal:common/compilation.bzl", - "COMMON_ATTRIBUTES", "compile_ts", "DEPS_ASPECTS", "ts_providers_dict_to_struct" +load("@build_bazel_rules_typescript//internal:common/compilation.bzl", + "COMMON_ATTRIBUTES", + "COMMON_OUTPUTS", + "compile_ts", + "DEPS_ASPECTS", + "ts_providers_dict_to_struct", ) load("@build_bazel_rules_typescript//internal:common/json_marshal.bzl", "json_marshal") diff --git a/packages/compiler-cli/BUILD.bazel b/packages/compiler-cli/BUILD.bazel index 6a0cc0cb2ef3d..1694e6d067dff 100644 --- a/packages/compiler-cli/BUILD.bazel +++ b/packages/compiler-cli/BUILD.bazel @@ -1,5 +1,11 @@ package(default_visibility=["//visibility:public"]) -load("@build_bazel_rules_typescript//:defs.bzl", "ts_library") +load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_config") + +ts_config( + name = "tsconfig", + src = "tsconfig-build.json", + deps = ["//packages:tsconfig-build.json"] +) ts_library( name = "compiler-cli", @@ -11,5 +17,5 @@ ts_library( deps = [ "//packages/compiler" ], - tsconfig = ":tsconfig-build.json", + tsconfig = ":tsconfig", ) diff --git a/packages/compiler/BUILD.bazel b/packages/compiler/BUILD.bazel index fde96d4c012b5..427a708dab325 100644 --- a/packages/compiler/BUILD.bazel +++ b/packages/compiler/BUILD.bazel @@ -8,6 +8,5 @@ ts_library( "testing/**", ]), module_name = "@angular/compiler", - deps = [], tsconfig = ":tsconfig-build.json", ) diff --git a/scripts/ci/env.sh b/scripts/ci/env.sh index d019d81d1e74b..3ec8e8918e274 100755 --- a/scripts/ci/env.sh +++ b/scripts/ci/env.sh @@ -36,6 +36,7 @@ fi setEnvVar NODE_VERSION 6.9.5 setEnvVar YARN_VERSION 1.0.2 +setEnvVar BAZEL_VERSION 0.5.4 setEnvVar SAUCE_CONNECT_VERSION 4.4.9 setEnvVar ANGULAR_CLI_VERSION 1.4.0-rc.2 setEnvVar PROJECT_ROOT $(cd ${thisDir}/../..; pwd) diff --git a/scripts/ci/install.sh b/scripts/ci/install.sh index a5a4673e9c3b3..50f88c45a5778 100755 --- a/scripts/ci/install.sh +++ b/scripts/ci/install.sh @@ -63,9 +63,9 @@ if [[ ${TRAVIS} && (${CI_MODE} == "bazel" || ${CI_MODE} == "e2e_2") ]]; then ( mkdir tmp cd tmp - curl --location --compressed https://github.com/bazelbuild/bazel/releases/download/0.5.2/bazel-0.5.2-installer-linux-x86_64.sh > bazel-0.5.2-installer-linux-x86_64.sh - chmod +x bazel-0.5.2-installer-linux-x86_64.sh - ./bazel-0.5.2-installer-linux-x86_64.sh --user + curl --location --compressed https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh > bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh + chmod +x bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh + ./bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh --user cd .. rm -rf tmp ) diff --git a/yarn.lock b/yarn.lock index ab9a76e008926..d365300efe30c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,11 +2,12 @@ # yarn lockfile v1 -"@bazel/typescript@0.1.x": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.1.0.tgz#14a0a74d06e0acf7cf60295963adbcc5d3f41217" +"@bazel/typescript@0.2.x": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.2.2.tgz#0a0d09924508c946de32e6acdb2b5cc1ee32c506" dependencies: "@types/node" "7.0.18" + "@types/source-map" "^0.5.1" protobufjs "5.0.0" tsickle "0.24.x" typescript "2.4.x" @@ -134,6 +135,10 @@ version "2.53.42" resolved "https://registry.yarnpkg.com/@types/selenium-webdriver/-/selenium-webdriver-2.53.42.tgz#74cb77fb6052edaff2a8984ddafd88d419f25cac" +"@types/source-map@^0.5.1": + version "0.5.1" + resolved "https://registry.yarnpkg.com/@types/source-map/-/source-map-0.5.1.tgz#7e74db5d06ab373a712356eebfaea2fad0ea2367" + "@types/systemjs@0.19.32": version "0.19.32" resolved "https://registry.yarnpkg.com/@types/systemjs/-/systemjs-0.19.32.tgz#e9204c4cdbc8e275d645c00e6150e68fc5615a24"