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, o5376a8b139/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
		
	
			
		
			
				
	
	
		
			351 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			351 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
 | |
| load("//packages/zone.js/test:karma_test.bzl", "karma_test")
 | |
| 
 | |
| package(default_visibility = ["//:__pkg__"])
 | |
| 
 | |
| exports_files([
 | |
|     "assets/sample.json",
 | |
|     "assets/worker.js",
 | |
|     "assets/import.html",
 | |
| ])
 | |
| 
 | |
| ts_library(
 | |
|     name = "common_spec_env",
 | |
|     testonly = True,
 | |
|     srcs = [
 | |
|         "test-env-setup-jasmine.ts",
 | |
|         "test_fake_polyfill.ts",
 | |
|         "wtf_mock.ts",
 | |
|     ],
 | |
|     deps = [
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "common_spec_srcs",
 | |
|     testonly = True,
 | |
|     srcs = glob(
 | |
|         [
 | |
|             "common/*.ts",
 | |
|             "zone-spec/*.ts",
 | |
|             "rxjs/*.ts",
 | |
|         ],
 | |
|         exclude = [
 | |
|             "common/Error.spec.ts",
 | |
|             "common/promise-disable-wrap-uncaught-promise-rejection.spec.ts",
 | |
|         ],
 | |
|     ),
 | |
|     deps = [
 | |
|         ":common_spec_util",
 | |
|         "//packages/zone.js/lib",
 | |
|         "@npm//rxjs",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "common_spec_util",
 | |
|     testonly = True,
 | |
|     srcs = ["test-util.ts"],
 | |
|     deps = [
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "error_spec_srcs",
 | |
|     testonly = True,
 | |
|     srcs = [
 | |
|         "common/Error.spec.ts",
 | |
|     ],
 | |
|     deps = [
 | |
|         ":common_spec_util",
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "test_node_lib",
 | |
|     testonly = True,
 | |
|     srcs = glob(["node/*.ts"]) + [
 | |
|         "node-env-setup.ts",
 | |
|         "test-env-setup-jasmine-no-patch-clock.ts",
 | |
|     ],
 | |
|     deps = [
 | |
|         ":common_spec_env",
 | |
|         ":common_spec_srcs",
 | |
|         ":common_spec_util",
 | |
|         "//packages/zone.js/lib",
 | |
|         "@npm//@types/shelljs",
 | |
|         "@npm//@types/systemjs",
 | |
|         "@npm//rxjs",
 | |
|         "@npm//shelljs",
 | |
|         "@npm//systemjs",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "node_entry_point",
 | |
|     testonly = True,
 | |
|     srcs = ["node_entry_point.ts"],
 | |
|     deps = [
 | |
|         ":common_spec_env",
 | |
|         ":common_spec_srcs",
 | |
|         ":common_spec_util",
 | |
|         "//packages/zone.js/lib",
 | |
|         "@npm//@types/shelljs",
 | |
|         "@npm//@types/systemjs",
 | |
|         "@npm//rxjs",
 | |
|         "@npm//shelljs",
 | |
|         "@npm//systemjs",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "node_entry_point_no_patch_clock",
 | |
|     testonly = True,
 | |
|     srcs = ["node_entry_point_no_patch_clock.ts"],
 | |
|     deps = [
 | |
|         ":common_spec_env",
 | |
|         ":common_spec_srcs",
 | |
|         ":common_spec_util",
 | |
|         "//packages/zone.js/lib",
 | |
|         "@npm//@types/shelljs",
 | |
|         "@npm//@types/systemjs",
 | |
|         "@npm//rxjs",
 | |
|         "@npm//shelljs",
 | |
|         "@npm//systemjs",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "bluebird_spec",
 | |
|     testonly = True,
 | |
|     srcs = [
 | |
|         "extra/bluebird.spec.ts",
 | |
|     ],
 | |
|     deps = [
 | |
|         ":common_spec_env",
 | |
|         "//packages/zone.js/lib",
 | |
|         "@npm//bluebird",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "node_bluebird_entry_point",
 | |
|     testonly = True,
 | |
|     srcs = ["node_bluebird_entry_point.ts"],
 | |
|     deps = [
 | |
|         ":common_spec_env",
 | |
|         "//packages/zone.js/lib",
 | |
|         "@npm//bluebird",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "node_error_disable_policy_entry_point",
 | |
|     testonly = True,
 | |
|     srcs = ["node_error_disable_policy_entry_point.ts"],
 | |
|     deps = [
 | |
|         ":common_spec_env",
 | |
|         ":common_spec_util",
 | |
|         ":error_spec_srcs",
 | |
|         ":node_error_entry_point",
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "node_error_entry_point",
 | |
|     testonly = True,
 | |
|     srcs = ["node_error_entry_point.ts"],
 | |
|     deps = [
 | |
|         ":common_spec_env",
 | |
|         ":common_spec_util",
 | |
|         ":error_spec_srcs",
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "node_error_lazy_policy_entry_point",
 | |
|     testonly = True,
 | |
|     srcs = ["node_error_lazy_policy_entry_point.ts"],
 | |
|     deps = [
 | |
|         ":common_spec_env",
 | |
|         ":common_spec_util",
 | |
|         ":error_spec_srcs",
 | |
|         ":node_error_entry_point",
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| jasmine_node_test(
 | |
|     name = "test_node",
 | |
|     bootstrap = [":node_entry_point_es5"],
 | |
|     deps = [
 | |
|         ":test_node_lib",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| jasmine_node_test(
 | |
|     name = "test_node_no_jasmine_clock",
 | |
|     bootstrap = [":node_entry_point_no_patch_clock_es5"],
 | |
|     deps = [
 | |
|         ":test_node_lib",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| jasmine_node_test(
 | |
|     name = "test_node_bluebird",
 | |
|     bootstrap = [":node_bluebird_entry_point_es5"],
 | |
|     deps = [
 | |
|         ":bluebird_spec",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| jasmine_node_test(
 | |
|     name = "test_node_error_disable_policy",
 | |
|     bootstrap = [":node_error_disable_policy_entry_point_es5"],
 | |
| )
 | |
| 
 | |
| jasmine_node_test(
 | |
|     name = "test_node_error_lazy_policy",
 | |
|     bootstrap = [":node_error_lazy_policy_entry_point_es5"],
 | |
| )
 | |
| 
 | |
| ts_library(
 | |
|     name = "npm_package_spec_lib",
 | |
|     testonly = True,
 | |
|     srcs = ["npm_package/npm_package.spec.ts"],
 | |
|     deps = [
 | |
|         "@npm//@types/shelljs",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| jasmine_node_test(
 | |
|     name = "test_npm_package",
 | |
|     srcs = [":npm_package_spec_lib"],
 | |
|     data = [
 | |
|         "//packages/zone.js:npm_package",
 | |
|         "@npm//shelljs",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| env_srcs = [
 | |
|     "browser-env-setup.ts",
 | |
|     "browser_symbol_setup.ts",
 | |
| ]
 | |
| 
 | |
| env_deps = [
 | |
|     ":common_spec_env",
 | |
|     ":common_spec_srcs",
 | |
|     ":common_spec_util",
 | |
|     ":error_spec_srcs",
 | |
|     "//packages/zone.js/lib",
 | |
|     "@npm//@types/shelljs",
 | |
|     "@npm//@types/systemjs",
 | |
|     "@npm//rxjs",
 | |
|     "@npm//shelljs",
 | |
|     "@npm//systemjs",
 | |
| ]
 | |
| 
 | |
| env_entry_point = ":browser-env-setup.ts"
 | |
| 
 | |
| test_srcs = glob(
 | |
|     ["browser/*.ts"],
 | |
|     exclude = [
 | |
|         "browser/shadydom.spec.ts",
 | |
|         "common/promise-disable-wrap-uncaught-promise-rejection.spec.ts",
 | |
|     ],
 | |
| ) + [
 | |
|     "extra/cordova.spec.ts",
 | |
|     "mocha-patch.spec.ts",
 | |
|     "jasmine-patch.spec.ts",
 | |
|     "common_tests.ts",
 | |
|     "browser_entry_point.ts",
 | |
| ]
 | |
| 
 | |
| test_deps = [
 | |
|     ":common_spec_env",
 | |
|     ":common_spec_srcs",
 | |
|     ":common_spec_util",
 | |
|     ":error_spec_srcs",
 | |
|     "//packages/zone.js/lib",
 | |
|     "@npm//@types/shelljs",
 | |
|     "@npm//@types/systemjs",
 | |
|     "@npm//rxjs",
 | |
|     "@npm//shelljs",
 | |
|     "@npm//systemjs",
 | |
| ]
 | |
| 
 | |
| test_entry_point = ":browser_entry_point.ts"
 | |
| 
 | |
| karma_tests = {
 | |
|     "browser_test": ["//packages/zone.js/bundles:zone-testing-bundle.umd.js"],
 | |
|     "browser_green_test": [
 | |
|         "//packages/zone.js/fesm2015:zone.js",
 | |
|         "//packages/zone.js/fesm2015:zone-testing.js",
 | |
|     ],
 | |
|     "browser_legacy_test": [
 | |
|         "//packages/zone.js/bundles:zone-legacy.umd.js",
 | |
|         "//packages/zone.js/bundles:zone.umd.js",
 | |
|         "//packages/zone.js/bundles:zone-testing.umd.js",
 | |
|     ],
 | |
| }
 | |
| 
 | |
| karma_test(
 | |
|     name = "browser_test",
 | |
|     bootstraps = karma_tests,
 | |
|     ci = True,
 | |
|     env_deps = env_deps,
 | |
|     env_entry_point = env_entry_point,
 | |
|     env_srcs = env_srcs,
 | |
|     test_deps = test_deps,
 | |
|     test_entry_point = test_entry_point,
 | |
|     test_srcs = test_srcs,
 | |
| )
 | |
| 
 | |
| karma_test(
 | |
|     name = "browser_shadydom",
 | |
|     bootstraps = {"browser_shadydom": [
 | |
|         "//packages/zone.js/bundles:zone-testing-bundle.umd.js",
 | |
|         "//packages/zone.js/bundles:webapis-shadydom.umd.js",
 | |
|     ]},
 | |
|     ci = False,
 | |
|     env_deps = [
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
|     env_entry_point = ":browser_shadydom_setup.ts",
 | |
|     env_srcs = ["browser_shadydom_setup.ts"],
 | |
|     test_deps = [
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
|     test_entry_point = ":browser_shadydom_entry_point.ts",
 | |
|     test_srcs = [
 | |
|         "browser/shadydom.spec.ts",
 | |
|         "browser_shadydom_entry_point.ts",
 | |
|     ],
 | |
| )
 | |
| 
 | |
| karma_test(
 | |
|     name = "browser_disable_wrap_uncaught_promise_rejection",
 | |
|     bootstraps = {"browser_disable_wrap_uncaught_promise_rejection": [
 | |
|         "//packages/zone.js/bundles:zone-testing-bundle.umd.js",
 | |
|     ]},
 | |
|     ci = False,
 | |
|     env_deps = [
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
|     env_entry_point = ":browser_disable_wrap_uncaught_promise_rejection_setup.ts",
 | |
|     env_srcs = ["browser_disable_wrap_uncaught_promise_rejection_setup.ts"],
 | |
|     test_deps = [
 | |
|         "//packages/zone.js/lib",
 | |
|     ],
 | |
|     test_entry_point = ":browser_disable_wrap_uncaught_promise_rejection_entry_point.ts",
 | |
|     test_srcs = [
 | |
|         "common/promise-disable-wrap-uncaught-promise-rejection.spec.ts",
 | |
|         "browser_disable_wrap_uncaught_promise_rejection_entry_point.ts",
 | |
|     ],
 | |
| )
 |