Skip to content

Commit

Permalink
fix(esbuild): allow passing additional args to the npm install for es…
Browse files Browse the repository at this point in the history
…build
  • Loading branch information
mattem committed Nov 5, 2021
1 parent 5e2df66 commit 1b17fa6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 7 additions & 1 deletion docs/Toolchains.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Defaults to `""`
**USAGE**

<pre>
esbuild_repositories(<a href="#esbuild_repositories-name">name</a>, <a href="#esbuild_repositories-npm_repository">npm_repository</a>)
esbuild_repositories(<a href="#esbuild_repositories-name">name</a>, <a href="#esbuild_repositories-npm_repository">npm_repository</a>, <a href="#esbuild_repositories-npm_args">npm_args</a>)
</pre>

Helper for fetching and setting up the esbuild versions and toolchains
Expand Down Expand Up @@ -252,4 +252,10 @@ by npm_install or yarn_install.

Defaults to `"npm"`

<h4 id="esbuild_repositories-npm_args">npm_args</h4>

additional args to pass to the npm install rule

Defaults to `[]`


8 changes: 7 additions & 1 deletion docs/esbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ Any other common attributes
**USAGE**

<pre>
esbuild_repositories(<a href="#esbuild_repositories-name">name</a>, <a href="#esbuild_repositories-npm_repository">npm_repository</a>)
esbuild_repositories(<a href="#esbuild_repositories-name">name</a>, <a href="#esbuild_repositories-npm_repository">npm_repository</a>, <a href="#esbuild_repositories-npm_args">npm_args</a>)
</pre>

Helper for fetching and setting up the esbuild versions and toolchains
Expand Down Expand Up @@ -431,4 +431,10 @@ by npm_install or yarn_install.

Defaults to `"npm"`

<h4 id="esbuild_repositories-npm_args">npm_args</h4>

additional args to pass to the npm install rule

Defaults to `[]`


5 changes: 3 additions & 2 deletions toolchains/esbuild/esbuild_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def _maybe(repo_rule, name, **kwargs):
if name not in native.existing_rules():
repo_rule(name = name, **kwargs)

def esbuild_repositories(name = "", npm_repository = "npm"):
def esbuild_repositories(name = "", npm_repository = "npm", npm_args = []):
"""Helper for fetching and setting up the esbuild versions and toolchains
This uses Bazel's downloader (via `http_archive`) to fetch the esbuild package
Expand All @@ -31,6 +31,7 @@ def esbuild_repositories(name = "", npm_repository = "npm"):
name: currently unused
npm_repository: the name of the repository where the @bazel/esbuild package is installed
by npm_install or yarn_install.
npm_args: additional args to pass to the npm install rule
"""

for name, meta in ESBUILD_PACKAGES.platforms.items():
Expand Down Expand Up @@ -68,7 +69,7 @@ def esbuild_repositories(name = "", npm_repository = "npm"):
"--no-optional",
# Disable scripts as we don't need the javascript shim replaced wit the binary.
"--ignore-scripts",
],
] + npm_args,
symlink_node_modules = False,
package_path = package_path,
)

0 comments on commit 1b17fa6

Please sign in to comment.