File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 3
3
Author Tobias Koppers @sokra
4
4
*/
5
5
6
- import crypto from "crypto" ;
7
6
import path from "path" ;
8
7
9
8
import webpack , {
@@ -15,6 +14,20 @@ import serialize from "serialize-javascript";
15
14
16
15
import schema from "./options.json" ;
17
16
17
+ const internalCreateHash = ( algorithm ) => {
18
+ try {
19
+ // eslint-disable-next-line global-require import/no-unresolved
20
+ const createHash = require ( "webpack/lib/util/createHash" ) ;
21
+
22
+ return createHash ( algorithm ) ;
23
+ } catch ( err ) {
24
+ // Ignore
25
+ }
26
+
27
+ return require ( "crypto" ) . createHash ( algorithm ) ;
28
+ } ;
29
+
30
+
18
31
const { RawSource } =
19
32
// eslint-disable-next-line global-require
20
33
webpack . sources || require ( "webpack-sources" ) ;
@@ -229,7 +242,7 @@ class CompressionPlugin {
229
242
originalAlgorithm : this . options . algorithm ,
230
243
compressionOptions : this . options . compressionOptions ,
231
244
name,
232
- contentHash : crypto . createHash ( "md4" ) . update ( input ) . digest ( "hex" ) ,
245
+ contentHash : internalCreateHash ( "md4" ) . update ( input ) . digest ( "hex" ) ,
233
246
} ;
234
247
} else {
235
248
cacheData . name = serialize ( {
You can’t perform that action at this time.
0 commit comments