Skip to content

Commit

Permalink
Add webpack require hack
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Nov 21, 2018
1 parent 58141c6 commit 40dcc1f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ function bindings (opts) {
opts.bindings += '.node'
}

// https://github.com/webpack/webpack/issues/4175#issuecomment-342931035
var requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require

var tries = []
, i = 0
, l = opts.try.length
Expand All @@ -78,7 +81,7 @@ function bindings (opts) {
}))
tries.push(n)
try {
b = opts.path ? require.resolve(n) : require(n)
b = opts.path ? requireFunc.resolve(n) : requireFunc(n)
if (!opts.path) {
b.path = n
}
Expand Down

0 comments on commit 40dcc1f

Please sign in to comment.