build: add a ng_package rule for @angular/router (#22628)
PR Close #22628
This commit is contained in:
parent
fcb8c492d6
commit
ce649f725f
|
@ -9,15 +9,15 @@ genrule(
|
|||
npm_package(
|
||||
name = "npm_package",
|
||||
srcs = [
|
||||
"package.json",
|
||||
"index.bzl",
|
||||
"package.json",
|
||||
"//packages/bazel/src:package_assets",
|
||||
],
|
||||
deps = [":workspace"],
|
||||
# Re-host //packages/bazel/ which is just // in the public distro
|
||||
replacements = {
|
||||
"//packages/bazel/": "//",
|
||||
"angular/packages/bazel/": "angular/",
|
||||
},
|
||||
stamp_data = "//tools:stamp_data",
|
||||
deps = [":workspace"],
|
||||
)
|
||||
|
|
|
@ -18,17 +18,38 @@ WELL_KNOWN_GLOBALS = {
|
|||
"@angular/core": "ng.core",
|
||||
"@angular/common": "ng.common",
|
||||
"@angular/platform-browser": "ng.platformBrowser",
|
||||
"rxjs/Observable": "Rx",
|
||||
"rxjs/Observer": "Rx",
|
||||
"rxjs/Subject": "Rx",
|
||||
"rxjs/Subscription": "Rx",
|
||||
"rxjs/observable/merge": "Rx.Observable",
|
||||
"rxjs/observable/of": "Rx.Observable.prototype",
|
||||
"rxjs/operator/concatMap": "Rx.Observable.prototype",
|
||||
"rxjs/operator/filter": "Rx.Observable.prototype",
|
||||
"rxjs/operator/map": "Rx.Observable.prototype",
|
||||
"rxjs/operator/share": "Rx.Observable.prototype",
|
||||
}
|
||||
WELL_KNOWN_GLOBALS.update({"rxjs/%s" % s: "Rx" for s in [
|
||||
"BehaviorSubject",
|
||||
"Observable",
|
||||
"Observer",
|
||||
"Subject",
|
||||
"Subscription",
|
||||
"util/EmptyError",
|
||||
]})
|
||||
WELL_KNOWN_GLOBALS.update({"rxjs/observable/%s" % s: "Rx.Observable" for s in [
|
||||
"from",
|
||||
"fromPromise",
|
||||
"forkJoin",
|
||||
"merge",
|
||||
"of",
|
||||
]})
|
||||
WELL_KNOWN_GLOBALS.update({"rxjs/operator/%s" % s: "Rx.Observable.prototype" for s in [
|
||||
"catch",
|
||||
"concatAll",
|
||||
"concatMap",
|
||||
"every",
|
||||
"first",
|
||||
"filter",
|
||||
"last",
|
||||
"map",
|
||||
"mergeAll",
|
||||
"mergeMap",
|
||||
"reduce",
|
||||
"share",
|
||||
"toPromise",
|
||||
]})
|
||||
|
||||
|
||||
def _rollup(ctx, rollup_config, entry_point, inputs, js_output, format = "es"):
|
||||
map_output = ctx.actions.declare_file(js_output.basename + ".map", sibling = js_output)
|
||||
|
@ -102,7 +123,7 @@ def _ng_package_impl(ctx):
|
|||
esm5 = []
|
||||
bundles = []
|
||||
|
||||
for entry_point in [''] + ctx.attr.secondary_entry_points:
|
||||
for entry_point in [""] + ctx.attr.secondary_entry_points:
|
||||
es2015_entry_point = "/".join([p for p in [
|
||||
ctx.bin_dir.path,
|
||||
ctx.label.package,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("//tools:defaults.bzl", "ng_module")
|
||||
load("//tools:defaults.bzl", "ng_module", "ng_package")
|
||||
|
||||
ng_module(
|
||||
name = "router",
|
||||
|
@ -19,3 +19,18 @@ ng_module(
|
|||
"@rxjs",
|
||||
],
|
||||
)
|
||||
|
||||
ng_package(
|
||||
name = "npm_package",
|
||||
srcs = ["package.json"],
|
||||
entry_point = "packages/router/index.js",
|
||||
secondary_entry_points = [
|
||||
"testing",
|
||||
"upgrade",
|
||||
],
|
||||
deps = [
|
||||
":router",
|
||||
"//packages/router/testing",
|
||||
"//packages/router/upgrade",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -4,7 +4,6 @@ load("//tools:defaults.bzl", "ng_module")
|
|||
|
||||
ng_module(
|
||||
name = "testing",
|
||||
testonly = 1,
|
||||
srcs = glob(["**/*.ts"]),
|
||||
module_name = "@angular/router/testing",
|
||||
deps = [
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("//tools:defaults.bzl", "ng_module")
|
||||
|
||||
ng_module(
|
||||
name = "upgrade",
|
||||
srcs = glob(["**/*.ts"]),
|
||||
module_name = "@angular/router/upgrade",
|
||||
deps = [
|
||||
"//packages/core",
|
||||
"//packages/router",
|
||||
],
|
||||
)
|
Loading…
Reference in New Issue