build: switch devmode output to es2015 (#44505)

To make our test output i.e. devmode output more aligned
with what we produce in the NPM packages, or to be more
aligned with what Angular applications will usually consume,
the devmode output is switched from ES5 to ES2015.

Additionally various tsconfigs (outside of Bazel) have been
updated to match with the other parts of the build. The rules
are:

ES2015 for test configurations, ES2020 for actual code that will
end up being shipped (this includes the IDE-only tsconfigs).

PR Close #44505
This commit is contained in:
Paul Gschwendtner
2021-12-16 14:11:53 +01:00
committed by Andrew Scott
parent 8388151f4d
commit c46d533b22
87 changed files with 134 additions and 250 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -20,7 +20,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -275,6 +275,10 @@ def _ngc_tsconfig(ctx, files, srcs, **kwargs):
if not is_devmode:
# Note: Keep in sync with the `prodmode_target` for `ts_library` in `tools/defaults.bzl`
tsconfig["compilerOptions"]["target"] = "es2020"
else:
# For devmode output, we use ES2015 to match with what `ts_library` produces by default.
# https://github.com/bazelbuild/rules_nodejs/blob/9b36274dba34204625579463e3da054a9f42cb47/packages/typescript/internal/build_defs.bzl#L83.
tsconfig["compilerOptions"]["target"] = "es2015"
return tsconfig
+1 -1
View File
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["es5", "es2015.collection", "es2015.core"],
"lib": ["es2015"],
"types": ["node"],
"esModuleInterop": true,
"downlevelIteration": true
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["es5", "es2015.collection", "es2015.core"],
"lib": ["es2015"],
"types": ["node", "jasmine"],
"esModuleInterop": true
}
+1 -1
View File
@@ -15,7 +15,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
"//packages/benchpress",
+1 -1
View File
@@ -27,7 +27,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -24,7 +24,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -38,7 +38,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -23,7 +23,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -21,7 +21,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
"//packages/platform-server",
@@ -19,7 +19,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -10,12 +10,12 @@
"baseUrl": ".",
"declaration": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"lib": ["es2015", "dom"],
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "../node_modules/flat_module",
"rootDir": "",
"target": "es5",
"target": "es2015",
"typeRoots": ["../node_modules/@types"]
},
@@ -8,11 +8,11 @@
"baseUrl": ".",
"declaration": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"lib": ["es2015", "dom"],
"moduleResolution": "node",
"noImplicitAny": true,
"rootDir": "",
"target": "es5",
"target": "es2015",
"types": []
}
}
@@ -8,12 +8,12 @@
"baseUrl": ".",
"declaration": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"lib": ["es2015", "dom"],
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "../node_modules/third_party",
"rootDir": "",
"target": "es5",
"target": "es2015",
"typeRoots": ["../node_modules/@types"]
}
}
@@ -12,7 +12,7 @@
"baseUrl": ".",
"declaration": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"lib": ["es2015", "dom"],
"moduleResolution": "node",
"noImplicitAny": true,
"noUnusedLocals": true,
@@ -23,7 +23,7 @@
// compatible with the option. Disabled until the integration test support the strict flag.
// TODO(devversion): this has been enabled without the integration test code being
"strictPropertyInitialization": false,
"target": "es5",
"target": "es2015",
"typeRoots": ["node_modules/@types"]
},
@@ -9,13 +9,13 @@
"baseUrl": ".",
"declaration": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"lib": ["es2015", "dom"],
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "./xi18n-out",
"rootDir": "",
"skipLibCheck": true,
"target": "es5",
"target": "es2015",
"typeRoots": ["node_modules/@types"]
},
@@ -29,7 +29,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -24,7 +24,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
+2 -2
View File
@@ -38,7 +38,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
],
@@ -90,7 +90,7 @@ babel(
jasmine_node_test(
name = "integration",
timeout = "long",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
":fesm5_angular_core",
"@npm//@angular/common-12",
@@ -31,7 +31,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -25,7 +25,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "test_lib",
testonly = True,
@@ -21,7 +21,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -19,7 +19,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -17,7 +17,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -23,7 +23,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -23,7 +23,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -23,7 +23,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -15,7 +15,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -24,7 +24,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
],
@@ -24,7 +24,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -20,7 +20,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "test_lib",
testonly = True,
@@ -25,7 +25,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -21,7 +21,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -21,7 +21,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -24,7 +24,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -18,7 +18,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -19,7 +19,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -19,7 +19,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -34,7 +34,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
@@ -20,7 +20,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
+6 -6
View File
@@ -40,7 +40,7 @@ ts_library(
jasmine_node_test(
name = "extract_i18n",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
data = [
"//packages/core:npm_package",
],
@@ -68,7 +68,7 @@ ts_library(
jasmine_node_test(
name = "downlevel_decorator_transform",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":downlevel_decorator_transform_lib",
],
@@ -92,7 +92,7 @@ ts_library(
jasmine_node_test(
name = "perform_watch",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
data = [
"//packages/core:npm_package",
],
@@ -119,7 +119,7 @@ ts_library(
jasmine_node_test(
name = "perform_compile",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
data = [
"//packages/core:npm_package",
],
@@ -142,7 +142,7 @@ ts_library(
jasmine_node_test(
name = "typescript_support",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":typescript_support_lib",
],
@@ -160,7 +160,7 @@ ts_library(
jasmine_node_test(
name = "version_helpers",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":version_helpers_lib",
],
@@ -12,7 +12,7 @@ ts_library(
jasmine_node_test(
name = "full",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
"//packages/compiler-cli/test/compliance/test_cases",
@@ -17,7 +17,7 @@ ts_library(
jasmine_node_test(
name = "linked",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
"//packages/compiler-cli/test/compliance/test_cases",
@@ -10,6 +10,7 @@ import * as fs from 'fs';
import * as path from 'path';
import {mainXi18n} from '../src/extract_i18n';
import {setup} from './test_support';
const EXPECTED_XMB = `<?xml version="1.0" encoding="UTF-8" ?>
@@ -222,10 +223,10 @@ describe('extract_i18n command line', () => {
"rootDir": ".",
"baseUrl": ".",
"declaration": true,
"target": "es5",
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"lib": ["es6", "dom"],
"lib": ["es2015", "dom"],
"typeRoots": ["node_modules/@types"]
}
}`);
+1 -1
View File
@@ -24,7 +24,7 @@ ts_library(
jasmine_node_test(
name = "ngtsc",
timeout = "long",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
"//packages/compiler-cli/src/ngtsc/testing/fake_common:npm_package",
"//packages/compiler-cli/src/ngtsc/testing/fake_core:npm_package",
+2 -2
View File
@@ -64,11 +64,11 @@ export class NgtscTestEnvironment {
"baseUrl": ".",
"allowJs": true,
"declaration": true,
"target": "es5",
"target": "es2015",
"newLine": "lf",
"module": "es2015",
"moduleResolution": "node",
"lib": ["es6", "dom"],
"lib": ["es2015", "dom"],
"typeRoots": ["node_modules/@types"]
},
"angularCompilerOptions": {
+1 -1
View File
@@ -54,7 +54,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
":test_node_only_lib",
@@ -14,7 +14,7 @@ ts_library(
jasmine_node_test(
name = "expression_parser",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":expression_parser_lib",
],
+1 -1
View File
@@ -13,7 +13,7 @@ ts_library(
jasmine_node_test(
name = "ml_parser",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":ml_parser_lib",
],
+1 -1
View File
@@ -16,7 +16,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -13,7 +13,7 @@ ts_library(
jasmine_node_test(
name = "selector",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":selector_lib",
],
+1 -1
View File
@@ -108,7 +108,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
data = [
":downleveled_es5_fixture",
],
+1 -1
View File
@@ -37,7 +37,7 @@ ts_library(
jasmine_node_test(
name = "acceptance",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":acceptance_lib",
"//packages/zone.js/lib:zone_d_ts",
+1 -1
View File
@@ -16,7 +16,7 @@ ts_library(
jasmine_node_test(
name = "compiler",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":compiler_lib",
],
+3 -23
View File
@@ -2,10 +2,6 @@ load("//tools:defaults.bzl", "jasmine_node_test", "karma_web_test_suite", "ts_li
package(default_visibility = ["//visibility:public"])
ES2015_SPECS = [
"providers_es2015_spec.ts",
]
ts_library(
name = "render3_lib",
testonly = True,
@@ -18,7 +14,7 @@ ts_library(
"is_shape_of.ts",
"jit_spec.ts",
"matchers.ts",
] + ES2015_SPECS,
],
),
deps = [
":matchers",
@@ -41,20 +37,6 @@ ts_library(
],
)
ts_library(
name = "render3_es2015_test_lib",
testonly = True,
srcs = ES2015_SPECS,
devmode_target = "es2015",
tsconfig = "es2015-tsconfig.json",
deps = [
":matchers",
":render3_lib",
"//packages:types",
"//packages/core",
],
)
ts_library(
name = "matchers",
testonly = True,
@@ -94,11 +76,10 @@ ts_library(
jasmine_node_test(
name = "render3",
bootstrap = [
":domino_es5",
"//tools/testing:node_es5",
":domino_es2015",
"//tools/testing:node_es2015",
],
deps = [
":render3_es2015_test_lib",
":render3_node_lib",
"//packages/zone.js/lib",
],
@@ -107,7 +88,6 @@ jasmine_node_test(
karma_web_test_suite(
name = "render3_web",
deps = [
":render3_es2015_test_lib",
":render3_lib",
],
)
+2 -2
View File
@@ -17,8 +17,8 @@ ts_library(
jasmine_node_test(
name = "ivy",
bootstrap = [
"//packages/core/test/render3:domino_es5",
"//tools/testing:node_es5",
"//packages/core/test/render3:domino_es2015",
"//tools/testing:node_es2015",
],
deps = [
":ivy_lib",
@@ -1,45 +0,0 @@
/**
* @license
* Copyright Google LLC 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
*/
import {forwardRef, InjectionToken, ɵɵdirectiveInject} from '@angular/core';
import {expectProvidersScenario} from './providers_helper';
describe('es2015 providers', () => {
abstract class Greeter {
abstract greet: string;
}
const GREETER = new InjectionToken<Greeter>('greeter');
class GreeterClass implements Greeter {
greet = 'Class';
hasBeenCleanedUp = false;
ngOnDestroy() {
this.hasBeenCleanedUp = true;
}
}
it('ClassProvider wrapped in forwardRef', () => {
let greeterInstance: GreeterClass|null = null;
expectProvidersScenario({
parent: {
providers: [{provide: GREETER, useClass: forwardRef(() => GreeterClass)}],
componentAssertion: () => {
greeterInstance = ɵɵdirectiveInject(GREETER) as GreeterClass;
expect(greeterInstance.greet).toEqual('Class');
}
}
});
expect(greeterInstance).not.toBeNull();
expect(greeterInstance!.hasBeenCleanedUp).toBe(true);
});
});
-11
View File
@@ -1,6 +1,5 @@
load("//tools:defaults.bzl", "karma_web_test_suite", "ts_library")
load("//tools/circular_dependency_test:index.bzl", "circular_dependency_test")
load("//tools:utils.bzl", "transpile_js_to_es5")
circular_dependency_test(
name = "circular_deps_test",
@@ -26,13 +25,6 @@ ts_library(
],
)
# This file is shipped as es2015 to npm. We have to transpile
# it to es5 in order to run the tests against older browsers.
transpile_js_to_es5(
name = "custom_elements_native_shim",
js_file = "@npm//:node_modules/@webcomponents/custom-elements/src/native-shim.js",
)
filegroup(
name = "elements_test_bootstrap_scripts",
testonly = True,
@@ -41,9 +33,6 @@ filegroup(
"@npm//:node_modules/core-js-bundle/index.js",
# Required for browsers that do not natively support Custom Elements.
"@npm//:node_modules/@webcomponents/custom-elements/custom-elements.min.js",
# Required for ES5 code to work with a native Custom Elements implementation.
# (See https://www.npmjs.com/package/@webcomponents/custom-elements#es5-vs-es2015.)
":custom_elements_native_shim",
"@npm//:node_modules/reflect-metadata/Reflect.js",
"//packages/zone.js/bundles:zone.umd.js",
"//packages/zone.js/bundles:zone-testing.umd.js",
+3 -3
View File
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "protractor_web_test_suite", "ts_devserver", "ts_library")
package(default_visibility = ["//visibility:public"])
ng_module(
name = "core_examples",
srcs = glob(
@@ -78,7 +78,7 @@ protractor_web_test_suite(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":core_tests_lib",
],
@@ -15,7 +15,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":fake_async_lib",
],
+1 -1
View File
@@ -27,7 +27,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//tools:defaults.bzl", "jasmine_node_test", "ts_config", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_config(
name = "tsconfig",
src = "tsconfig-build.json",
@@ -42,7 +42,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -14,7 +14,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -14,7 +14,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -23,7 +23,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -27,7 +27,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
"@npm//glob",
@@ -21,7 +21,7 @@ ts_library(
jasmine_node_test(
name = "integration",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
"//packages/localize/tools/test/extract/integration/test_files",
"//packages/localize/tools/test/extract/integration/test_files:compile_es2015",
@@ -28,7 +28,7 @@ copy_to_bin(
jasmine_node_test(
name = "integration",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
":test_files",
],
@@ -18,7 +18,7 @@ ts_library(
jasmine_node_test(
name = "integration",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
data = [
"//packages/localize/tools/test/translate/integration/locales",
"//packages/localize/tools/test/translate/integration/test_files",
@@ -25,7 +25,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -31,7 +31,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -42,7 +42,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -18,7 +18,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_no_angular_es5"],
bootstrap = ["//tools/testing:node_no_angular_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -35,7 +35,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
+1 -1
View File
@@ -36,7 +36,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
@@ -27,7 +27,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":aot_test_lib",
],
+3 -3
View File
@@ -3,7 +3,7 @@
"baseUrl": ".",
"declaration": false,
"strict": true,
"module": "es2015",
"module": "es2020",
"moduleResolution": "node",
"strictNullChecks": true,
"strictPropertyInitialization": true,
@@ -17,8 +17,8 @@
"@angular/service-worker/config": ["../../../dist/packages/service-worker/config"]
},
"inlineSourceMap": true,
"lib": ["es2015"],
"target": "es5",
"lib": ["es2020"],
"target": "es2020",
"typeRoots": [],
"types": [
"node"
@@ -21,7 +21,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
"//packages/service-worker/config",
+1 -1
View File
@@ -25,7 +25,7 @@ ts_library(
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [
":test_lib",
],
+1 -3
View File
@@ -31,8 +31,6 @@
"importHelpers": true
},
"bazelOptions": {
"suppressTsconfigOverrideWarnings": true,
// TODO(devversion): Switch devmode target to ES2020 or combine devmode with prodmode.
"devmodeTargetOverride": "es5"
"suppressTsconfigOverrideWarnings": true
}
}
+1 -2
View File
@@ -11,7 +11,6 @@
}]
},
"bazelOptions": {
"suppressTsconfigOverrideWarnings": true,
"devmodeTargetOverride": "es5"
"suppressTsconfigOverrideWarnings": true
}
}
+2 -2
View File
@@ -8,6 +8,7 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "es2020",
"target": "es2020",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
@@ -43,7 +44,6 @@
],
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"target": "es2020",
"types": [
"angular"
]
@@ -68,4 +68,4 @@
"platform-server/integrationtest",
"router/test/aot_ngsummary_test"
]
}
}
+5 -5
View File
@@ -182,7 +182,7 @@ ts_library(
jasmine_node_test(
name = "test_node",
bootstrap = [":node_entry_point_es5"],
bootstrap = [":node_entry_point_es2015"],
deps = [
":test_node_lib",
],
@@ -190,7 +190,7 @@ jasmine_node_test(
jasmine_node_test(
name = "test_node_no_jasmine_clock",
bootstrap = [":node_entry_point_no_patch_clock_es5"],
bootstrap = [":node_entry_point_no_patch_clock_es2015"],
deps = [
":test_node_lib",
],
@@ -198,7 +198,7 @@ jasmine_node_test(
jasmine_node_test(
name = "test_node_bluebird",
bootstrap = [":node_bluebird_entry_point_es5"],
bootstrap = [":node_bluebird_entry_point_es2015"],
deps = [
":bluebird_spec",
],
@@ -206,12 +206,12 @@ jasmine_node_test(
jasmine_node_test(
name = "test_node_error_disable_policy",
bootstrap = [":node_error_disable_policy_entry_point_es5"],
bootstrap = [":node_error_disable_policy_entry_point_es2015"],
)
jasmine_node_test(
name = "test_node_error_lazy_policy",
bootstrap = [":node_error_lazy_policy_entry_point_es5"],
bootstrap = [":node_error_lazy_policy_entry_point_es2015"],
)
ts_library(
+16 -11
View File
@@ -123,6 +123,7 @@ def ts_library(name, tsconfig = None, testonly = False, deps = [], module_name =
# For prodmode, the target is set to `ES2020`. `@bazel/typecript` sets `ES2015` by
# default. Note that this should be in sync with the `ng_module` tsconfig generation.
# https://github.com/bazelbuild/rules_nodejs/blob/901df3868e3ceda177d3ed181205e8456a5592ea/third_party/github.com/bazelbuild/rules_typescript/internal/common/tsconfig.bzl#L195
# https://github.com/bazelbuild/rules_nodejs/blob/9b36274dba34204625579463e3da054a9f42cb47/packages/typescript/internal/build_defs.bzl#L85.
prodmode_target = "es2020",
# `module_name` is used for AMD module names within emitted JavaScript files.
module_name = module_name,
@@ -132,14 +133,18 @@ def ts_library(name, tsconfig = None, testonly = False, deps = [], module_name =
**kwargs
)
# Select the es5 .js output of the ts_library for use in downstream boostrap targets
# with `output_group = "es5_sources"`. This exposes an internal detail of ts_library
# that is not ideal.
# TODO(gregmagolan): clean this up by using tsc() in these cases rather than ts_library
# The `ts_library` targets by default only expose the type definitions as `DefaultInfo`.
# This is an auto-generated target that can be used to access the plain ES2015 devmode output.
# TODO(devversion): Should be renamed once we have devmode & prodmode combined.
native.filegroup(
name = "%s_es5" % name,
# Note: When changing the suffix of this target, update the `jasmine_node_test` bootstrap
# logic which has special logic for resolving such targets.
name = "%s_es2015" % name,
srcs = [":%s" % name],
testonly = testonly,
# Note: Ironically this is named `es5_sources` but it refers to the devmode output.
# This is just an artifact of many iterations in `@bazel/typescript`. This is being
# solved together with us combining devmode & prodmode.
output_group = "es5_sources",
)
@@ -404,15 +409,15 @@ def jasmine_node_test(bootstrap = [], **kwargs):
file.
The label is automatically added to the deps of jasmine_node_test.
If the label ends in `_es5` which by convention selects the es5 outputs
of a ts_library rule, then corresponding ts_library target sans `_es5`
If the label ends in `_es2015` which by convention selects the es2015 outputs
of a ts_library rule, then corresponding ts_library target sans `_es2015`
is also added to the deps of jasmine_node_test.
For example with,
jasmine_node_test(
name = "test",
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
deps = [":test_lib"],
)
@@ -438,12 +443,12 @@ def jasmine_node_test(bootstrap = [], **kwargs):
for label in bootstrap:
deps += [label]
templated_args += ["--node_options=--require=$$(rlocation $(rootpath %s))" % label]
if label.endswith("_es5"):
if label.endswith("_es2015"):
# If this label is a filegroup derived from a ts_library then automatically
# add the ts_library target (which is the label sans `_es5`) to deps so we pull
# add the ts_library target (which is the label sans `_es2015`) to deps so we pull
# in all of its transitive deps. This removes the need for duplicate deps on the
# target and makes the usage of this rule less verbose.
deps += [label[:-4]]
deps += [label[:-len("_es2015")]]
_jasmine_node_test(
deps = deps,
+1 -1
View File
@@ -57,6 +57,6 @@ jasmine_node_test(
jasmine_node_test(
name = "fail_bootstrap_test",
srcs = ["fail.spec.js"],
bootstrap = ["//tools/testing:node_es5"],
bootstrap = ["//tools/testing:node_es2015"],
expected_exit_code = 55,
)
-47
View File
@@ -1,47 +0,0 @@
"""Simple utility bazel macros for convenience usage."""
load("@npm//typescript:index.bzl", "tsc")
def transpile_js_to_es5(name, js_file):
"""Transpiles a provided javascript target to es5.
For testing on IE, shims must be served in es5, this macro can be used to
transpile es2015 JS shims to es5 for usage in IE testing.
Example usage:
transpile_js_to_es5(
name = "my-file",
js_file = "@npm//some_package/shim_files/es6_shim_file.js",
)
filegroup(
name = "some_shims_for_tests",
testonly = True,
srcs = [
":my-file",
...
]
)
"""
tsc(
name = name,
outs = [
"%s.js" % name,
],
args = [
# Allow JS files to be used for transpiling
"--allowJs",
# Skip lib check as pure local javascript transpiling should be done
"--skipLibCheck",
# Transpile to ES5
"--target ES5",
# Output the transpiled file to the location provided by the name
"--outFile $(execpath :%s.js)" % name,
# Transpile the provided js_file
"$(execpath %s)" % js_file,
],
data = [
js_file,
],
)