Skip to content

Commit

Permalink
revert: build: update to nodejs rules 0.27 (angular#29210)
Browse files Browse the repository at this point in the history
This reverts commit 08231f0.
  • Loading branch information
matsko committed Mar 15, 2019
1 parent 8ed13a3 commit b2aadff
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 104 deletions.
7 changes: 4 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ 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 = "251a023b6c5c5c97db1bfe24652dc19dad05f4da68f8e1821d92d911fa3f4ef4",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.27.4/rules_nodejs-0.27.4.tar.gz"],
sha256 = "5c86b055c57e15bf32d9009a15bcd6d8e190c41b1ff2fb18037b75e0012e4e7c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.26.0/rules_nodejs-0.26.0.tar.gz"],
)

# Check the bazel version and download npm dependencies
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "check_rules_nodejs_version", "node_repositories", "yarn_install")
load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_repositories", "yarn_install")
load("@build_bazel_rules_nodejs//:package.bzl", "check_rules_nodejs_version")

# Bazel version must be at least v0.21.0 because:
# - 0.21.0 Using --incompatible_strict_action_env flag fixes cache when running `yarn bazel`
Expand Down
4 changes: 2 additions & 2 deletions integration/bazel/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,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 = "251a023b6c5c5c97db1bfe24652dc19dad05f4da68f8e1821d92d911fa3f4ef4",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.27.4/rules_nodejs-0.27.4.tar.gz"],
sha256 = "5c86b055c57e15bf32d9009a15bcd6d8e190c41b1ff2fb18037b75e0012e4e7c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.26.0/rules_nodejs-0.26.0.tar.gz"],
)

# Fetch sass rules for compiling sass files
Expand Down
2 changes: 1 addition & 1 deletion integration/bazel/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@angular/bazel": "packages-dist:bazel",
"@angular/compiler": "packages-dist:compiler",
"@angular/compiler-cli": "packages-dist:compiler-cli",
"@bazel/karma": "0.27.4",
"@bazel/karma": "0.26.0",
"@types/jasmine": "2.8.8",
"@types/source-map": "0.5.1",
"protractor": "5.1.2",
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"@angular-devkit/core": "^7.3.2",
"@angular-devkit/schematics": "^7.3.2",
"@angular/bazel": "file:./tools/npm/@angular_bazel",
"@bazel/jasmine": "0.27.4",
"@bazel/karma": "0.27.4",
"@bazel/typescript": "0.27.4",
"@bazel/jasmine": "0.26.0",
"@bazel/karma": "0.26.0",
"@bazel/typescript": "0.26.0",
"@microsoft/api-extractor": "^7.0.21",
"@schematics/angular": "^7.3.5",
"@types/angular": "^1.6.47",
Expand Down Expand Up @@ -86,7 +86,6 @@
"protractor": "^5.4.2",
"reflect-metadata": "^0.1.3",
"rollup": "^1.1.0",
"rollup-plugin-commonjs": "^9.2.1",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rxjs": "^6.4.0",
Expand Down Expand Up @@ -143,6 +142,7 @@
"madge": "0.5.0",
"mutation-observer": "^1.0.3",
"rewire": "2.5.2",
"rollup-plugin-commonjs": "8.1.0",
"sauce-connect": "https://saucelabs.com/downloads/sc-4.5.1-linux.tar.gz",
"semver": "5.4.1",
"tslint-eslint-rules": "4.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/bazel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@angular-devkit/architect": "^0.13.4",
"@angular-devkit/core": "^7.0.4",
"@angular-devkit/schematics": "^7.3.0-rc.0",
"@bazel/typescript": "^0.27.4",
"@bazel/typescript": "^0.26.0",
"@microsoft/api-extractor": "^7.0.21",
"@schematics/angular": "^7.3.5",
"@types/node": "6.0.84",
Expand Down
1 change: 0 additions & 1 deletion packages/bazel/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ nodejs_binary(
"@npm//@angular-devkit/build-optimizer",
"@npm//is-builtin-module",
"@npm//rollup",
"@npm//rollup-plugin-commonjs",
"@npm//rollup-plugin-node-resolve",
"@npm//rollup-plugin-sourcemaps",
],
Expand Down
4 changes: 2 additions & 2 deletions packages/bazel/src/builders/files/WORKSPACE.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ workspace(name = "project")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_NODEJS_VERSION = "0.27.4"
RULES_NODEJS_VERSION = "0.26.0"
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "251a023b6c5c5c97db1bfe24652dc19dad05f4da68f8e1821d92d911fa3f4ef4",
sha256 = "5c86b055c57e15bf32d9009a15bcd6d8e190c41b1ff2fb18037b75e0012e4e7c",
url = "https://github.com/bazelbuild/rules_nodejs/releases/download/%s/rules_nodejs-%s.tar.gz" % (RULES_NODEJS_VERSION, RULES_NODEJS_VERSION),
)

