build(bazel): do not build rxjs from source under Bazel (#28869)

PR Close #28869
This commit is contained in:
Greg Magolan
2019-02-13 16:31:29 -08:00
committed by Igor Minar
parent be6af26dc1
commit 3eb327b67b
99 changed files with 359 additions and 148 deletions

View File

@ -25,7 +25,6 @@ ts_library(
"@ngdeps//@angular-devkit/architect",
"@ngdeps//@angular-devkit/core",
"@ngdeps//@types/node",
"@rxjs",
"@rxjs//operators",
"@ngdeps//rxjs",
],
)

View File

@ -28,13 +28,6 @@ http_archive(
strip_prefix = "angular-%s" % ANGULAR_VERSION,
)
# RxJS
RXJS_VERSION = "<%= RXJS_VERSION %>"
http_archive(
name = "rxjs",
url = "https://registry.yarnpkg.com/rxjs/-/rxjs-%s.tgz" % RXJS_VERSION,
strip_prefix = "package/src",
)
<% if (sass) { %>
# Rules for compiling sass
RULES_SASS_VERSION = "<%= RULES_SASS_VERSION %>"

View File

@ -16,6 +16,16 @@ sass_binary(
for x in glob(["**/*.scss"])
]
<% } %>
filegroup(
name = "rxjs_umd_modules",
srcs = [
# do not sort
"@npm//node_modules/rxjs:bundles/rxjs.umd.js",
":rxjs_shims.js",
],
)
ng_module(
name = "src",
srcs = glob(
@ -36,13 +46,17 @@ ng_module(
"@angular//packages/platform-browser",<% if (routing) { %>
"@angular//packages/router",<% } %>
"@npm//@types",
"@npm//rxjs",
],
)
rollup_bundle(
name = "bundle",
entry_point = "src/main.prod",
deps = ["//src"],
deps = [
"//src",
"@npm//rxjs",
],
)
web_package(
@ -67,15 +81,14 @@ history_server(
ts_devserver(
name = "devserver",
port = 4200,
additional_root_paths = [
"npm/node_modules/zone.js/dist",
"npm/node_modules/tslib",
],
entry_module = "<%= utils.underscore(name) %>/src/main.dev",
serving_path = "/bundle.min.js",
scripts = [
"@npm//node_modules/tslib:tslib.js",
":rxjs_umd_modules",
],
static_files = [
"@npm//node_modules/zone.js:dist/zone.min.js",
"@npm//node_modules/tslib:tslib.js",
],
index_html = "index.html",
deps = [":src"],
@ -120,6 +133,7 @@ ts_web_test_suite(
"@io_bazel_rules_webtesting//browsers:chromium-local",
],
deps = [
":rxjs_umd_modules",
":test_lib",
"@npm//karma-jasmine",
],

View File

@ -0,0 +1,32 @@
/**
* @fileoverview Provides named UMD shims for `rxjs/operators` and `rxjs/testing`.
* This file should be included in the "scripts" of a "ts_devserver"
* rule and the "deps" of a "ts_web_test_suite" rule.
*/
// rxjs/operators
(function(factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
} else if (typeof define === 'function' && define.amd) {
define('rxjs/operators', ['exports', 'rxjs'], factory);
}
})(function(exports, rxjs) {
'use strict';
Object.keys(rxjs.operators).forEach(function(key) { exports[key] = rxjs.operators[key]; });
Object.defineProperty(exports, '__esModule', {value: true});
});
// rxjs/testing
(function(factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
} else if (typeof define === 'function' && define.amd) {
define('rxjs/testing', ['exports', 'rxjs'], factory);
}
})(function(exports, rxjs) {
'use strict';
Object.keys(rxjs.testing).forEach(function(key) { exports[key] = rxjs.testing[key]; });
Object.defineProperty(exports, '__esModule', {value: true});
});

View File

@ -90,7 +90,6 @@ export default function(options: BazelWorkspaceOptions): Rule {
'RULES_NODEJS_VERSION': '0.18.6',
'RULES_NODEJS_SHA256': '1416d03823fed624b49a0abbd9979f7c63bbedfd37890ddecedd2fe25cccebc6',
'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
'RXJS_VERSION': existingVersions.RxJs || clean(latestVersions.RxJs),
// TODO(kyliau): Consider moving this to latest-versions.ts
'RULES_SASS_VERSION': '1.15.1',
};