Skip to content

Commit

Permalink
fix(builtin): include package.json files in browserify inputs
Browse files Browse the repository at this point in the history
Required for packages like nise
  • Loading branch information
alexeagle committed Jul 12, 2019
1 parent b213595 commit 13c09e6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/npm_install/npm_umd_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,26 @@ def _npm_umd_bundle(ctx):

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

# Only pass .js files as inputs to browserify
inputs = [f for f in sources if f.path.endswith(".js")]
# Only pass .js and package.json files as inputs to browserify.
# The latter is required for module resolution in some cases.
inputs = [
f
for f in sources
if f.path.endswith(".js") or f.basename == "package.json"
]

ctx.actions.run(
progress_message = "Generated UMD bundle for %s npm package [browserify]" % ctx.attr.package_name,
executable = ctx.executable._browserify_wrapped,
inputs = inputs,
outputs = [output],
arguments = [args],
# browserify may load files from nodejs but these aren't declared as action inputs
# looks like:
# 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)
# 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
# TODO(alexeagle): remove this line and make the tests work with RBE
execution_requirements = {"local": "1"},
)

return [
Expand Down

0 comments on commit 13c09e6

Please sign in to comment.