diff --git a/e2e/smoke/BUILD b/e2e/smoke/BUILD index f4b1dc9..7fb89e6 100644 --- a/e2e/smoke/BUILD +++ b/e2e/smoke/BUILD @@ -3,7 +3,7 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") esbuild( name = "lib", - srcs = ["main.js"], + srcs = ["main.js", "tsconfig.json"], entry_point = "main.js", ) diff --git a/e2e/smoke/tsconfig.json b/e2e/smoke/tsconfig.json new file mode 100644 index 0000000..c0a99e3 --- /dev/null +++ b/e2e/smoke/tsconfig.json @@ -0,0 +1 @@ +with invalid syntax, esbuild shouldn't use this \ No newline at end of file diff --git a/esbuild/private/BUILD.bazel b/esbuild/private/BUILD.bazel index 7f5f44f..875f0fb 100644 --- a/esbuild/private/BUILD.bazel +++ b/esbuild/private/BUILD.bazel @@ -6,7 +6,7 @@ exports_files( ) exports_files( - ["launcher.js"], + ["launcher.js", "empty.json"], visibility = ["//visibility:public"], ) diff --git a/esbuild/private/empty.json b/esbuild/private/empty.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/esbuild/private/empty.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/esbuild/private/esbuild.bzl b/esbuild/private/esbuild.bzl index 39e9c69..284e790 100644 --- a/esbuild/private/esbuild.bzl +++ b/esbuild/private/esbuild.bzl @@ -163,6 +163,11 @@ See https://esbuild.github.io/api/#target for more details TODO: show how to write a config file that depends on plugins, similar to the esbuild_config macro in rules_nodejs. """, ), + "_tsconfig": attr.label( + mandatory = False, + allow_single_file = True, + default = Label("@aspect_rules_esbuild//esbuild/private:empty.json"), + ) } def _bin_relative_path(ctx, file): @@ -199,6 +204,7 @@ def _esbuild_impl(ctx): # Also disable the log limit and show all logs "logLevel": "warning", "logLimit": 0, + "tsconfig": _bin_relative_path(ctx, ctx.file._tsconfig), "metafile": ctx.attr.metafile, "platform": ctx.attr.platform, # Don't preserve symlinks since doing so breaks node_modules resolution @@ -306,6 +312,8 @@ def _esbuild_impl(ctx): # inputs.append(ctx.version_file) # env["BAZEL_VERSION_FILE"] = ctx.version_file.path + other_inputs.append(ctx.file._tsconfig) + input_sources = depset( copy_files_to_bin_actions(ctx, [ file diff --git a/esbuild/repositories.bzl b/esbuild/repositories.bzl index b00ef41..024e4c7 100644 --- a/esbuild/repositories.bzl +++ b/esbuild/repositories.bzl @@ -39,6 +39,10 @@ def _esbuild_repo_impl(repository_ctx): Label("@aspect_rules_esbuild//esbuild/private:launcher.js"), "launcher.js", ) + repository_ctx.symlink( + Label("@aspect_rules_esbuild//esbuild/private:empty.json"), + "empty.json", + ) build_content = """#Generated by esbuild/repositories.bzl load("@aspect_rules_esbuild//esbuild:toolchain.bzl", "esbuild_toolchain") load("@aspect_rules_js//js:defs.bzl", "js_binary") @@ -52,7 +56,7 @@ npm_link_package( js_binary( name = "launcher", entry_point = "launcher.js", - data = [":node_modules/esbuild"], + data = [":node_modules/esbuild", ":empty.json"], ) esbuild_toolchain(