allow to disable compareBeforeEmit

This commit is contained in:
Tobias Koppers 2019-11-04 16:46:45 +01:00
parent 019e35bf26
commit 07671f3481
4 changed files with 21 additions and 8 deletions

View File

@ -1180,6 +1180,10 @@ export interface OutputOptions {
* Number of milliseconds before chunk request expires
*/
chunkLoadTimeout?: number;
/**
* Check if to be emitted file already exists and have the same content before writing to output filesystem
*/
compareBeforeEmit?: boolean;
/**
* This option enables cross-origin loading of chunks.
*/

View File

@ -581,15 +581,19 @@ class Compiler {
}
}
this.outputFileSystem.stat(targetPath, (err, stats) => {
const exists = !err && stats.isFile();
if (this.options.output.compareBeforeEmit) {
this.outputFileSystem.stat(targetPath, (err, stats) => {
const exists = !err && stats.isFile();
if (exists) {
processExistingFile(stats);
} else {
processMissingFile();
}
});
if (exists) {
processExistingFile(stats);
} else {
processMissingFile();
}
});
} else {
processMissingFile();
}
};
if (targetFile.match(/\/|\\/)) {

View File

@ -232,6 +232,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
this.set("output.webassemblyModuleFilename", "[hash].module.wasm");
this.set("output.library", "");
this.set("output.publicPath", "");
this.set("output.compareBeforeEmit", true);
this.set("output.hotUpdateFunction", "make", options => {
return Template.toIdentifier(
"webpackHotUpdate" + Template.toIdentifier(options.output.library)

View File

@ -1123,6 +1123,10 @@
"description": "Number of milliseconds before chunk request expires",
"type": "number"
},
"compareBeforeEmit": {
"description": "Check if to be emitted file already exists and have the same content before writing to output filesystem",
"type": "boolean"
},
"crossOriginLoading": {
"description": "This option enables cross-origin loading of chunks.",
"enum": [false, "anonymous", "use-credentials"]