Skip to content

Commit

Permalink
Revert "build: upgrade to rules_nodejs 1.0.0 (first stable release) (a…
Browse files Browse the repository at this point in the history
…ngular#34589)" (angular#34730)

This reverts commit cb6ffa1.

PR Close angular#34730
  • Loading branch information
atscott committed Jan 10, 2020
1 parent aa02447 commit e88d652
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 81 deletions.
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Fetch rules_nodejs so we can install our npm dependencies
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "3887b948779431ac443e6a64f31b9e1e17b8d386a31eebc50ec1d9b0a6cabd2b",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.0.0/rules_nodejs-1.0.0.tar.gz"],
sha256 = "16fc00ab0d1e538e88f084272316c0693a2e9007d64f45529b82f6230aedb073",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.42.2/rules_nodejs-0.42.2.tar.gz"],
)

# Check the bazel version and download npm dependencies
Expand All @@ -29,7 +29,7 @@ Try running `yarn bazel` instead.
minimum_bazel_version = "1.1.0",
)

check_rules_nodejs_version(minimum_version_string = "1.0.0")
check_rules_nodejs_version(minimum_version_string = "0.42.1")

# Setup the Node.js toolchain
node_repositories(
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
"@angular-devkit/schematics": "^9.0.0-rc.3",
"@angular/bazel": "file:./tools/npm/@angular_bazel",
"@babel/core": "^7.6.4",
"@bazel/jasmine": "1.0.0",
"@bazel/karma": "1.0.0",
"@bazel/protractor": "1.0.0",
"@bazel/rollup": "1.0.0",
"@bazel/terser": "1.0.0",
"@bazel/typescript": "1.0.0",
"@bazel/jasmine": "0.42.2",
"@bazel/karma": "0.42.2",
"@bazel/protractor": "0.42.2",
"@bazel/rollup": "0.42.2",
"@bazel/terser": "0.42.2",
"@bazel/typescript": "0.42.2",
"@microsoft/api-extractor": "^7.3.9",
"@schematics/angular": "^9.0.0-rc.3",
"@types/angular": "^1.6.47",
Expand Down
8 changes: 4 additions & 4 deletions packages/bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//tools:defaults.bzl", "pkg_npm")
load("//tools:defaults.bzl", "npm_package")

pkg_npm(
npm_package(
name = "npm_package",
srcs = glob(
["*"],
Expand All @@ -14,10 +14,10 @@ pkg_npm(
"//packages/bazel/src/schematics:package_assets",
"//packages/bazel/third_party/github.com/bazelbuild/bazel/src/main/protobuf:package_assets",
],
nested_packages = [
packages = [
"//packages/bazel/docs",
],
substitutions = {
replacements = {
"(#|\/\/)\\s+BEGIN-DEV-ONLY[\\w\W]+?(#|\/\/)\\s+END-DEV-ONLY": "",
"//packages/bazel/": "//",
"angular/packages/bazel/": "npm_angular_bazel/",
Expand Down
16 changes: 8 additions & 8 deletions packages/bazel/src/ng_package/ng_package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ specification of this format at https://goo.gl/jB3GVv

load("@build_bazel_rules_nodejs//:providers.bzl", "JSEcmaScriptModuleInfo", "JSNamedModuleInfo", "NpmPackageInfo", "node_modules_aspect")
load(
"@build_bazel_rules_nodejs//internal/pkg_npm:pkg_npm.bzl",
"PKG_NPM_ATTRS",
"PKG_NPM_OUTPUTS",
"@build_bazel_rules_nodejs//internal/npm_package:npm_package.bzl",
"NPM_PACKAGE_ATTRS",
"NPM_PACKAGE_OUTPUTS",
"create_package",
)
load("//packages/bazel/src:external.bzl", "FLAT_DTS_FILE_SUFFIX")
Expand Down Expand Up @@ -623,15 +623,15 @@ def _ng_package_impl(ctx):
package_dir = create_package(
ctx,
devfiles.to_list(),
[npm_package_directory] + ctx.files.nested_packages,
[npm_package_directory] + ctx.files.packages,
)
return [DefaultInfo(
files = depset([package_dir]),
)]

_NG_PACKAGE_DEPS_ASPECTS = [esm5_outputs_aspect, ng_package_module_mappings_aspect, node_modules_aspect]

_NG_PACKAGE_ATTRS = dict(PKG_NPM_ATTRS, **{
_NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **{
"srcs": attr.label_list(
doc = """JavaScript source files from the workspace.
These can use ES2015 syntax and ES Modules (import/export)""",
Expand Down Expand Up @@ -807,12 +807,12 @@ def _ng_package_outputs(name, entry_point, entry_point_name):
"umd": "%s.umd.js" % basename,
"umd_min": "%s.umd.min.js" % basename,
}
for key in PKG_NPM_OUTPUTS:
# PKG_NPM_OUTPUTS is a "normal" dict-valued outputs so it looks like
for key in NPM_PACKAGE_OUTPUTS:
# NPM_PACKAGE_OUTPUTS is a "normal" dict-valued outputs so it looks like
# "pack": "%{name}.pack",
# But this is a function-valued outputs.
# Bazel won't replace the %{name} token so we have to do it.
outputs[key] = PKG_NPM_OUTPUTS[key].replace("%{name}", name)
outputs[key] = NPM_PACKAGE_OUTPUTS[key].replace("%{name}", name)
return outputs

ng_package = rule(
Expand Down
6 changes: 3 additions & 3 deletions packages/bazel/test/ng_package/example/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "ng_module", "ng_package", "pkg_npm")
load("//tools:defaults.bzl", "ng_module", "ng_package", "npm_package")

package(default_visibility = ["//packages/bazel/test:__subpackages__"])

Expand Down Expand Up @@ -26,7 +26,7 @@ ng_package(
],
entry_point = ":index.ts",
entry_point_name = "waffels",
nested_packages = [
packages = [
":arbitrary_npm_package",
],
deps = [
Expand All @@ -52,7 +52,7 @@ genrule(
output_to_bindir = True,
)

pkg_npm(
npm_package(
name = "arbitrary_npm_package",
srcs = [":arbitrary-npm-package-main.js"],
)
4 changes: 2 additions & 2 deletions packages/benchpress/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:defaults.bzl", "npm_package", "ts_library")

package(default_visibility = ["//visibility:public"])

Expand All @@ -18,7 +18,7 @@ ts_library(
],
)

pkg_npm(
npm_package(
name = "npm_package",
srcs = [
"README.md",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ng_package(
"//packages/common/upgrade:package.json",
],
entry_point = ":index.ts",
nested_packages = ["//packages/common/locales:package"],
packages = ["//packages/common/locales:package"],
tags = [
"release-with-framework",
],
Expand Down
7 changes: 4 additions & 3 deletions packages/common/locales/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:defaults.bzl", "npm_package", "ts_library")

package(default_visibility = ["//visibility:public"])

Expand All @@ -10,10 +10,11 @@ ts_library(
),
)

pkg_npm(
npm_package(
name = "package",
srcs = glob(["global/*.js"]) + ["package.json"],
substitutions = {
replacements = {

# Workaround for `.d.ts`` containing `/// <amd-module .../>`
# which are generated in TypeScript v2.9, but not before.
"/// <amd-module name=.*/>": "",
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler-cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:defaults.bzl", "npm_package", "ts_library")
load("@npm_bazel_typescript//:index.bzl", "ts_config")

ts_config(
Expand Down Expand Up @@ -53,7 +53,7 @@ ts_library(
],
)

pkg_npm(
npm_package(
name = "npm_package",
srcs = [
"package.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ng_package(
"//packages/core/testing:package.json",
],
entry_point = ":index.ts",
nested_packages = [
packages = [
"//packages/core/schematics:npm_package",
],
tags = [
Expand Down
4 changes: 2 additions & 2 deletions packages/core/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
load("//tools:defaults.bzl", "pkg_npm")
load("//tools:defaults.bzl", "npm_package")

exports_files([
"tsconfig.json",
"migrations.json",
])

pkg_npm(
npm_package(
name = "npm_package",
srcs = ["migrations.json"],
visibility = ["//packages/core:__pkg__"],
Expand Down
2 changes: 1 addition & 1 deletion packages/elements/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ng_package(
"**/package.json",
]),
entry_point = ":index.ts",
nested_packages = [
packages = [
"//packages/elements/schematics:npm_package",
],
tags = [
Expand Down
4 changes: 2 additions & 2 deletions packages/elements/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "pkg_npm")
load("//tools:defaults.bzl", "npm_package")

package(default_visibility = ["//visibility:public"])

Expand All @@ -15,7 +15,7 @@ genrule(
output_to_bindir = 1,
)

pkg_npm(
npm_package(
name = "npm_package",
srcs = [
"collection.json",
Expand Down
4 changes: 2 additions & 2 deletions packages/language-service/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:defaults.bzl", "npm_package", "ts_library")

package(default_visibility = ["//visibility:public"])

Expand All @@ -20,7 +20,7 @@ ts_library(
],
)

pkg_npm(
npm_package(
name = "npm_package",
srcs = ["package.json"],
tags = [
Expand Down
2 changes: 1 addition & 1 deletion packages/localize/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ng_package(
"//packages/localize/init:package.json",
],
entry_point = ":index.ts",
nested_packages = [
packages = [
"//packages/localize/schematics:npm_package",
"//packages/localize/src/tools:npm_package",
],
Expand Down
4 changes: 2 additions & 2 deletions packages/localize/schematics/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//tools:defaults.bzl", "pkg_npm")
load("//tools:defaults.bzl", "npm_package")

package(default_visibility = ["//visibility:public"])

Expand All @@ -10,7 +10,7 @@ filegroup(
visibility = ["//packages/localize:__subpackages__"],
)

pkg_npm(
npm_package(
name = "npm_package",
srcs = [
"collection.json",
Expand Down
4 changes: 2 additions & 2 deletions packages/localize/src/tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "pkg_npm", "ts_library")
load("//tools:defaults.bzl", "npm_package", "ts_library")
load("@npm_bazel_typescript//:index.bzl", "ts_config")

ts_config(
Expand Down Expand Up @@ -30,7 +30,7 @@ ts_library(
],
)

pkg_npm(
npm_package(
name = "npm_package",
srcs = [
],
Expand Down
4 changes: 2 additions & 2 deletions packages/zone.js/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("@build_bazel_rules_nodejs//:index.bzl", "npm_package")
load("//packages/zone.js:bundles.bzl", "ES2015_BUNDLES", "ES5_BUNDLES", "ES5_GLOBAL_BUNDLES")

exports_files([
Expand All @@ -21,7 +21,7 @@ genrule(
cmd = "(echo '/**\n @license' && cat $< && echo '*/') > $@",
)

pkg_npm(
npm_package(
name = "npm_package",
srcs = [
"CHANGELOG.md",
Expand Down
8 changes: 4 additions & 4 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,19 @@ def ng_package(name, readme_md = None, license_banner = None, deps = [], **kwarg
deps = deps,
readme_md = readme_md,
license_banner = license_banner,
substitutions = PKG_GROUP_REPLACEMENTS,
replacements = PKG_GROUP_REPLACEMENTS,
ng_packager = _INTERNAL_NG_PACKAGE_PACKAGER,
terser_config_file = _INTERNAL_NG_PACKAGE_DEFALUT_TERSER_CONFIG_FILE,
rollup_config_tmpl = _INTERNAL_NG_PACKAGE_DEFAULT_ROLLUP_CONFIG_TMPL,
rollup = _INTERNAL_NG_PACKAGE_DEFAULT_ROLLUP,
**kwargs
)

def pkg_npm(name, substitutions = {}, **kwargs):
def npm_package(name, replacements = {}, **kwargs):
"""Default values for npm_package"""
_pkg_npm(
_npm_package(
name = name,
substitutions = dict(substitutions, **PKG_GROUP_REPLACEMENTS),
replacements = dict(replacements, **PKG_GROUP_REPLACEMENTS),
**kwargs
)

Expand Down
6 changes: 3 additions & 3 deletions tools/ts-api-guardian/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BEGIN-INTERNAL
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("@build_bazel_rules_nodejs//:index.bzl", "npm_package")
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
load("@npm_bazel_typescript//:index.bzl", "ts_library")

Expand Down Expand Up @@ -29,7 +29,7 @@ genrule(
cmd = "cp $< $@",
)

pkg_npm(
npm_package(
name = "ts-api-guardian",
srcs = [
"BUILD.bazel",
Expand All @@ -38,7 +38,7 @@ pkg_npm(
"index.bzl",
"package.json",
],
substitutions = {
replacements = {
"@angular//tools/ts-api-guardian:bin": "@npm_ts_api_guardian//:bin",
"@angular//tools/ts-api-guardian:lib": "@npm//ts-api-guardian",
"angular/tools/ts-api-guardian/": "npm_ts_api_guardian/",
Expand Down
Loading

0 comments on commit e88d652

Please sign in to comment.