File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint-disable
2
2
no-param-reassign
3
3
*/
4
- import crypto from 'crypto' ;
5
4
import path from 'path' ;
6
5
7
6
import { SourceMapConsumer } from 'source-map' ;
@@ -16,6 +15,19 @@ import schema from './options.json';
16
15
import TaskRunner from './TaskRunner' ;
17
16
18
17
const warningRegex = / \[ .+ : ( [ 0 - 9 ] + ) , ( [ 0 - 9 ] + ) \] / ;
18
+ const internalCreateHash = ( algorithm ) => {
19
+ try {
20
+ // eslint-disable-next-line global-require
21
+ const createHash = require ( 'webpack/lib/util/createHash' ) ;
22
+
23
+ return createHash ( algorithm ) ;
24
+ } catch ( err ) {
25
+ // Ignore
26
+ }
27
+
28
+ // eslint-disable-next-line global-require
29
+ return require ( 'crypto' ) . createHash ( algorithm ) ;
30
+ } ;
19
31
20
32
class TerserPlugin {
21
33
constructor ( options = { } ) {
@@ -236,8 +248,7 @@ class TerserPlugin {
236
248
// eslint-disable-next-line global-require
237
249
'terser-webpack-plugin' : require ( '../package.json' ) . version ,
238
250
'terser-webpack-plugin-options' : this . options ,
239
- hash : crypto
240
- . createHash ( 'md4' )
251
+ hash : internalCreateHash ( 'md4' )
241
252
. update ( input )
242
253
. digest ( 'hex' ) ,
243
254
} ;
You can’t perform that action at this time.
0 commit comments