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 * Number of milliseconds before chunk request expires
*/ */
chunkLoadTimeout?: number; 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. * This option enables cross-origin loading of chunks.
*/ */

View File

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

View File

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

View File

@ -1123,6 +1123,10 @@
"description": "Number of milliseconds before chunk request expires", "description": "Number of milliseconds before chunk request expires",
"type": "number" "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": { "crossOriginLoading": {
"description": "This option enables cross-origin loading of chunks.", "description": "This option enables cross-origin loading of chunks.",
"enum": [false, "anonymous", "use-credentials"] "enum": [false, "anonymous", "use-credentials"]