Skip to content

Commit

Permalink
feat(esbuild): add support for plugins via supplying a configuration …
Browse files Browse the repository at this point in the history
…file
  • Loading branch information
mattem authored and alexeagle committed Aug 13, 2021
1 parent 25a08c5 commit 5551bff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/esbuild/esbuild.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "params_file")
load("@build_bazel_rules_nodejs//:providers.bzl", "ExternalNpmPackageInfo", "JSEcmaScriptModuleInfo", "JSModuleInfo", "node_modules_aspect", "run_node")
load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "MODULE_MAPPINGS_ASPECT_RESULTS_NAME", "module_mappings_aspect")
load("@build_bazel_rules_nodejs//packages/esbuild/toolchain:toolchain.bzl", "TOOLCHAIN")
load(":helpers.bzl", "desugar_entry_point_names", "filter_files", "generate_path_mapping", "resolve_entry_point", "write_args_file", "write_jsconfig_file")
load(":helpers.bzl", "desugar_entry_point_names", "filter_files", "generate_path_mapping", "make_deps_target", "resolve_entry_point", "write_args_file", "write_jsconfig_file")

def _esbuild_impl(ctx):
# For each dep, JSEcmaScriptModuleInfo is used if found, then JSModuleInfo and finally
Expand Down Expand Up @@ -154,8 +154,13 @@ def _esbuild_impl(ctx):

if ctx.attr.config:
configs = ctx.attr.config[JSEcmaScriptModuleInfo].sources.to_list()
<<<<<<< HEAD
if len(configs) != 1:
fail("Expected only one source file: the configuration entrypoint")
=======
if len(configs) > 1:
fail("Expected only one source file the configuration entrypoint")
>>>>>>> feat(esbuild): add support for plugins via supplying a configuration file

inputs.append(configs[0])
launcher_args.add("--config_file=%s" % configs[0].path)
Expand Down
3 changes: 3 additions & 0 deletions packages/esbuild/helpers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ TS_EXTENSIONS = ["ts", "tsx"]
JS_EXTENSIONS = ["js", "jsx", "mjs"]
ALLOWED_EXTENSIONS = JS_EXTENSIONS + TS_EXTENSIONS

def make_deps_target(name):
return name + "_deps"

def strip_ext(f):
"Strips the extension of a file."
return f.short_path[:-len(f.extension) - 1]
Expand Down

0 comments on commit 5551bff

Please sign in to comment.