Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(esbuild): allow passing additional args to the npm install for esbuild #3063

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
)