From a98eda7eeae1eb24b7074f0b5386e45b1a25e47e Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Mon, 15 Jul 2019 10:18:23 -0700 Subject: [PATCH] fix(builtin): process/browser should resolve from browserify Previously I marked the action local:1 but this masked a real failure in downstream project We can workaround the linked ncc issue to make browserify run correctly --- internal/npm_install/npm_umd_bundle.bzl | 6 ------ scripts/vendor_browserify.sh | 3 +++ third_party/github.com/browserify/browserify/main.js | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/internal/npm_install/npm_umd_bundle.bzl b/internal/npm_install/npm_umd_bundle.bzl index 446818fd3b..25bddf83a8 100644 --- a/internal/npm_install/npm_umd_bundle.bzl +++ b/internal/npm_install/npm_umd_bundle.bzl @@ -48,12 +48,6 @@ def _npm_umd_bundle(ctx): 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 [ diff --git a/scripts/vendor_browserify.sh b/scripts/vendor_browserify.sh index 4f0cc8a4dd..d88322482c 100755 --- a/scripts/vendor_browserify.sh +++ b/scripts/vendor_browserify.sh @@ -11,6 +11,9 @@ echo "Compiling browserify with ncc" echo "Local mod: revert https://github.com/browserify/browserify/pull/1801" sed -i 's#parent.id !== self._mdeps.top.id#parent.id#' third_party/github.com/browserify/browserify/index.js +echo "Local mod: workaround https://github.com/zeit/ncc/issues/461" +sed -i "s#require('process/browser.js')#require('./browser1')#" third_party/github.com/browserify/browserify/main.js + echo "Copy LICENSE" cp -f ./node_modules/browserify/LICENSE ./third_party/github.com/browserify/browserify diff --git a/third_party/github.com/browserify/browserify/main.js b/third_party/github.com/browserify/browserify/main.js index 38c058f19a..7671ab3cf4 100644 --- a/third_party/github.com/browserify/browserify/main.js +++ b/third_party/github.com/browserify/browserify/main.js @@ -1,4 +1,4 @@ -var nextTick = require('process/browser.js').nextTick; +var nextTick = require('./browser1').nextTick; var apply = Function.prototype.apply; var slice = Array.prototype.slice; var immediateIds = {};