mini-css-extract-plugin
Advanced tools
Comparing version
@@ -70,7 +70,5 @@ "use strict"; | ||
this.sourceMap = sourceMap; | ||
this.buildInfo = { | ||
assets, | ||
assetsInfo | ||
}; | ||
this.buildMeta = {}; | ||
this.assets = assets; | ||
this.assetsInfo = assetsInfo; | ||
this._needBuild = true; | ||
} // no source() so webpack 4 doesn't do add stuff to the bundle | ||
@@ -114,5 +112,10 @@ | ||
updateCacheModule(module) { | ||
this.content = module.content; | ||
this.media = module.media; | ||
this.sourceMap = module.sourceMap; | ||
if (this.content !== module.content || this.media !== module.media || this.sourceMap !== module.sourceMap || this.assets !== module.assets || this.assetsInfo !== module.assetsInfo) { | ||
this._needBuild = true; | ||
this.content = module.content; | ||
this.media = module.media; | ||
this.sourceMap = module.sourceMap; | ||
this.assets = module.assets; | ||
this.assetsInfo = module.assetsInfo; | ||
} | ||
} // eslint-disable-next-line class-methods-use-this | ||
@@ -122,3 +125,3 @@ | ||
needRebuild() { | ||
return true; | ||
return this._needBuild; | ||
} // eslint-disable-next-line class-methods-use-this | ||
@@ -128,18 +131,30 @@ | ||
needBuild(context, callback) { | ||
callback(null, false); | ||
callback(null, this._needBuild); | ||
} | ||
build(options, compilation, resolver, fileSystem, callback) { | ||
this.buildInfo = {}; | ||
this.buildInfo = { | ||
assets: this.assets, | ||
assetsInfo: this.assetsInfo, | ||
cacheable: true, | ||
hash: this._computeHash(compilation.outputOptions.hashFunction) | ||
}; | ||
this.buildMeta = {}; | ||
this._needBuild = false; | ||
callback(); | ||
} | ||
updateHash(hash, context) { | ||
super.updateHash(hash, context); | ||
_computeHash(hashFunction) { | ||
const hash = webpack.util.createHash(hashFunction); | ||
hash.update(this.content); | ||
hash.update(this.media || ''); | ||
hash.update(this.sourceMap ? JSON.stringify(this.sourceMap) : ''); | ||
hash.update(this.sourceMap || ''); | ||
return hash.digest('hex'); | ||
} | ||
updateHash(hash, context) { | ||
super.updateHash(hash, context); | ||
hash.update(this.buildInfo.hash); | ||
} | ||
serialize(context) { | ||
@@ -155,3 +170,5 @@ const { | ||
write(this.sourceMap); | ||
write(this.buildInfo); | ||
write(this.assets); | ||
write(this.assetsInfo); | ||
write(this._needBuild); | ||
super.serialize(context); | ||
@@ -161,2 +178,3 @@ } | ||
deserialize(context) { | ||
this._needBuild = context.read(); | ||
super.deserialize(context); | ||
@@ -185,6 +203,4 @@ } | ||
const sourceMap = read(); | ||
const { | ||
assets, | ||
assetsInfo | ||
} = read(); | ||
const assets = read(); | ||
const assetsInfo = read(); | ||
const dep = new CssModule({ | ||
@@ -350,3 +366,3 @@ context: contextModule, | ||
if (!compiler.options.experiments) { | ||
throw new Error('experimentalUseImportModule is only support for webpack >= 5.32.0'); | ||
throw new Error('experimentalUseImportModule is only support for webpack >= 5.33.2'); | ||
} | ||
@@ -535,6 +551,10 @@ | ||
for (const m of modules) { | ||
m.updateHash(hash, { | ||
chunkGraph | ||
}); | ||
if (isWebpack4) { | ||
for (const m of modules) { | ||
m.updateHash(hash); | ||
} | ||
} else { | ||
for (const m of modules) { | ||
hash.update(chunkGraph.getModuleHash(m, chunk.runtime)); | ||
} | ||
} // eslint-disable-next-line no-param-reassign | ||
@@ -541,0 +561,0 @@ |
{ | ||
"name": "mini-css-extract-plugin", | ||
"version": "1.6.1", | ||
"version": "1.6.2", | ||
"description": "extracts CSS into separate files", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
90754
1.05%1402
1.37%