Skip to content

Commit 6f32259

Browse files
committed
build: ship schematic code with ES2015 as target
This commit switches the schematic code to build as ES2015. This is necessary to support Node v12 which is still supported in LTS mode
1 parent 0589791 commit 6f32259

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

src/cdk/schematics/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ ts_library(
2222
"testing/**/*.ts",
2323
],
2424
),
25+
devmode_module = "commonjs",
2526
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
2627
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
27-
devmode_module = "commonjs",
28+
devmode_target = "es2015",
2829
prodmode_module = "commonjs",
30+
prodmode_target = "es2015",
2931
tsconfig = ":tsconfig.json",
3032
deps = [
3133
"//src/cdk/schematics/update-tool",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ package(default_visibility = ["//visibility:public"])
55
ts_library(
66
name = "update-tool",
77
srcs = glob(["**/*.ts"]),
8+
devmode_module = "commonjs",
89
# Schematics can not yet run in ESM module. For now we continue to use CommonJS.
910
# TODO(ESM): remove this once the Angular CLI supports ESM schematics.
10-
devmode_module = "commonjs",
11+
devmode_target = "es2015",
1112
prodmode_module = "commonjs",
13+
prodmode_target = "es2015",
1214
tsconfig = ":tsconfig.json",
1315
deps = [
1416
"@npm//@types/node",

src/material/schematics/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ ts_library(
2323
"ng-generate/*/files/**/*.ts",
2424
],
2525
),
26+
devmode_module = "commonjs",
2627
# Schematics do not need to run in browsers and can use `commonjs`
2728
# as format instead the default `umd` format.
28-
devmode_module = "commonjs",
29+
devmode_target = "es2015",
2930
prodmode_module = "commonjs",
31+
prodmode_target = "es2015",
3032
tsconfig = ":tsconfig.json",
3133
deps = [
3234
"//src/cdk/schematics",

tools/defaults.bzl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ def sass_library(**kwargs):
6565
def npm_sass_library(**kwargs):
6666
_npm_sass_library(**kwargs)
6767

68-
def ts_library(tsconfig = None, deps = [], testonly = False, devmode_module = None, **kwargs):
68+
def ts_library(
69+
tsconfig = None,
70+
deps = [],
71+
testonly = False,
72+
# TODO(devversion): disallow configuration of the target when schematics use ESM.
73+
devmode_target = None,
74+
prodmode_target = None,
75+
devmode_module = None,
76+
**kwargs):
6977
# Add tslib because we use import helpers for all public packages.
7078
local_deps = ["@npm//tslib"] + deps
7179

@@ -85,10 +93,10 @@ def ts_library(tsconfig = None, deps = [], testonly = False, devmode_module = No
8593
# For prodmode, the target is set to `ES2020`. `@bazel/typecript` sets `ES2015` by default. Note
8694
# that this should be in sync with the `ng_module` tsconfig generation to emit proper APF v13.
8795
# https://github.com/bazelbuild/rules_nodejs/blob/901df3868e3ceda177d3ed181205e8456a5592ea/third_party/github.com/bazelbuild/rules_typescript/internal/common/tsconfig.bzl#L195
88-
prodmode_target = "es2020",
96+
prodmode_target = prodmode_target if prodmode_target != None else "es2020",
8997
# We also set devmode output to the same settings as prodmode as a first step in combining
9098
# devmode and prodmode output. We will not rely on AMD output anyway due to the linker processing.
91-
devmode_target = "es2020",
99+
devmode_target = devmode_target if devmode_target != None else "es2020",
92100
devmode_module = devmode_module if devmode_module != None else "esnext",
93101
tsconfig = tsconfig,
94102
testonly = testonly,

0 commit comments

Comments
 (0)