File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 14
14
15
15
var bufferFrom = require ( 'buffer-from' ) ;
16
16
17
+ /**
18
+ * Requires a module which is protected against bundler minification.
19
+ *
20
+ * @param {NodeModule } mod
21
+ * @param {string } request
22
+ */
23
+ function dynamicRequire ( mod , request ) {
24
+ return mod . require ( request ) ;
25
+ }
26
+
17
27
// Only install once if called multiple times
18
28
var errorFormatterInstalled = false ;
19
29
var uncaughtShimInstalled = false ;
@@ -565,9 +575,8 @@ exports.install = function(options) {
565
575
// Worker threads. Workers pass the error to the main thread as an event,
566
576
// rather than printing something to stderr and exiting.
567
577
try {
568
- // Don't let browserify try to resolve this require(), it's pointless
569
- // and breaks the build process.
570
- var worker_threads = require ( 'worker_' + 'threads' ) ;
578
+ // We need to use `dynamicRequire` because `require` on it's own will be optimized by WebPack/Browserify.
579
+ var worker_threads = dynamicRequire ( module , 'worker_threads' ) ;
571
580
if ( worker_threads . isMainThread === false ) {
572
581
installHandler = false ;
573
582
}
You can’t perform that action at this time.
0 commit comments