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 1414
1515var bufferFrom = require ( 'buffer-from' ) ;
1616
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+
1727// Only install once if called multiple times
1828var errorFormatterInstalled = false ;
1929var uncaughtShimInstalled = false ;
@@ -565,9 +575,8 @@ exports.install = function(options) {
565575 // Worker threads. Workers pass the error to the main thread as an event,
566576 // rather than printing something to stderr and exiting.
567577 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' ) ;
571580 if ( worker_threads . isMainThread === false ) {
572581 installHandler = false ;
573582 }
You can’t perform that action at this time.
0 commit comments