refactor(bazel): convert most ts_library to ng_module (#22176)

This is necessary so we can produce ng metadata for our packages that are published as libraries

PR Close #22176
This commit is contained in:
Alex Eagle 2018-02-13 08:19:33 -08:00 committed by Victor Berchet
parent 03d93c96a3
commit a069e08354
28 changed files with 56 additions and 50 deletions

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "animations",
srcs = glob(
[

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "browser",
srcs = glob(
[

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),

View File

@ -7,6 +7,6 @@
Users should not load files under "/src"
"""
load("//src:ng_module.bzl", _ng_module = "ng_module")
load("//packages/bazel/src:ng_module.bzl", _ng_module = "ng_module")
ng_module = _ng_module

View File

@ -12,8 +12,8 @@ ts_library(
visibility = ["//packages/bazel/test/ngc-wrapped:__subpackages__"],
deps = [
# BEGIN-INTERNAL
# Only needed when compiling Angular from sources.
# Users with an npm depnedency will get this dependency from node_modules.
# Only needed when compiling within the Angular repo.
# Users will get this dependency from node_modules.
"//packages/compiler-cli",
# END-INTERNAL
"@build_bazel_rules_typescript//internal/tsc_wrapped",

View File

@ -10,12 +10,8 @@ ts_library(
],
tsconfig = ":tsconfig.json",
deps = [
# BEGIN-INTERNAL
# Only needed when compiling within the Angular repo.
# Users will get this dependency from node_modules.
"//packages/compiler-cli",
# END-INTERNAL
"//packages/bazel/src/ngc-wrapped:ngc_lib",
"//packages/compiler-cli",
],
)

View File

@ -1,10 +1,9 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(
[
"*.ts",

View File

@ -1,10 +1,9 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/common/testing",
deps = [

View File

@ -22,6 +22,7 @@ ts_library(
],
),
module_name = "@angular/compiler-cli",
node_modules = "@//:node_modules",
tsconfig = ":tsconfig",
deps = [
"//packages/compiler",

View File

@ -12,6 +12,9 @@
},
"outDir": "../../dist/packages/compiler-cli"
},
"bazelOptions": {
"suppressTsconfigOverrideWarnings": true
},
"exclude": [
"integrationtest"

View File

@ -1,10 +1,9 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/core/testing",
deps = [

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Compiler, CompilerOptions, Component, ComponentFactory, Directive, Injector, NgModule, Pipe, Type} from '@angular/core';
import {Compiler, CompilerOptions, Component, ComponentFactory, Directive, Injectable, Injector, NgModule, Pipe, Type} from '@angular/core';
import {MetadataOverride} from './metadata_override';
@ -19,6 +19,7 @@ function unimplemented(): any {
*
* @experimental
*/
@Injectable()
export class TestingCompiler extends Compiler {
get injector(): Injector { throw unimplemented(); }
overrideModule(module: Type<any>, overrides: MetadataOverride<NgModule>): void {

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "platform-browser-dynamic",
srcs = glob(
[

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "platform-webworker",
srcs = glob(
[

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "router",
srcs = glob(
[

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "service-worker",
srcs = glob(
[

View File

@ -1,13 +1,14 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "testing",
testonly = 1,
srcs = glob(["**/*.ts"]),
module_name = "@angular/service-worker/testing",
deps = [
"//packages/core",
"@rxjs",
],
)

View File

@ -8,6 +8,7 @@ ts_library(
srcs = glob(["**/*.ts"]),
deps = [
"//packages:types",
"//packages/core",
"//packages/service-worker/worker",
"@rxjs",
],

View File

@ -15,6 +15,9 @@
"target": "es2017",
"typeRoots": []
},
"bazelOptions": {
"suppressTsconfigOverrideWarnings": true
},
"files": [
"main.ts",
"src/service-worker.d.ts"

View File

@ -24,6 +24,9 @@
"target": "es5",
"types": ["angularjs"]
},
"bazelOptions": {
"suppressTsconfigOverrideWarnings": true
},
"exclude": [
"bazel",
"compiler-cli/integrationtest",

View File

@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")
ts_library(
ng_module(
name = "upgrade",
srcs = glob(
[

View File

@ -1,6 +1,6 @@
"""Re-export of some bazel rules with repository-wide defaults."""
load("@build_bazel_rules_typescript//:defs.bzl", _ts_library = "ts_library")
load("//packages/bazel/src:ng_module.bzl", _ng_module = "ng_module")
load("//packages/bazel:index.bzl", _ng_module = "ng_module")
DEFAULT_TSCONFIG = "//packages:tsconfig-build.json"
@ -9,7 +9,7 @@ def ts_library(tsconfig = None, **kwargs):
tsconfig = DEFAULT_TSCONFIG
_ts_library(tsconfig = tsconfig, **kwargs)
def ng_module(tsconfig = None, **kwargs):
def ng_module(name, tsconfig = None, **kwargs):
if not tsconfig:
tsconfig = DEFAULT_TSCONFIG
_ng_module(tsconfig = tsconfig, **kwargs)
_ng_module(name = name, tsconfig = tsconfig, **kwargs)