File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ const { minify } = require("./minify");
105
105
/**
106
106
* @typedef {object } MinimizeFunctionHelpers
107
107
* @property {() => string | undefined } [getMinimizerVersion]
108
+ * @property {() => boolean | undefined } [supportsWorkerThreads]
108
109
*/
109
110
110
111
/**
@@ -412,7 +413,12 @@ class TerserPlugin {
412
413
(
413
414
new Worker ( require . resolve ( "./minify" ) , {
414
415
numWorkers : numberOfWorkers ,
415
- enableWorkerThreads : true ,
416
+ enableWorkerThreads :
417
+ typeof this . options . minimizer . implementation
418
+ . supportsWorkerThreads !== "undefined"
419
+ ? this . options . minimizer . implementation . supportsWorkerThreads ( ) !==
420
+ false
421
+ : true ,
416
422
} )
417
423
) ;
418
424
Original file line number Diff line number Diff line change @@ -326,6 +326,11 @@ terserMinify.getMinimizerVersion = () => {
326
326
return packageJson && packageJson . version ;
327
327
} ;
328
328
329
+ /**
330
+ * @returns {boolean | undefined }
331
+ */
332
+ terserMinify . supportsWorkerThreads = ( ) => true ;
333
+
329
334
/* istanbul ignore next */
330
335
/**
331
336
* @param {Input } input
@@ -544,6 +549,11 @@ uglifyJsMinify.getMinimizerVersion = () => {
544
549
return packageJson && packageJson . version ;
545
550
} ;
546
551
552
+ /**
553
+ * @returns {boolean | undefined }
554
+ */
555
+ uglifyJsMinify . supportsWorkerThreads = ( ) => true ;
556
+
547
557
/* istanbul ignore next */
548
558
/**
549
559
* @param {Input } input
@@ -645,6 +655,11 @@ swcMinify.getMinimizerVersion = () => {
645
655
return packageJson && packageJson . version ;
646
656
} ;
647
657
658
+ /**
659
+ * @returns {boolean | undefined }
660
+ */
661
+ swcMinify . supportsWorkerThreads = ( ) => false ;
662
+
648
663
/* istanbul ignore next */
649
664
/**
650
665
* @param {Input } input
@@ -755,6 +770,11 @@ esbuildMinify.getMinimizerVersion = () => {
755
770
return packageJson && packageJson . version ;
756
771
} ;
757
772
773
+ /**
774
+ * @returns {boolean | undefined }
775
+ */
776
+ esbuildMinify . supportsWorkerThreads = ( ) => false ;
777
+
758
778
/**
759
779
* @template T
760
780
* @param fn {(function(): any) | undefined}
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ type BasicMinimizerImplementation<T> = (
192
192
) => Promise < MinimizedResult > ;
193
193
type MinimizeFunctionHelpers = {
194
194
getMinimizerVersion ?: ( ( ) => string | undefined ) | undefined ;
195
+ supportsWorkerThreads ?: ( ( ) => boolean | undefined ) | undefined ;
195
196
} ;
196
197
type MinimizerImplementation < T > = BasicMinimizerImplementation < T > &
197
198
MinimizeFunctionHelpers ;
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ export namespace terserMinify {
51
51
* @returns {string | undefined }
52
52
*/
53
53
function getMinimizerVersion ( ) : string | undefined ;
54
+ /**
55
+ * @returns {boolean | undefined }
56
+ */
57
+ function supportsWorkerThreads ( ) : boolean | undefined ;
54
58
}
55
59
/**
56
60
* @param {Input } input
@@ -70,6 +74,10 @@ export namespace uglifyJsMinify {
70
74
* @returns {string | undefined }
71
75
*/
72
76
function getMinimizerVersion ( ) : string | undefined ;
77
+ /**
78
+ * @returns {boolean | undefined }
79
+ */
80
+ function supportsWorkerThreads ( ) : boolean | undefined ;
73
81
}
74
82
/**
75
83
* @param {Input } input
@@ -87,6 +95,10 @@ export namespace swcMinify {
87
95
* @returns {string | undefined }
88
96
*/
89
97
function getMinimizerVersion ( ) : string | undefined ;
98
+ /**
99
+ * @returns {boolean | undefined }
100
+ */
101
+ function supportsWorkerThreads ( ) : boolean | undefined ;
90
102
}
91
103
/**
92
104
* @param {Input } input
@@ -104,4 +116,8 @@ export namespace esbuildMinify {
104
116
* @returns {string | undefined }
105
117
*/
106
118
function getMinimizerVersion ( ) : string | undefined ;
119
+ /**
120
+ * @returns {boolean | undefined }
121
+ */
122
+ function supportsWorkerThreads ( ) : boolean | undefined ;
107
123
}
You can’t perform that action at this time.
0 commit comments