Skip to content

Commit

Permalink
fix(bazel): esbuild ESM bundles should prioritize ESM main field
Browse files Browse the repository at this point in the history
ESBuild by default with `platform: node` will prioritize `main` and then
check `module` if present. We want it  the other way around as ES
modules are easier to bundle and guaranteed to work.
  • Loading branch information
devversion committed Oct 15, 2022
1 parent 798dbd9 commit f12f251
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions bazel/esbuild/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def esbuild_esm_bundle(name, **kwargs):

args = dict(
resolveExtensions = [".mjs", ".js", ".json"],
mainFields = ["module", "main"],
outExtension = {".js": ".mjs"},
# Workaround for: https://github.com/evanw/esbuild/issues/1921.
banner = {
Expand Down

0 comments on commit f12f251

Please sign in to comment.