File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 33 Author Tobias Koppers @sokra
44*/
55
6- import crypto from "crypto" ;
76import path from "path" ;
87
98import webpack , {
@@ -15,6 +14,20 @@ import serialize from "serialize-javascript";
1514
1615import schema from "./options.json" ;
1716
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+
1831const { RawSource } =
1932 // eslint-disable-next-line global-require
2033 webpack . sources || require ( "webpack-sources" ) ;
@@ -229,7 +242,7 @@ class CompressionPlugin {
229242 originalAlgorithm : this . options . algorithm ,
230243 compressionOptions : this . options . compressionOptions ,
231244 name,
232- contentHash : crypto . createHash ( "md4" ) . update ( input ) . digest ( "hex" ) ,
245+ contentHash : internalCreateHash ( "md4" ) . update ( input ) . digest ( "hex" ) ,
233246 } ;
234247 } else {
235248 cacheData . name = serialize ( {
You can’t perform that action at this time.
0 commit comments