Expand Down
11 changes: 8 additions & 3 deletions packages/bazel/src/ng_package/ng_package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load(
"@build_bazel_rules_nodejs//:internal/rollup/rollup_bundle.bzl",
"ROLLUP_ATTRS",
"ROLLUP_DEPS_ASPECTS",
"run_terser",
"run_uglify",
"write_rollup_config",
)
load(
Expand Down Expand Up @@ -309,13 +309,13 @@ def _ng_package_impl(ctx):
include_tslib = True,
),
)
terser_sourcemap = run_terser(
uglify_sourcemap = run_uglify(
ctx,
umd_output,
min_output,
config_name = entry_point.replace("/", "_"),
)
bundles.append(struct(js = min_output, map = terser_sourcemap))
bundles.append(struct(js = min_output, map = uglify_sourcemap))

packager_inputs = (
ctx.files.srcs +
Expand Down Expand Up @@ -433,6 +433,11 @@ NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **dict(ROLLUP_ATTRS, **{
default = Label("@build_bazel_rules_nodejs//internal/rollup:rollup.config.js"),
allow_single_file = True,
),
"_uglify": attr.label(
default = Label("@build_bazel_rules_nodejs//internal/rollup:uglify"),
executable = True,
cfg = "host",
),
}))

# Angular wants these named after the entry_point,
Expand Down
39 changes: 9 additions & 30 deletions packages/bazel/src/ng_rollup_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ load(
"ROLLUP_OUTPUTS",
"run_rollup",
"run_sourcemapexplorer",
"run_terser",
"run_uglify",
"write_rollup_config",
)
load("@build_bazel_rules_nodejs//internal/common:collect_es6_sources.bzl", collect_es2015_sources = "collect_es6_sources")
Expand Down Expand Up @@ -101,12 +101,10 @@ def _run_tsc(ctx, input, output):
# Borrowed from bazelbuild/rules_nodejs, with the addition of brotli compression output
def _plain_rollup_bundle(ctx):
rollup_config = write_rollup_config(ctx)
run_rollup(ctx, collect_es2015_sources(ctx), rollup_config, ctx.outputs.build_es2015)
run_terser(ctx, ctx.outputs.build_es2015, ctx.outputs.build_es2015_min, config_name = ctx.label.name + "es2015_min")
run_terser(ctx, ctx.outputs.build_es2015, ctx.outputs.build_es2015_min_debug, debug = True, config_name = ctx.label.name + "es2015_min_debug")
_run_tsc(ctx, ctx.outputs.build_es2015, ctx.outputs.build_es5)
source_map = run_terser(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min)
run_terser(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min_debug, debug = True)
run_rollup(ctx, collect_es2015_sources(ctx), rollup_config, ctx.outputs.build_es6)
_run_tsc(ctx, ctx.outputs.build_es6, ctx.outputs.build_es5)
source_map = run_uglify(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min)
run_uglify(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min_debug, debug = True)
umd_rollup_config = write_rollup_config(ctx, filename = "_%s_umd.rollup.conf.js", output_format = "umd")
run_rollup(ctx, collect_es2015_sources(ctx), umd_rollup_config, ctx.outputs.build_umd)
cjs_rollup_config = write_rollup_config(ctx, filename = "_%s_cjs.rollup.conf.js", output_format = "cjs")
Expand All @@ -125,44 +123,25 @@ def _ng_rollup_bundle(ctx):
# We don't expect anyone to make use of this bundle yet, but it makes this rule
# compatible with rollup_bundle which allows them to be easily swapped back and
# forth.
esm2015_rollup_config = write_rollup_config(ctx, filename = "_%s.rollup_es2015.conf.js")
esm2015_rollup_sourcemap = run_rollup(ctx, collect_es2015_sources(ctx), esm2015_rollup_config, ctx.outputs.build_es2015)

