Skip to content

Commit

Permalink
build: update to latest @bazel/typescript (angular#19277)
Browse files Browse the repository at this point in the history
Switches devmode output of an ng_module to UMD
  • Loading branch information
alexeagle authored and vicb committed Sep 25, 2017
1 parent e224e3d commit 9ad4b3b
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 18 deletions.
4 changes: 3 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports_files(["tsconfig-build.json"])
2 changes: 1 addition & 1 deletion packages/bazel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion packages/bazel/src/ng_module.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
load(":rules_typescript.bzl",
"tsc_wrapped_tsconfig",
"COMMON_ATTRIBUTES",
"COMMON_OUTPUTS",
"compile_ts",
"DEPS_ASPECTS",
"ts_providers_dict_to_struct",
Expand Down Expand Up @@ -189,4 +190,5 @@ ng_module = rule(
default = Label("@//:node_modules")
),
},
)
outputs = COMMON_OUTPUTS,
)
7 changes: 5 additions & 2 deletions packages/bazel/src/ngc-wrapped/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// TODO(tbosch): figure out why we need this as it breaks node code within ngc-wrapped
/// <reference types="node" />
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';
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 6 additions & 3 deletions packages/bazel/src/rules_typescript.bzl
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 8 additions & 2 deletions packages/compiler-cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -11,5 +17,5 @@ ts_library(
deps = [
"//packages/compiler"
],
tsconfig = ":tsconfig-build.json",
tsconfig = ":tsconfig",
)
1 change: 0 additions & 1 deletion packages/compiler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ ts_library(
"testing/**",
]),
module_name = "@angular/compiler",
deps = [],
tsconfig = ":tsconfig-build.json",
)
1 change: 1 addition & 0 deletions scripts/ci/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions scripts/ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
11 changes: 8 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 9ad4b3b

Please sign in to comment.