Skip to content

Commit 8875305

Browse files
devversionzarend
authored andcommitted
build: switch devmode output to ES2020 and ESM
Switches the devmode output to ES2020 and ESM. This is in preparation for allowing fast rebuilds with the Angular FW v13 packages. Since these packages are now strict ESM, and rely on the linker, we need to have some bundling in between for tests, or the dev-app (this is actually even faster than relying on ConcatJS/RequireJS/SystemJS). This bundling should not need to consume the prodmode output, but rather use the devmode output because otherwise the usual development workflow would result in both devmode + prodmode being requested.. resulting in a significant slow-down due to 2x TS compilations. Devmode output is always requested for dependencies on `ts_library` or `ng_module` to accomplish the TS fine-grained TS compilations. Since this is the case, we just naturally use the devmode output for bundling of tests/dev-app.. so inherently we need to switch devmode to ESM for enabling bundling.
1 parent cd038f5 commit 8875305

File tree

47 files changed

+131
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+131
-68
lines changed

integration/size-test/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ exports_files([
1111
ts_library(
1212
name = "check-size",
1313
srcs = ["check-size.ts"],
14+
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
15+
devmode_module = "commonjs",
1416
deps = [
1517
"@npm//@bazel/runfiles",
1618
"@npm//@types/node",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"integration-tests:size-test": "bazel test //integration/size-test/...",
4747
"check-mdc-tests": "ts-node --project scripts/tsconfig.json scripts/check-mdc-tests.ts",
4848
"check-mdc-exports": "ts-node --project scripts/tsconfig.json scripts/check-mdc-exports.ts",
49-
"check-tooling-setup": "yarn tsc --project tools/tsconfig-ci.json && yarn tsc --project .ng-dev/tsconfig.json",
49+
"check-tooling-setup": "yarn tsc --project tools/tsconfig.json && yarn tsc --project .ng-dev/tsconfig.json",
5050
"tsc": "node ./node_modules/typescript/bin/tsc",
5151
"prepare": "husky install"
5252
},

scripts/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
33
"outDir": "../dist/dev-infra-scripts",
4-
"target": "es2015",
5-
"lib": ["es2016"],
4+
"target": "es2020",
5+
"lib": ["es2020"],
66
"moduleResolution": "node",
77
"types": ["node"],
88
"strict": true,

src/bazel-tsconfig-build.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,22 @@
2020
"noImplicitThis": true,
2121
"importHelpers": true,
2222
"strictBindCallApply": true,
23+
"esModuleInterop": true,
2324
"newLine": "lf",
2425
// Bazel either uses "umd" or "esnext". We replicate this here for IDE support.
2526
// https://github.com/bazelbuild/rules_typescript/blob/master/internal/common/tsconfig.bzl#L199
2627
"module": "esnext",
2728
"moduleResolution": "node",
2829
"sourceMap": true,
2930
"inlineSources": true,
30-
"target": "es2015",
31-
"lib": ["es2015", "dom"],
31+
"target": "es2020",
32+
"lib": ["es2020", "dom"],
3233
"skipLibCheck": true,
3334
"types": ["tslib"]
3435
},
3536
"bazelOptions": {
3637
// Note: We can remove this once we fully switched away from Gulp. Currently we still set
3738
// some options here just in favor of the standard tsconfig's which extending this one.
38-
"suppressTsconfigOverrideWarnings": true,
39-
// See https://github.com/angular/angular/issues/29107
40-
"devmodeTargetOverride": "es5"
39+
"suppressTsconfigOverrideWarnings": true
4140
}
4241
}

src/bazel-tsconfig-test.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
"types": ["jasmine"]
99
},
1010
"bazelOptions": {
11-
"suppressTsconfigOverrideWarnings": true,
12-
// See https://github.com/angular/angular/issues/29107
13-
"devmodeTargetOverride": "es5"
11+
"suppressTsconfigOverrideWarnings": true
1412
}
1513
}

src/cdk/schematics/BUILD.bazel

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ ts_library(
2222
"testing/**/*.ts",
2323
],
2424
),
25-
# Schematics do not need to run in browsers and can use `commonjs`
26-
# as format instead the default `umd` format.
25+
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
26+
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
2727
devmode_module = "commonjs",
2828
prodmode_module = "commonjs",
2929
tsconfig = ":tsconfig.json",
@@ -73,6 +73,10 @@ ts_library(
7373
"**/files/**/*.spec.ts",
7474
],
7575
),
76+
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
77+
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
78+
devmode_module = "commonjs",
79+
prodmode_module = "commonjs",
7680
tsconfig = ":tsconfig.json",
7781
deps = [
7882
":schematics",

src/cdk/schematics/testing/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ts_library(
66
name = "testing",
77
testonly = True,
88
srcs = glob(["**/*.ts"]),
9-
# Schematics do not need to run in browsers and can use `commonjs`
10-
# as format instead the default `umd` format.
9+
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
10+
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
1111
devmode_module = "commonjs",
1212
prodmode_module = "commonjs",
1313
tsconfig = "tsconfig.json",

src/cdk/schematics/update-tool/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package(default_visibility = ["//visibility:public"])
55
ts_library(
66
name = "update-tool",
77
srcs = glob(["**/*.ts"]),
8-
# Schematics do not need to run in browsers and can use `commonjs`
9-
# as format instead the default `umd` format.
8+
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
9+
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
1010
devmode_module = "commonjs",
1111
prodmode_module = "commonjs",
1212
tsconfig = ":tsconfig.json",

src/cdk/testing/tests/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ ts_library(
8282
name = "webdriver_test_sources",
8383
testonly = True,
8484
srcs = ["webdriver.e2e.spec.ts"],
85+
# TODO(ESM): remove this once the Bazel NodeJS rules can handle ESM with `nodejs_binary`.
86+
devmode_module = "commonjs",
8587
deps = [
8688
":cross_environment_specs",
8789
":test_harnesses",

src/components-examples/material/datepicker/BUILD.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@npm//@bazel/typescript:index.bzl", "ts_config")
21
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
32

43
package(default_visibility = ["//visibility:public"])
@@ -13,7 +12,6 @@ ng_module(
1312
"**/*.html",
1413
"**/*.css",
1514
]),
16-
tsconfig = ":tsconfig",
1715
deps = [
1816
"//src/cdk/testing",
1917
"//src/cdk/testing/testbed",
@@ -33,12 +31,6 @@ ng_module(
3331
],
3432
)
3533

36-
ts_config(
37-
name = "tsconfig",
38-
src = "tsconfig-build.json",
39-
deps = ["//src:bazel-tsconfig-build.json"],
40-
)
41-
4234
filegroup(
4335
name = "source-files",
4436
srcs = glob([

0 commit comments

Comments
 (0)