Skip to content

Commit

Permalink
build: remove deps on legacy nodejs rules rollup_bundle internals (#3…
Browse files Browse the repository at this point in the history
…3201)

The legacy nodejs rules rollup_bundle is now deprecated and will be removed in the nodejs rules 1.0 release due in mid-November. This PR brings in the rules_nodejs internal API deps that ng_rollup_bundle, ng_package and ls_rollup_bundle depend on into this repo to break the dependency. In the future these rules should switch to use the new rollup_bundle via a macro as done in #33329 but this is not possible right now due to the complication of having esm5 re-rooted ts_library dependencies.

The es6 sources now have .mjs extensions so they no longer need to be re-rooted to `{package}.es6`. This eliminates the need for the collect_es6_sources() function.

Note: repo has been updated to the newest working version of rollup which is 1.25.2. There is some regression in 1.26.0 which causes the following bundling failure:

```
ERROR: /Users/greg/google/angular/packages/localize/BUILD.bazel:20:1: Optimizing JavaScript packages/localize/localize.umd.min.js [terser] failed (Exit 1) terser.sh failed: error executing command bazel-out/host/bin/external/npm/terser/bin/terser.sh bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.js --output bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.min.js ... (remaining 5 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Parse error at packages/localize/localize.umd.js:491,4
    export * from './src/constants';
    ^
ERROR: Export statement may only appear at top level
    at js_error (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/parse.js:357:11)
    at Dn.visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/scope.js:347:13)
    at Dn._visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1207:24)
    at AST_Export._walk (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:718:17)
    at walk_body (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:168:17)
    at AST_Function.call (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:430:13)
    at descend (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1208:21)
    at Dn.visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/scope.js:256:13)
    at Dn._visit (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:1207:24)
    at AST_Function._walk (/private/var/tmp/_bazel_greg/5e8f8a9cd1c6fbc1afd11e37ee1fe2e5/sandbox/darwin-sandbox/79/execroot/angular/bazel-out/host/bin/external/npm/terser/bin/terser.sh.runfiles/npm/node_modules/terser/lib/ast.js:424:24)
[Function]
Target //packages/localize:npm_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /Users/greg/google/angular/packages/localize/BUILD.bazel:20:1 Optimizing JavaScript packages/localize/localize.umd.min.js [terser] failed (Exit 1) terser.sh failed: error executing command bazel-out/host/bin/external/npm/terser/bin/terser.sh bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.js --output bazel-out/darwin-fastbuild/bin/packages/localize/localize.umd.min.js ... (remaining 5 argument(s) skipped)
```

Will leave that for another day.

