Skip to content

Commit 13c09e6

Browse files
committed
fix(builtin): include package.json files in browserify inputs
Required for packages like nise
1 parent b213595 commit 13c09e6

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

internal/npm_install/npm_umd_bundle.bzl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,26 @@ def _npm_umd_bundle(ctx):
3434

3535
sources = ctx.attr.package[NodeModuleSources].sources.to_list()
3636

37-
# Only pass .js files as inputs to browserify
38-
inputs = [f for f in sources if f.path.endswith(".js")]
37+
# Only pass .js and package.json files as inputs to browserify.
38+
# The latter is required for module resolution in some cases.
39+
inputs = [
40+
f
41+
for f in sources
42+
if f.path.endswith(".js") or f.basename == "package.json"
43+
]
3944

4045
ctx.actions.run(
4146
progress_message = "Generated UMD bundle for %s npm package [browserify]" % ctx.attr.package_name,
4247
executable = ctx.executable._browserify_wrapped,
4348
inputs = inputs,
4449
outputs = [output],
4550
arguments = [args],
51+
# browserify may load files from nodejs but these aren't declared as action inputs
52+
# looks like:
53+
# ERROR: /workdir/internal/npm_install/test/BUILD.bazel:50:1: Couldn't build file internal/npm_install/test/sinon.umd.js: Generated UMD bundle for sinon npm package [browserify] failed (Exit 1)
54+
# Error: Cannot find module 'process/browser.js' from '/b/f/w/bazel-out/host/bin/external/build_bazel_rules_nodejs/internal/npm_install/browserify-wrapped.runfiles/build_bazel_rules_nodejs/third_party/github.com/browserify/browserify
55+
# TODO(alexeagle): remove this line and make the tests work with RBE
56+
execution_requirements = {"local": "1"},
4657
)
4758

4859
return [

0 commit comments

Comments
 (0)