mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 10:11:50 +08:00
build: support substituting/stamping files other than package.json
Similart to `pkg_npm` from `rules_nodejs`, we should have a way to make use of the stamp constants/placeholders throughout individual package files. This is not possible at all with `rules_js`'s `npm_package` rule, nor does it support stamp substitutions out of the box at all. We have our own `expand_template` machinery to substitute `package.json` files of npm archives, but we need to expand this to support arbitrary files inside a package. This will be opt-in for explicitly listed files; which is a good compromise for simplicity of supporting this. This commit adds the necessary functionality and demonstrates the feature by fixing `@angular/build`.
This commit is contained in:
parent
5660d05874
commit
e31be733b6
@ -229,6 +229,10 @@ npm_package(
|
|||||||
pkg_deps = [
|
pkg_deps = [
|
||||||
"//packages/angular_devkit/architect:package.json",
|
"//packages/angular_devkit/architect:package.json",
|
||||||
],
|
],
|
||||||
|
stamp_files = [
|
||||||
|
"src/tools/esbuild/utils.js",
|
||||||
|
"src/utils/normalize-cache.js",
|
||||||
|
],
|
||||||
tags = ["release-package"],
|
tags = ["release-package"],
|
||||||
deps = RUNTIME_ASSETS + [
|
deps = RUNTIME_ASSETS + [
|
||||||
":README.md",
|
":README.md",
|
||||||
|
@ -170,6 +170,9 @@ npm_package(
|
|||||||
"//packages/angular_devkit/schematics:package.json",
|
"//packages/angular_devkit/schematics:package.json",
|
||||||
"//packages/schematics/angular:package.json",
|
"//packages/schematics/angular:package.json",
|
||||||
],
|
],
|
||||||
|
stamp_files = [
|
||||||
|
"src/utilities/version.js",
|
||||||
|
],
|
||||||
tags = ["release-package"],
|
tags = ["release-package"],
|
||||||
deps = RUNTIME_ASSETS + [
|
deps = RUNTIME_ASSETS + [
|
||||||
":README.md",
|
":README.md",
|
||||||
|
@ -13,6 +13,7 @@ def npm_package(
|
|||||||
deps = [],
|
deps = [],
|
||||||
visibility = None,
|
visibility = None,
|
||||||
pkg_deps = [],
|
pkg_deps = [],
|
||||||
|
stamp_files = [],
|
||||||
pkg_json = "package.json",
|
pkg_json = "package.json",
|
||||||
**kwargs):
|
**kwargs):
|
||||||
if name != "pkg":
|
if name != "pkg":
|
||||||
@ -74,11 +75,23 @@ def npm_package(
|
|||||||
stamp_substitutions = get_npm_package_substitutions_for_rjs(),
|
stamp_substitutions = get_npm_package_substitutions_for_rjs(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
stamp_targets = []
|
||||||
|
for f in stamp_files:
|
||||||
|
expand_template(
|
||||||
|
name = "stamp_file_%s" % f,
|
||||||
|
template = f,
|
||||||
|
out = "substituted/%s" % f,
|
||||||
|
substitutions = NO_STAMP_PACKAGE_SUBSTITUTIONS,
|
||||||
|
stamp_substitutions = get_npm_package_substitutions_for_rjs(),
|
||||||
|
)
|
||||||
|
|
||||||
|
stamp_targets.append("stamp_file_%s" % f)
|
||||||
|
|
||||||
_npm_package(
|
_npm_package(
|
||||||
name = "npm_package",
|
name = "npm_package",
|
||||||
visibility = visibility,
|
visibility = visibility,
|
||||||
# Note: Order matters here! Last file takes precedence after replaced prefixes.
|
# Note: Order matters here! Last file takes precedence after replaced prefixes.
|
||||||
srcs = deps + [":final_package_json"],
|
srcs = deps + stamp_targets + [":final_package_json"],
|
||||||
replace_prefixes = {
|
replace_prefixes = {
|
||||||
"substituted_final/": "",
|
"substituted_final/": "",
|
||||||
"substituted_with_tars/": "",
|
"substituted_with_tars/": "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user