Terser also updated to 4.3.3. Updating to 4.3.4 (https://github.com/terser/terser/blob/master/CHANGELOG.md) turns comments preservation on by default which increases the size of the //packages/core/test/bundling/todo:bundle.min.js in CI. After bazelbuild/rules_nodejs#1317 terser can be updated to the latest as passing —comments /a^/ to args can turn off all comments for the //packages/core/test/bundling/todo:bundle.min.js size test.

PR Close #33201
  • Loading branch information
gregmagolan authored and atscott committed Nov 5, 2019
1 parent bf10e98 commit 0addaab
Show file tree
Hide file tree
Showing 24 changed files with 1,332 additions and 671 deletions.
4 changes: 2 additions & 2 deletions integration/bazel/package.json
Expand Up @@ -30,11 +30,11 @@
"@bazel/typescript": "0.39.1",
"@types/jasmine": "2.8.8",
"http-server": "^0.11.1",
"rollup": "^1.21.4",
"rollup": "~1.25.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"terser": "4.3.1",
"terser": "^4.3.9",
"typescript": "3.6.4"
},
"scripts": {
Expand Down
48 changes: 24 additions & 24 deletions integration/bazel/yarn.lock
Expand Up @@ -63,29 +63,29 @@
"@angular/router@file:../../dist/packages-dist/router":
version "9.0.0-next.14"

"@bazel/bazel-darwin_x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.28.1.tgz#415658785e1dbd6f7ab5c8f2b98c1c99c614e1d5"
integrity sha512-VDKWmplAfa4uCAbkIQ5nRn04MFQqtsPNuc2HkluJ8OIum773yC2dPR+OlLBKxrlBuKJYB27TtbOwOa6w/uK7aw==
"@bazel/bazel-darwin_x64@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-1.0.0.tgz#8ab7ecba867130d87e3ecd6cfd5757e59ea274ab"
integrity sha512-2J8qPpUAhSsuZ1P0kMFLvAQUz8zB8mkKmGL3/8raXUnw9TblsykwAdeg3QlJwTLORn+ZqdAjOYEQIarnTpS1NA==

"@bazel/bazel-linux_x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.28.1.tgz#f78006089e17660261088272a0e04fc886572e34"
integrity sha512-n4XfNxagYhejQD32V4XSxT/qzuH1l/2jxslbKSak66/uQ+wad8Ew9rjNb4JUin3xtrfFtzmxx2jpQkybZsRVGA==
"@bazel/bazel-linux_x64@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-1.0.0.tgz#7043cc41eaf7b1d2618766e0759d513873bb9659"
integrity sha512-/ZpOrYyDNGqUyAGPHFr4Y1kn8xCG1G4Lg2VMZtfCZzDohzoYFYs8iyQGU2/8PwldH8XX+oJT9atWqSt1EyoeAw==

"@bazel/bazel-win32_x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.28.1.tgz#60a2819618cf7582cc35ac16c01763a5e807b414"
integrity sha512-T4xksGfKikaHS4zxnGT6r5R436mz9j2lz//L1vc5sJnaEF/1e2Gv6MLl86vfZW2Xxo6iIEi6ntSzgYxP2Blohw==
"@bazel/bazel-win32_x64@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-1.0.0.tgz#1111e4910c155a1917162ae96fd3737d062d20dd"
integrity sha512-p5LpQ/WiijwOS+eBkdD7UewHL8JwK+8gpb4tIKqgh/a2yawgzEQPJDPBUV9ykss5t+s85BL2kEMhduuDewt/MA==

"@bazel/bazel@file:../../node_modules/@bazel/bazel":
version "0.28.1"
version "1.0.0"
dependencies:
"@bazel/hide-bazel-files" latest
optionalDependencies:
"@bazel/bazel-darwin_x64" "0.28.1"
"@bazel/bazel-linux_x64" "0.28.1"
"@bazel/bazel-win32_x64" "0.28.1"
"@bazel/bazel-darwin_x64" "1.0.0"
"@bazel/bazel-linux_x64" "1.0.0"
"@bazel/bazel-win32_x64" "1.0.0"

"@bazel/hide-bazel-files@latest":
version "0.38.3"
Expand Down Expand Up @@ -2867,10 +2867,10 @@ rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.8.1:
dependencies:
estree-walker "^0.6.1"

rollup@^1.21.4:
version "1.26.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.26.0.tgz#cf40fd5e1edc4d7f3d4235a0a43f1c2be1cf294b"
integrity sha512-5HljNYn9icFvXX+Oe97qY5TWvnWhKqgGT0HGeWWqFPx7w7+Anzg7dfHMtUif7YYy6QxAgynDSwK6uxbgcrVUxw==
rollup@~1.25.0:
version "1.25.2"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.25.2.tgz#739f508bd8f7ece52bb6c1fcda83466af82b7f6d"
integrity sha512-+7z6Wab/L45QCPcfpuTZKwKiB0tynj05s/+s2U3F2Bi7rOLPr9UcjUwO7/xpjlPNXA/hwnth6jBExFRGyf3tMg==
dependencies:
"@types/estree" "*"
"@types/node" "*"
Expand Down Expand Up @@ -3296,10 +3296,10 @@ tar@^4:
safe-buffer "^5.1.2"
yallist "^3.0.3"

terser@4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.1.tgz#09820bcb3398299c4b48d9a86aefc65127d0ed65"
integrity sha512-pnzH6dnFEsR2aa2SJaKb1uSCl3QmIsJ8dEkj0Fky+2AwMMcC9doMqLOQIH6wVTEKaVfKVvLSk5qxPBEZT9mywg==
terser@^4.3.9:
version "4.3.9"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.9.tgz#e4be37f80553d02645668727777687dad26bbca8"
integrity sha512-NFGMpHjlzmyOtPL+fDw3G7+6Ueh/sz4mkaUYa4lJCxOPTNzd0Uj0aZJOmsDYoSQyfuVoWDMSWTPU3huyOm2zdA==
dependencies:
commander "^2.20.0"
source-map "~0.6.1"
Expand Down
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -44,6 +44,7 @@
"@bazel/jasmine": "0.39.1",
"@bazel/karma": "0.39.1",
"@bazel/protractor": "0.39.1",
"@bazel/terser": "0.39.1",
"@bazel/typescript": "0.39.1",
"@microsoft/api-extractor": "^7.3.9",
"@schematics/angular": "^8.0.0-beta.15",
Expand Down Expand Up @@ -102,18 +103,17 @@
"nodejs-websocket": "^1.7.2",
"protractor": "^5.4.2",
"reflect-metadata": "^0.1.3",
"rollup": "^1.1.0",
"rollup-plugin-amd": "^3.0.0",
"rollup-plugin-commonjs": "^9.2.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup": "~1.25.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rxjs": "^6.5.3",
"selenium-webdriver": "3.5.0",
"shelljs": "^0.8.1",
"source-map": "^0.6.1",
"source-map-support": "0.5.9",
"systemjs": "0.18.10",
"terser": "4.3.3",
"tsickle": "0.37.0",
"tslib": "^1.10.0",
"tslint": "5.7.0",
Expand Down
1 change: 0 additions & 1 deletion packages/bazel/docs/BUILD.bazel
Expand Up @@ -4,7 +4,6 @@ skylark_doc(
name = "docs",
srcs = [
"//packages/bazel/src:ng_module.bzl",
"//packages/bazel/src:ng_rollup_bundle.bzl",
"//packages/bazel/src/ng_package:ng_package.bzl",
],
format = "html",
Expand Down
11 changes: 6 additions & 5 deletions packages/bazel/package.json
Expand Up @@ -33,10 +33,11 @@
"peerDependencies": {
"@angular/compiler-cli": "0.0.0-PLACEHOLDER",
"@bazel/typescript": "0.*",
"typescript": ">=3.6 <3.7"
},
"devDependencies": {

"typescript": ">=3.6 <3.7",
"rollup": ">=1.20.0",
"rollup-plugin-commonjs": ">=9.0.0",
"rollup-plugin-node-resolve": ">=4.2.0",
"rollup-plugin-sourcemaps": ">=0.4.0"
},
"repository": {
"type": "git",
Expand All @@ -47,4 +48,4 @@
"ng-update": {
"packageGroup": "NG_UPDATE_PACKAGE_GROUP"
}
}
}
17 changes: 0 additions & 17 deletions packages/bazel/src/BUILD.bazel
Expand Up @@ -10,23 +10,6 @@ exports_files(glob(["*.bzl"]))

load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")

nodejs_binary(
name = "rollup_with_build_optimizer",
data = [
"@npm//@angular-devkit/build-optimizer",
"@npm//is-builtin-module",
"@npm//rollup",
"@npm//rollup-plugin-amd",
"@npm//rollup-plugin-commonjs",
"@npm//rollup-plugin-json",
"@npm//rollup-plugin-node-resolve",
"@npm//rollup-plugin-sourcemaps",
],
entry_point = "@npm//:node_modules/rollup/bin/rollup",
install_source_map_support = False,
visibility = ["//visibility:public"],
)

filegroup(
name = "empty_node_modules",
srcs = [],
Expand Down
24 changes: 22 additions & 2 deletions packages/bazel/src/ng_package/BUILD.bazel
Expand Up @@ -27,9 +27,29 @@ nodejs_binary(
install_source_map_support = False,
)

exports_files(["ng_package.bzl"])
nodejs_binary(
name = "rollup_for_ng_package",
data = [
"@npm//rollup",
"@npm//rollup-plugin-commonjs",
"@npm//rollup-plugin-node-resolve",
"@npm//rollup-plugin-sourcemaps",
],
entry_point = "@npm//:node_modules/rollup/dist/bin/rollup",
install_source_map_support = False,
)

exports_files([
"ng_package.bzl",
"rollup.config.js",
"terser_config.default.json",
])

filegroup(
name = "package_assets",
srcs = glob(["*.bzl"]) + ["BUILD.bazel"],
srcs = glob(["*.bzl"]) + [
"BUILD.bazel",
"rollup.config.js",
"terser_config.default.json",
],
)

0 comments on commit 0addaab

Please sign in to comment.