run_terser(
ctx,
ctx.outputs.build_es2015,
ctx.outputs.build_es2015_min,
config_name = ctx.label.name + "es2015_min",
comments = False,
in_source_map = esm2015_rollup_sourcemap,
)
run_terser(
ctx,
ctx.outputs.build_es2015,
ctx.outputs.build_es2015_min_debug,
config_name = ctx.label.name + "es2015_min_debug",
debug = True,
comments = False,
)
esm2015_rollup_config = write_rollup_config(ctx, filename = "_%s.rollup_es6.conf.js")
run_rollup(ctx, collect_es2015_sources(ctx), esm2015_rollup_config, ctx.outputs.build_es6)

esm5_sources = flatten_esm5(ctx)

rollup_config = write_rollup_config(ctx, [BO_PLUGIN], "/".join([ctx.bin_dir.path, ctx.label.package, esm5_root_dir(ctx)]))
rollup_sourcemap = run_rollup(ctx, esm5_sources, rollup_config, ctx.outputs.build_es5)

sourcemap = run_terser(
sourcemap = run_uglify(
ctx,
ctx.outputs.build_es5,
ctx.outputs.build_es5_min,
config_name = ctx.label.name + "es5_min",
comments = False,
in_source_map = rollup_sourcemap,
)
run_terser(
run_uglify(
ctx,
ctx.outputs.build_es5,
ctx.outputs.build_es5_min_debug,
config_name = ctx.label.name + "es5_min_debug",
debug = True,
comments = False,
)
Expand Down
2 changes: 1 addition & 1 deletion packages/bazel/src/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function addDevDependenciesToPackageJson(options: Schema) {
'@angular/upgrade': angularCoreVersion,
'@bazel/bazel': '^0.23.0',
'@bazel/ibazel': '^0.9.0',
'@bazel/karma': '^0.27.4',
'@bazel/karma': '^0.26.0',
};

const recorder = host.beginUpdate(packageJson);
Expand Down
4 changes: 2 additions & 2 deletions packages/language-service/bundles/rollup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ load(
"ROLLUP_ATTRS",
"ROLLUP_DEPS_ASPECTS",
"run_rollup",
"run_terser",
"run_uglify",
"write_rollup_config",
)
load("//packages/bazel/src:esm5.bzl", "esm5_outputs_aspect", "esm5_root_dir", "flatten_esm5")
Expand All @@ -41,7 +41,7 @@ def _ls_rollup_bundle(ctx):
output_format = "amd",
)
run_rollup(ctx, esm5_sources, rollup_config, ctx.outputs.build_umd)
source_map = run_terser(ctx, ctx.outputs.build_umd, ctx.outputs.build_umd_min)
source_map = run_uglify(ctx, ctx.outputs.build_umd, ctx.outputs.build_umd_min)
return DefaultInfo(files = depset([ctx.outputs.build_umd, ctx.outputs.build_umd_min, source_map]))

ls_rollup_bundle = rule(
Expand Down
2 changes: 1 addition & 1 deletion packages/service-worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ genrule(

genrule(
name = "ngsw_worker_renamed",
srcs = ["//packages/service-worker/worker:ngsw_worker.es2015.js"],
srcs = ["//packages/service-worker/worker:ngsw_worker.es6.js"],
outs = ["ngsw-worker.js"],
# Remove sourcemap since this file will be served in production site
# See https://github.com/angular/angular/issues/23596
Expand Down
Loading

0 comments on commit b2aadff

Please sign in to comment.