2019-08-15 11:35:33 -04:00
|
|
|
load("//tools:defaults.bzl", "rollup_bundle", "ts_library")
|
2021-02-04 17:11:53 -05:00
|
|
|
load("@npm//@bazel/concatjs:index.bzl", "karma_web_test_suite")
|
2019-07-21 06:44:13 -04:00
|
|
|
|
|
|
|
def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, test_entry_point):
|
|
|
|
ts_library(
|
|
|
|
name = name + "_env",
|
|
|
|
testonly = True,
|
|
|
|
srcs = env_srcs,
|
|
|
|
deps = env_deps,
|
|
|
|
)
|
|
|
|
rollup_bundle(
|
|
|
|
name = name + "_env_rollup",
|
|
|
|
testonly = True,
|
2019-12-21 20:27:41 -05:00
|
|
|
sourcemap = "false",
|
2019-07-21 06:44:13 -04:00
|
|
|
entry_point = env_entry_point,
|
2020-03-05 16:53:34 -05:00
|
|
|
silent = True,
|
2019-07-21 06:44:13 -04:00
|
|
|
deps = [
|
|
|
|
":" + name + "_env",
|
2019-10-27 19:28:03 -04:00
|
|
|
"@npm//rollup-plugin-commonjs",
|
|
|
|
"@npm//rollup-plugin-node-resolve",
|
2019-07-21 06:44:13 -04:00
|
|
|
],
|
|
|
|
)
|
|
|
|
ts_library(
|
|
|
|
name = name + "_test",
|
|
|
|
testonly = True,
|
|
|
|
srcs = test_srcs,
|
|
|
|
deps = test_deps,
|
|
|
|
)
|
|
|
|
rollup_bundle(
|
|
|
|
name = name + "_rollup",
|
|
|
|
testonly = True,
|
2020-03-05 16:53:34 -05:00
|
|
|
silent = True,
|
2019-12-21 20:27:41 -05:00
|
|
|
sourcemap = "false",
|
2019-07-21 06:44:13 -04:00
|
|
|
entry_point = test_entry_point,
|
refactor(zone.js): refactor zone rollup config (#40481)
When migrating zone.js from gulp to bazel, some legacy build config files are still there,
we have `rollup-es5.config.js` and `rollup-es5_global-es2015.config.js`, since in gulp build
system, build `es5` or `esm` files are set in the config file, but in the bazel world,
the output format is not config in the config.js file, but is required by the downstream
bazel target. So we don't really need the two rollup config files any longer.
Another difference is in `rollup-es5.config.js`, the `external` and `global` libraries names
are also config there, and these settings are also valid for `es2015` build, these settings
are not in the `es2015.config.js` for some legacy reasons. So we don't need to keep this
difference either.
PR Close #40481
2021-01-19 07:33:03 -05:00
|
|
|
config_file = "//packages/zone.js:rollup.config.js",
|
2019-07-21 06:44:13 -04:00
|
|
|
deps = [
|
|
|
|
":" + name + "_test",
|
2019-10-27 19:28:03 -04:00
|
|
|
"@npm//rollup-plugin-commonjs",
|
|
|
|
"@npm//rollup-plugin-node-resolve",
|
2019-07-21 06:44:13 -04:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, test_entry_point, bootstraps, ci):
|
|
|
|
first = True
|
|
|
|
for subname in bootstraps:
|
|
|
|
bootstrap = bootstraps[subname]
|
|
|
|
firstFlag = first
|
|
|
|
if first:
|
|
|
|
first = False
|
|
|
|
karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, test_entry_point)
|
|
|
|
_karma_test_required_dist_files = [
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#36540)
Close #35157
In the current version of zone.js, zone.js uses it's own package format, and it is not following the rule
of Angualr package format(APF), so it is not easily to be consumed by Angular CLI or other bundle tools.
For example, zone.js npm package has two bundles,
1. zone.js/dist/zone.js, this is a `es5` bundle.
2. zone.js/dist/zone-evergreen.js, this is a `es2015` bundle.
And Angular CLI has to add some hard-coding code to handle this case, ohttps://github.com/angular/angular-cli/blob/5376a8b1392ac7bd252782d8474161ce03a4d1cb/packages/schematics/angular/application/files/src/polyfills.ts.template#L55-L58
This PR upgrade zone.js npm package format to follow APF rule, https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx
The updated points are:
1. in package.json, update all bundle related properties
```
"main": "./bundles/zone.umd.js",
"module": "./fesm2015/zone.js",
"es2015": "./fesm2015/zone.js",
"fesm2015": "./fesm2015/zone.js",
```
2. re-organize dist folder, for example for `zone.js` bundle, now we have
```
dist/
bundles/
zone.js // this is the es5 bundle
fesm2015/
zone.js // this is the es2015 bundle (in the old version is `zone-evergreen.js`)
```
3. have several sub-packages.
1. `zone-testing`, provide zone-testing bundles include zone.js and testing libraries
2. `zone-node`, provide zone.js implemention for NodeJS
3. `zone-mix`, provide zone.js patches for both Browser and NodeJS
All those sub-packages will have their own `package.json` and the bundle will reference `bundles(es5)` and `fesm2015(es2015)`.
4. keep backward compatibility, still keep the `zone.js/dist` folder, and all bundles will be redirected to `zone.js/bundles` or `zone.js/fesm2015` folders.
PR Close #36540
2020-05-16 21:53:03 -04:00
|
|
|
"//packages/zone.js/bundles:task-tracking.umd.js",
|
|
|
|
"//packages/zone.js/bundles:wtf.umd.js",
|
|
|
|
"//packages/zone.js/bundles:webapis-notification.umd.js",
|
|
|
|
"//packages/zone.js/bundles:webapis-media-query.umd.js",
|
|
|
|
"//packages/zone.js/bundles:zone-patch-canvas.umd.js",
|
|
|
|
"//packages/zone.js/bundles:zone-patch-fetch.umd.js",
|
|
|
|
"//packages/zone.js/bundles:zone-patch-resize-observer.umd.js",
|
|
|
|
"//packages/zone.js/bundles:zone-patch-message-port.umd.js",
|
|
|
|
"//packages/zone.js/bundles:zone-patch-user-media.umd.js",
|
2019-12-21 20:27:41 -05:00
|
|
|
":" + name + "_rollup.umd",
|
2019-07-21 06:44:13 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
karma_web_test_suite(
|
|
|
|
name = subname + "_karma_jasmine_test",
|
|
|
|
srcs = [
|
|
|
|
"fake_entry.js",
|
|
|
|
],
|
|
|
|
bootstrap = [
|
2019-12-21 20:27:41 -05:00
|
|
|
":" + name + "_env_rollup.umd",
|
2019-07-21 06:44:13 -04:00
|
|
|
] + bootstrap +
|
|
|
|
_karma_test_required_dist_files,
|
2020-07-13 16:25:46 -04:00
|
|
|
browsers = ["//dev-infra/browsers/chromium:chromium"],
|
2019-07-21 06:44:13 -04:00
|
|
|
static_files = [
|
|
|
|
":assets/sample.json",
|
|
|
|
":assets/worker.js",
|
|
|
|
":assets/import.html",
|
|
|
|
],
|
|
|
|
tags = ["zone_karma_test"],
|
|
|
|
runtime_deps = [
|
|
|
|
"@npm//karma-browserstack-launcher",
|
2020-11-11 12:42:36 -05:00
|
|
|
"@npm//karma-sauce-launcher",
|
2019-07-21 06:44:13 -04:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
if ci and firstFlag:
|
|
|
|
karma_web_test_suite(
|
|
|
|
name = "karma_jasmine_test_ci",
|
|
|
|
srcs = [
|
|
|
|
"fake_entry.js",
|
|
|
|
],
|
|
|
|
bootstrap = [
|
|
|
|
":saucelabs.js",
|
2019-12-21 20:27:41 -05:00
|
|
|
":" + name + "_env_rollup.umd",
|
feat(zone.js): upgrade zone.js to angular package format(APF) (#36540)
Close #35157
In the current version of zone.js, zone.js uses it's own package format, and it is not following the rule
of Angualr package format(APF), so it is not easily to be consumed by Angular CLI or other bundle tools.
For example, zone.js npm package has two bundles,
1. zone.js/dist/zone.js, this is a `es5` bundle.
2. zone.js/dist/zone-evergreen.js, this is a `es2015` bundle.
And Angular CLI has to add some hard-coding code to handle this case, ohttps://github.com/angular/angular-cli/blob/5376a8b1392ac7bd252782d8474161ce03a4d1cb/packages/schematics/angular/application/files/src/polyfills.ts.template#L55-L58
This PR upgrade zone.js npm package format to follow APF rule, https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#heading=h.k0mh3o8u5hx
The updated points are:
1. in package.json, update all bundle related properties
```
"main": "./bundles/zone.umd.js",
"module": "./fesm2015/zone.js",
"es2015": "./fesm2015/zone.js",
"fesm2015": "./fesm2015/zone.js",
```
2. re-organize dist folder, for example for `zone.js` bundle, now we have
```
dist/
bundles/
zone.js // this is the es5 bundle
fesm2015/
zone.js // this is the es2015 bundle (in the old version is `zone-evergreen.js`)
```
3. have several sub-packages.
1. `zone-testing`, provide zone-testing bundles include zone.js and testing libraries
2. `zone-node`, provide zone.js implemention for NodeJS
3. `zone-mix`, provide zone.js patches for both Browser and NodeJS
All those sub-packages will have their own `package.json` and the bundle will reference `bundles(es5)` and `fesm2015(es2015)`.
4. keep backward compatibility, still keep the `zone.js/dist` folder, and all bundles will be redirected to `zone.js/bundles` or `zone.js/fesm2015` folders.
PR Close #36540
2020-05-16 21:53:03 -04:00
|
|
|
"//packages/zone.js/bundles:zone-testing-bundle.umd.min.js",
|
2019-07-21 06:44:13 -04:00
|
|
|
] + _karma_test_required_dist_files,
|
2020-07-13 16:25:46 -04:00
|
|
|
browsers = ["//dev-infra/browsers/chromium:chromium"],
|
2019-07-21 06:44:13 -04:00
|
|
|
config_file = "//:karma-js.conf.js",
|
|
|
|
configuration_env_vars = ["KARMA_WEB_TEST_MODE"],
|
|
|
|
data = [
|
|
|
|
"//:browser-providers.conf.js",
|
|
|
|
"//tools:jasmine-seed-generator.js",
|
|
|
|
],
|
|
|
|
static_files = [
|
|
|
|
":assets/sample.json",
|
|
|
|
":assets/worker.js",
|
|
|
|
":assets/import.html",
|
|
|
|
],
|
|
|
|
tags = ["zone_karma_test"],
|
2019-12-06 10:17:09 -05:00
|
|
|
# Visible to //:saucelabs_unit_tests_poc target
|
2019-07-21 06:44:13 -04:00
|
|
|
visibility = ["//:__pkg__"],
|
|
|
|
runtime_deps = [
|
|
|
|
"@npm//karma-browserstack-launcher",
|
2020-11-11 12:42:36 -05:00
|
|
|
"@npm//karma-sauce-launcher",
|
2019-07-21 06:44:13 -04:00
|
|
|
],
|
|
|
|
)
|