Skip to content

Commit 7493eb1

Browse files
Fabian Wilesalexeagle
Fabian Wiles
authored andcommitted
feat(ts_library): bump default target to es2015
Closes bazel-contrib#217 PiperOrigin-RevId: 225095761
1 parent bc494ff commit 7493eb1

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
load(":devmode_consumer.bzl", "devmode_consumer")
2+
3+
devmode_consumer(
4+
name = "devmode_consumer",
5+
deps = ["//examples:bar_ts_library"],
6+
)
7+
8+
sh_test(
9+
name = "devmode_consumer_test",
10+
srcs = ["devmode_consumer_test.sh"],
11+
data = [
12+
":devmode_consumer",
13+
"@bazel_tools//tools/bash/runfiles",
14+
],
15+
)

third_party/github.com/bazelbuild/rules_typescript/examples/es5_output/es5_consumer.bzl renamed to third_party/github.com/bazelbuild/rules_typescript/examples/devmode_consumer/devmode_consumer.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Example of a rule that requires ES5 (devmode) inputs.
15+
"""Example of a rule that requires es2015 (devmode) inputs.
1616
"""
1717

1818
load("@build_bazel_rules_nodejs//internal:node.bzl", "sources_aspect")
1919

20-
def _es5_consumer(ctx):
20+
def _devmode_consumer(ctx):
2121
files = depset()
2222

2323
# Since we apply the sources_aspect to our deps below, we can iterate through
@@ -32,8 +32,8 @@ def _es5_consumer(ctx):
3232
runfiles = ctx.runfiles(files.to_list()),
3333
)]
3434

35-
es5_consumer = rule(
36-
implementation = _es5_consumer,
35+
devmode_consumer = rule(
36+
implementation = _devmode_consumer,
3737
attrs = {
3838
"deps": attr.label_list(aspects = [sources_aspect]),
3939
},

third_party/github.com/bazelbuild/rules_typescript/examples/es5_output/es5_output_test.sh renamed to third_party/github.com/bazelbuild/rules_typescript/examples/devmode_consumer/devmode_consumer_test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,10 @@ if [[ "$FOO_JS" != *"define(\"build_bazel_rules_typescript/examples/foo\""* ]];
7979
echo "$FOO_JS"
8080
exit 1
8181
fi
82+
83+
# should produce es2015 classes
84+
if [[ "$FOO_JS" != *"class Greeter"* ]]; then
85+
echo "Expected foo.js produce a es2015, but was"
86+
echo "$FOO_JS"
87+
exit 1
88+
fi

third_party/github.com/bazelbuild/rules_typescript/examples/es5_output/BUILD.bazel

Lines changed: 0 additions & 15 deletions
This file was deleted.

third_party/github.com/bazelbuild/rules_typescript/examples/googmodule/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ ts_library(
66
tsconfig = "tsconfig.json",
77
)
88

9-
load("//examples/es5_output:es5_consumer.bzl", "es5_consumer")
9+
load("//examples/devmode_consumer:devmode_consumer.bzl", "devmode_consumer")
1010

11-
es5_consumer(
12-
name = "es5_output",
11+
devmode_consumer(
12+
name = "devmode_output",
1313
deps = [":googmodule"],
1414
)
1515

@@ -19,7 +19,7 @@ jasmine_node_test(
1919
name = "googmodule_output_test",
2020
srcs = ["googmodule_output_test.js"],
2121
data = [
22-
":es5_output",
22+
":devmode_output",
2323
"@npm//jasmine",
2424
],
2525
)

third_party/github.com/bazelbuild/rules_typescript/internal/build_defs.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ def tsc_wrapped_tsconfig(
187187
)
188188
config["bazelOptions"]["nodeModulesPrefix"] = node_modules_root
189189

190+
# Override the target so we use es2015 for devmode
191+
# Since g3 isn't ready to do this yet
192+
config["compilerOptions"]["target"] = "es2015"
193+
190194
# If the user gives a tsconfig attribute, the generated file should extend
191195
# from the user's tsconfig.
192196
# See https://github.com/Microsoft/TypeScript/issues/9876

0 commit comments

Comments
 (0)