Skip to content

Commit b9251fd

Browse files
alexeaglebenlesh
authored andcommitted
build: Remove cc_binary dependency on brotli (angular#29912)
Just use the JavaScript port instead. We don't care about speed since we compress once as a build step. PR Close angular#29912
1 parent c0ec1d6 commit b9251fd

File tree

7 files changed

+42
-11
lines changed

7 files changed

+42
-11
lines changed

BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
2-
31
package(default_visibility = ["//visibility:public"])
42

53
load("//tools:defaults.bzl", "karma_web_test")

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"angular-mocks-1.5": "npm:angular-mocks@1.5",
6767
"angular-mocks-1.6": "npm:angular-mocks@1.6",
6868
"base64-js": "1.2.1",
69+
"brotli": "^1.3.2",
6970
"canonical-path": "1.0.0",
7071
"chai": "^4.1.2",
7172
"chalk": "^2.3.1",

packages/bazel/package.bzl

-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ def rules_angular_dev_dependencies():
2424
shorter.
2525
"""
2626

27-
http_archive(
28-
name = "org_brotli",
29-
sha256 = "774b893a0700b0692a76e2e5b7e7610dbbe330ffbe3fe864b4b52ca718061d5a",
30-
strip_prefix = "brotli-1.0.5",
31-
url = "https://github.com/google/brotli/archive/v1.0.5.zip",
32-
)
33-
3427
# Needed for Remote Execution
3528
_maybe(
3629
http_archive,

packages/bazel/src/ng_rollup_bundle.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ ng_rollup_bundle = rule(
194194
"_brotli": attr.label(
195195
executable = True,
196196
cfg = "host",
197-
default = Label("@org_brotli//:brotli"),
197+
default = Label("//tools/brotli-cli"),
198198
),
199199
"_rollup": attr.label(
200200
executable = True,

tools/brotli-cli/BUILD.bazel

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
2+
3+
nodejs_binary(
4+
name = "brotli-cli",
5+
data = [
6+
"cli.js",
7+
"@npm//brotli",
8+
],
9+
entry_point = "angular/tools/brotli-cli/cli.js",
10+
visibility = ["//:__subpackages__"],
11+
)

tools/brotli-cli/cli.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
const fs = require('fs');
10+
const compress = require('brotli/compress');
11+
12+
function main(args) {
13+
const output = args[0].substring('--output='.length);
14+
const input = args[1];
15+
const buffer = fs.readFileSync(input);
16+
fs.writeFileSync(output, compress(buffer, {mode: 0, quality: 11}));
17+
}
18+
19+
if (require.main === module) {
20+
main(process.argv.slice(2));
21+
}

yarn.lock

+8-1
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ base64-js@1.2.1:
13211321
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886"
13221322
integrity sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==
13231323

1324-
base64-js@^1.0.2:
1324+
base64-js@^1.0.2, base64-js@^1.1.2:
13251325
version "1.3.0"
13261326
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3"
13271327
integrity sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==
@@ -1558,6 +1558,13 @@ braces@^2.3.0, braces@^2.3.1, braces@^2.3.2:
15581558
split-string "^3.0.2"
15591559
to-regex "^3.0.1"
15601560

1561+
brotli@^1.3.2:
1562+
version "1.3.2"
1563+
resolved "https://registry.yarnpkg.com/brotli/-/brotli-1.3.2.tgz#525a9cad4fcba96475d7d388f6aecb13eed52f46"
1564+
integrity sha1-UlqcrU/LqWR119OI9q7LE+7VL0Y=
1565+
dependencies:
1566+
base64-js "^1.1.2"
1567+
15611568
browserify-zlib@~0.1.4:
15621569
version "0.1.4"
15631570
resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.1.4.tgz#bb35f8a519f600e0fa6b8485241c979d0141fb2d"

0 commit comments

Comments
 (0)