Skip to content

Commit

Permalink
feat(ts_library): bump default target to es2015
Browse files Browse the repository at this point in the history
Closes bazel-contrib#217

PiperOrigin-RevId: 225095761
  • Loading branch information
Fabian Wiles authored and alexeagle committed Dec 12, 2018
1 parent 509469b commit f608b10
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load(":devmode_consumer.bzl", "devmode_consumer")

devmode_consumer(
name = "devmode_consumer",
deps = ["//examples:bar_ts_library"],
)

sh_test(
name = "devmode_consumer_test",
srcs = ["devmode_consumer_test.sh"],
data = [
":devmode_consumer",
"@bazel_tools//tools/bash/runfiles",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Example of a rule that requires ES5 (devmode) inputs.
"""Example of a rule that requires es2015 (devmode) inputs.
"""

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

def _es5_consumer(ctx):
def _devmode_consumer(ctx):
files = depset()

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

es5_consumer = rule(
implementation = _es5_consumer,
devmode_consumer = rule(
implementation = _devmode_consumer,
attrs = {
"deps": attr.label_list(aspects = [sources_aspect]),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,10 @@ if [[ "$FOO_JS" != *"define(\"build_bazel_rules_typescript/examples/foo\""* ]];
echo "$FOO_JS"
exit 1
fi

# should produce es2015 classes
if [[ "$FOO_JS" != *"class Greeter"* ]]; then
echo "Expected foo.js produce a es2015, but was"
echo "$FOO_JS"
exit 1
fi

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ ts_library(
tsconfig = "tsconfig.json",
)

load("//examples/es5_output:es5_consumer.bzl", "es5_consumer")
load("//examples/devmode_consumer:devmode_consumer.bzl", "devmode_consumer")

es5_consumer(
name = "es5_output",
devmode_consumer(
name = "devmode_output",
deps = [":googmodule"],
)

Expand All @@ -19,7 +19,7 @@ jasmine_node_test(
name = "googmodule_output_test",
srcs = ["googmodule_output_test.js"],
data = [
":es5_output",
":devmode_output",
"@npm//jasmine",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ def tsc_wrapped_tsconfig(
)
config["bazelOptions"]["nodeModulesPrefix"] = node_modules_root

# Override the target so we use es2015 for devmode
# Since g3 isn't ready to do this yet
config["compilerOptions"]["target"] = "es2015"

# If the user gives a tsconfig attribute, the generated file should extend
# from the user's tsconfig.
# See https://github.com/Microsoft/TypeScript/issues/9876
Expand Down

0 comments on commit f608b10

Please sign in to comment.