diff --git a/BUILD.bazel b/BUILD.bazel index 0ade4f4beb..58ce9abd32 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,5 +1,3 @@ -load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") - package(default_visibility = ["//visibility:public"]) load("//tools:defaults.bzl", "karma_web_test") diff --git a/package.json b/package.json index 02505ee90e..fa9d196c7a 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "angular-mocks-1.5": "npm:angular-mocks@1.5", "angular-mocks-1.6": "npm:angular-mocks@1.6", "base64-js": "1.2.1", + "brotli": "^1.3.2", "canonical-path": "1.0.0", "chai": "^4.1.2", "chalk": "^2.3.1", diff --git a/packages/bazel/package.bzl b/packages/bazel/package.bzl index 043a56f5e4..a8a3812a0f 100644 --- a/packages/bazel/package.bzl +++ b/packages/bazel/package.bzl @@ -24,13 +24,6 @@ def rules_angular_dev_dependencies(): shorter. """ - http_archive( - name = "org_brotli", - sha256 = "774b893a0700b0692a76e2e5b7e7610dbbe330ffbe3fe864b4b52ca718061d5a", - strip_prefix = "brotli-1.0.5", - url = "https://github.com/google/brotli/archive/v1.0.5.zip", - ) - # Needed for Remote Execution _maybe( http_archive, diff --git a/packages/bazel/src/ng_rollup_bundle.bzl b/packages/bazel/src/ng_rollup_bundle.bzl index 0aadf42a6b..d1100520e6 100644 --- a/packages/bazel/src/ng_rollup_bundle.bzl +++ b/packages/bazel/src/ng_rollup_bundle.bzl @@ -194,7 +194,7 @@ ng_rollup_bundle = rule( "_brotli": attr.label( executable = True, cfg = "host", - default = Label("@org_brotli//:brotli"), + default = Label("//tools/brotli-cli"), ), "_rollup": attr.label( executable = True, diff --git a/tools/brotli-cli/BUILD.bazel b/tools/brotli-cli/BUILD.bazel new file mode 100644 index 0000000000..7a60027f8b --- /dev/null +++ b/tools/brotli-cli/BUILD.bazel @@ -0,0 +1,11 @@ +load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary") + +nodejs_binary( + name = "brotli-cli", + data = [ + "cli.js", + "@npm//brotli", + ], + entry_point = "angular/tools/brotli-cli/cli.js", + visibility = ["//:__subpackages__"], +) diff --git a/tools/brotli-cli/cli.js b/tools/brotli-cli/cli.js new file mode 100644 index 0000000000..e38a4a5c43 --- /dev/null +++ b/tools/brotli-cli/cli.js @@ -0,0 +1,21 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +const fs = require('fs'); +const compress = require('brotli/compress'); + +function main(args) { + const output = args[0].substring('--output='.length); + const input = args[1]; + const buffer = fs.readFileSync(input); + fs.writeFileSync(output, compress(buffer, {mode: 0, quality: 11})); +} + +if (require.main === module) { + main(process.argv.slice(2)); +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index cfe742e5e9..0afe364313 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1321,7 +1321,7 @@ base64-js@1.2.1: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886" integrity sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw== -base64-js@^1.0.2: +base64-js@^1.0.2, base64-js@^1.1.2: version "1.3.0" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" integrity sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw== @@ -1558,6 +1558,13 @@ braces@^2.3.0, braces@^2.3.1, braces@^2.3.2: split-string "^3.0.2" to-regex "^3.0.1" +brotli@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/brotli/-/brotli-1.3.2.tgz#525a9cad4fcba96475d7d388f6aecb13eed52f46" + integrity sha1-UlqcrU/LqWR119OI9q7LE+7VL0Y= + dependencies: + base64-js "^1.1.2" + browserify-zlib@~0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.1.4.tgz#bb35f8a519f600e0fa6b8485241c979d0141fb2d"