refactor: update packages/bazel npm artifact to not rely on defaults.bzl (#48538)

Fixes that we temporarily broke the Bazel npm package artifact as
part of the ESM work. This commit adjusts it and also makes the
artifact subsitutions more maintainable.

PR Close #48538
This commit is contained in:
Paul Gschwendtner
2022-12-17 10:32:29 +00:00
parent e523d2785e
commit cbb9183ed4
5 changed files with 35 additions and 43 deletions
+4 -4
View File
@@ -8,10 +8,10 @@
"node": "^14.20.0 || ^16.13.0 || >=18.10.0"
},
"bin": {
"ngc-wrapped": "./src/ngc-wrapped/index.js",
"packager": "./src/ng_package/packager.js",
"types_bundler": "./src/types_bundle/index.js",
"xi18n": "./src/ngc-wrapped/extract_i18n.js"
"ngc-wrapped": "./src/ngc-wrapped/index.mjs",
"packager": "./src/ng_package/packager.mjs",
"types_bundler": "./src/types_bundle/index.mjs",
"xi18n": "./src/ngc-wrapped/extract_i18n.mjs"
},
"typings": "./src/ngc-wrapped/index.d.ts",
"bazelBin": {
+2 -36
View File
@@ -1,48 +1,13 @@
# BEGIN-DEV-ONLY
load("//tools:defaults.bzl", "nodejs_binary", "ts_library")
package(default_visibility = ["//visibility:public"])
nodejs_binary(
name = "rollup_for_ng_package",
data = [
# BEGIN-DEV-ONLY
"@npm" +
# END-DEV-ONLY
"//rollup",
# BEGIN-DEV-ONLY
"@npm" +
# END-DEV-ONLY
"//@rollup/plugin-commonjs",
# BEGIN-DEV-ONLY
"@npm" +
# END-DEV-ONLY
"//@rollup/plugin-node-resolve",
# BEGIN-DEV-ONLY
"@npm" +
# END-DEV-ONLY
"//rollup-plugin-sourcemaps",
# BEGIN-DEV-ONLY
"@npm" +
# END-DEV-ONLY
"//typescript",
],
entry_point = (
# BEGIN-DEV-ONLY
"@npm" +
# END-DEV-ONLY
"//:node_modules/rollup/dist/bin/rollup"
),
# Disable the linker and rely on patched resolution which works better on Windows
# and is less prone to race conditions when targets build concurrently.
templated_args = ["--nobazel_run_linker"],
)
exports_files([
"ng_package.bzl",
"rollup.config.js",
])
# BEGIN-DEV-ONLY
ts_library(
name = "lib",
srcs = glob(["*.ts"]),
@@ -55,6 +20,7 @@ ts_library(
filegroup(
name = "package_assets",
srcs = glob(["*.bzl"]) + [
"//packages/bazel/src/ng_package/rollup:package_assets",
"BUILD.bazel",
"rollup.config.js",
],
+2 -2
View File
@@ -32,7 +32,7 @@ def _debug(vars, *args):
_DEFAULT_NG_PACKAGER = "//@angular/bazel/bin:packager"
_DEFAULT_ROLLUP_CONFIG_TMPL = "//:node_modules/@angular/bazel/src/ng_package/rollup.config.js"
_DEFAULT_ROLLUP = "//@angular/bazel/src/ng_package:rollup_for_ng_package"
_DEFAULT_ROLLUP = "//@angular/bazel/src/ng_package/rollup"
_NG_PACKAGE_MODULE_MAPPINGS_ATTR = "ng_package_module_mappings"
@@ -112,7 +112,7 @@ def _compute_node_modules_root(ctx):
"""Computes the node_modules root from the node_modules and deps attributes.
Args:
ctx: the skylark execution context
ctx: the starlark execution context
Returns:
The node_modules root as a string
@@ -0,0 +1,26 @@
# Note: This file is shipped to NPM. It cannot use the `defaults.bzl` macro.
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
package(default_visibility = ["//visibility:public"])
filegroup(
name = "package_assets",
srcs = ["BUILD.bazel"],
)
nodejs_binary(
name = "rollup",
data = [
"@npm//@rollup/plugin-commonjs",
"@npm//@rollup/plugin-node-resolve",
"@npm//rollup",
"@npm//rollup-plugin-sourcemaps",
"@npm//typescript",
],
entry_point = (
"@npm//:node_modules/rollup/dist/bin/rollup"
),
# Disable the linker and rely on patched resolution which works better on Windows
# and is less prone to race conditions when targets build concurrently.
templated_args = ["--nobazel_run_linker"],
)
+1 -1
View File
@@ -26,7 +26,7 @@ _INTERNAL_NG_MODULE_COMPILER = "//packages/bazel/src/ngc-wrapped"
_INTERNAL_NG_MODULE_XI18N = "//packages/bazel/src/ngc-wrapped:xi18n"
_INTERNAL_NG_PACKAGE_PACKAGER = "//packages/bazel/src/ng_package:packager"
_INTERNAL_NG_PACKAGE_DEFAULT_ROLLUP_CONFIG_TMPL = "//packages/bazel/src/ng_package:rollup.config.js"
_INTERNAL_NG_PACKAGE_DEFAULT_ROLLUP = "//packages/bazel/src/ng_package:rollup_for_ng_package"
_INTERNAL_NG_PACKAGE_DEFAULT_ROLLUP = "//packages/bazel/src/ng_package/rollup"
esbuild_config = _esbuild_config
http_server = _http_server