mirror of https://github.com/webpack/webpack.git
(fix): pr comments
This commit is contained in:
parent
d35cf1e056
commit
ee0c891c67
|
@ -423,6 +423,21 @@ export type ChunkLoadTimeout = number;
|
||||||
* The global variable used by webpack for loading of chunks.
|
* The global variable used by webpack for loading of chunks.
|
||||||
*/
|
*/
|
||||||
export type ChunkLoadingGlobal = string;
|
export type ChunkLoadingGlobal = string;
|
||||||
|
/**
|
||||||
|
* Clean the output directory before emit.
|
||||||
|
*/
|
||||||
|
export type CleanPlugin =
|
||||||
|
| boolean
|
||||||
|
| {
|
||||||
|
/**
|
||||||
|
* Log the assets that should be removed instead of delete them.
|
||||||
|
*/
|
||||||
|
dry?: boolean;
|
||||||
|
/**
|
||||||
|
* Not delete the assets, that matches to this regexp or a function.
|
||||||
|
*/
|
||||||
|
ignore?: RegExp | ((asset: string) => boolean);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
||||||
*/
|
*/
|
||||||
|
@ -1735,7 +1750,7 @@ export interface Output {
|
||||||
/**
|
/**
|
||||||
* Clean the output directory before emit.
|
* Clean the output directory before emit.
|
||||||
*/
|
*/
|
||||||
clean?: boolean | CleanPlugin;
|
clean?: CleanPlugin;
|
||||||
/**
|
/**
|
||||||
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
||||||
*/
|
*/
|
||||||
|
@ -1889,23 +1904,6 @@ export interface Output {
|
||||||
*/
|
*/
|
||||||
workerWasmLoading?: WasmLoading;
|
workerWasmLoading?: WasmLoading;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Clean the output directory before emit.
|
|
||||||
*/
|
|
||||||
export interface CleanPlugin {
|
|
||||||
/**
|
|
||||||
* Log the assets that should be removed instead of delete them.
|
|
||||||
*/
|
|
||||||
dry?: boolean;
|
|
||||||
/**
|
|
||||||
* Is clean enabled.
|
|
||||||
*/
|
|
||||||
enabled?: boolean;
|
|
||||||
/**
|
|
||||||
* Not delete the assets, that matches to this regexp or a function.
|
|
||||||
*/
|
|
||||||
ignore?: RegExp | ((asset: string) => boolean);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* The abilities of the environment where the webpack generated code should run.
|
* The abilities of the environment where the webpack generated code should run.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,10 +9,6 @@ export interface CleanPluginArgument {
|
||||||
* Log the assets that should be removed instead of delete them.
|
* Log the assets that should be removed instead of delete them.
|
||||||
*/
|
*/
|
||||||
dry?: boolean;
|
dry?: boolean;
|
||||||
/**
|
|
||||||
* Is clean enabled.
|
|
||||||
*/
|
|
||||||
enabled?: boolean;
|
|
||||||
/**
|
/**
|
||||||
* Not delete the assets, that matches to this regexp or a function.
|
* Not delete the assets, that matches to this regexp or a function.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -63,8 +63,8 @@ class CleanPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {CleanPluginArgument} [options] options */
|
/** @param {CleanPluginArgument} [options] options */
|
||||||
constructor(options) {
|
constructor(options = {}) {
|
||||||
this.options = Object.assign({ enabled: true, dry: false }, options || {});
|
this.options = { dry: false, ...options };
|
||||||
|
|
||||||
if (options && typeof options === "object") {
|
if (options && typeof options === "object") {
|
||||||
validate(schema, options, {
|
validate(schema, options, {
|
||||||
|
@ -174,7 +174,7 @@ class CleanPlugin {
|
||||||
|
|
||||||
if (this.ignoreList.some(ignore => checkToIgnore(ignore, child))) {
|
if (this.ignoreList.some(ignore => checkToIgnore(ignore, child))) {
|
||||||
if (this.options.dry) {
|
if (this.options.dry) {
|
||||||
this.logger.info(`[${child}] was ignored`);
|
this.logger.info(`[${child}] will be ignored in non-dry mode`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return callback();
|
return callback();
|
||||||
|
@ -188,7 +188,9 @@ class CleanPlugin {
|
||||||
if (stat.isFile()) {
|
if (stat.isFile()) {
|
||||||
if (this.fsState.files.has(child)) {
|
if (this.fsState.files.has(child)) {
|
||||||
if (this.options.dry) {
|
if (this.options.dry) {
|
||||||
this.logger.info(`[${child}] was ignored`);
|
this.logger.info(
|
||||||
|
`[${child}] will be ignored in non-dry mode`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return callback();
|
return callback();
|
||||||
|
|
|
@ -168,7 +168,9 @@ class WebpackOptionsApply extends OptionsApply {
|
||||||
|
|
||||||
if (options.output.clean) {
|
if (options.output.clean) {
|
||||||
const CleanPlugin = require("./CleanPlugin");
|
const CleanPlugin = require("./CleanPlugin");
|
||||||
new CleanPlugin(options.output.clean).apply(compiler);
|
new CleanPlugin(
|
||||||
|
options.output.clean === true ? {} : options.output.clean
|
||||||
|
).apply(compiler);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.devtool) {
|
if (options.devtool) {
|
||||||
|
|
|
@ -251,10 +251,7 @@ const getNormalizedWebpackOptions = config => {
|
||||||
chunkLoading: output.chunkLoading,
|
chunkLoading: output.chunkLoading,
|
||||||
chunkLoadingGlobal: output.chunkLoadingGlobal,
|
chunkLoadingGlobal: output.chunkLoadingGlobal,
|
||||||
chunkLoadTimeout: output.chunkLoadTimeout,
|
chunkLoadTimeout: output.chunkLoadTimeout,
|
||||||
clean:
|
clean: output.clean,
|
||||||
typeof output.clean === "boolean"
|
|
||||||
? { enabled: output.clean }
|
|
||||||
: output.clean,
|
|
||||||
compareBeforeEmit: output.compareBeforeEmit,
|
compareBeforeEmit: output.compareBeforeEmit,
|
||||||
crossOriginLoading: output.crossOriginLoading,
|
crossOriginLoading: output.crossOriginLoading,
|
||||||
devtoolFallbackModuleFilenameTemplate:
|
devtoolFallbackModuleFilenameTemplate:
|
||||||
|
|
|
@ -130,6 +130,11 @@
|
||||||
},
|
},
|
||||||
"CleanPlugin": {
|
"CleanPlugin": {
|
||||||
"description": "Clean the output directory before emit.",
|
"description": "Clean the output directory before emit.",
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -137,10 +142,6 @@
|
||||||
"description": "Log the assets that should be removed instead of delete them.",
|
"description": "Log the assets that should be removed instead of delete them.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"enabled": {
|
|
||||||
"description": "Is clean enabled.",
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"ignore": {
|
"ignore": {
|
||||||
"description": "Not delete the assets, that matches to this regexp or a function.",
|
"description": "Not delete the assets, that matches to this regexp or a function.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
|
@ -155,6 +156,8 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"CompareBeforeEmit": {
|
"CompareBeforeEmit": {
|
||||||
"description": "Check if to be emitted file already exists and have the same content before writing to output filesystem.",
|
"description": "Check if to be emitted file already exists and have the same content before writing to output filesystem.",
|
||||||
|
@ -1908,15 +1911,7 @@
|
||||||
"$ref": "#/definitions/ChunkLoadingGlobal"
|
"$ref": "#/definitions/ChunkLoadingGlobal"
|
||||||
},
|
},
|
||||||
"clean": {
|
"clean": {
|
||||||
"description": "Clean the output directory before emit.",
|
|
||||||
"anyOf": [
|
|
||||||
{
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"$ref": "#/definitions/CleanPlugin"
|
"$ref": "#/definitions/CleanPlugin"
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"compareBeforeEmit": {
|
"compareBeforeEmit": {
|
||||||
"$ref": "#/definitions/CompareBeforeEmit"
|
"$ref": "#/definitions/CompareBeforeEmit"
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
"description": "Log the assets that should be removed instead of delete them.",
|
"description": "Log the assets that should be removed instead of delete them.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"enabled": {
|
|
||||||
"description": "Is clean enabled.",
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"ignore": {
|
"ignore": {
|
||||||
"description": "Not delete the assets, that matches to this regexp or a function.",
|
"description": "Not delete the assets, that matches to this regexp or a function.",
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
|
|
|
@ -2133,19 +2133,6 @@ Object {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"simpleType": "boolean",
|
"simpleType": "boolean",
|
||||||
},
|
},
|
||||||
"output-clean-enabled": Object {
|
|
||||||
"configs": Array [
|
|
||||||
Object {
|
|
||||||
"description": "Is clean enabled.",
|
|
||||||
"multiple": false,
|
|
||||||
"path": "output.clean.enabled",
|
|
||||||
"type": "boolean",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"description": "Is clean enabled.",
|
|
||||||
"multiple": false,
|
|
||||||
"simpleType": "boolean",
|
|
||||||
},
|
|
||||||
"output-clean-ignore": Object {
|
"output-clean-ignore": Object {
|
||||||
"configs": Array [
|
"configs": Array [
|
||||||
Object {
|
Object {
|
||||||
|
|
|
@ -1002,19 +1002,23 @@ declare interface CleanPluginArgument {
|
||||||
*/
|
*/
|
||||||
dry?: boolean;
|
dry?: boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* Is clean enabled.
|
|
||||||
*/
|
|
||||||
enabled?: boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not delete the assets, that matches to this regexp or a function.
|
* Not delete the assets, that matches to this regexp or a function.
|
||||||
*/
|
*/
|
||||||
ignore?: RegExp | ((asset: string) => boolean);
|
ignore?: RegExp | ((asset: string) => boolean);
|
||||||
}
|
}
|
||||||
declare class CleanPluginClass {
|
declare class CleanPluginClass {
|
||||||
constructor(options: CleanPluginArgument);
|
constructor(options?: CleanPluginArgument);
|
||||||
options: { enabled: boolean; dry: boolean } & CleanPluginArgument;
|
options: {
|
||||||
|
/**
|
||||||
|
* Log the assets that should be removed instead of delete them.
|
||||||
|
*/
|
||||||
|
dry: boolean;
|
||||||
|
/**
|
||||||
|
* Not delete the assets, that matches to this regexp or a function.
|
||||||
|
*/
|
||||||
|
ignore?: RegExp | ((asset: string) => boolean);
|
||||||
|
};
|
||||||
ignoreList: (RegExp | ((arg0: string) => boolean))[];
|
ignoreList: (RegExp | ((arg0: string) => boolean))[];
|
||||||
logger: WebpackLogger;
|
logger: WebpackLogger;
|
||||||
fs: OutputFileSystem;
|
fs: OutputFileSystem;
|
||||||
|
@ -1035,26 +1039,18 @@ declare interface CleanPluginCompilationHooks {
|
||||||
void
|
void
|
||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
|
type CleanPluginWebpackOptions =
|
||||||
/**
|
| boolean
|
||||||
* Clean the output directory before emit.
|
| {
|
||||||
*/
|
|
||||||
declare interface CleanPluginWebpackOptions {
|
|
||||||
/**
|
/**
|
||||||
* Log the assets that should be removed instead of delete them.
|
* Log the assets that should be removed instead of delete them.
|
||||||
*/
|
*/
|
||||||
dry?: boolean;
|
dry?: boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* Is clean enabled.
|
|
||||||
*/
|
|
||||||
enabled?: boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Not delete the assets, that matches to this regexp or a function.
|
* Not delete the assets, that matches to this regexp or a function.
|
||||||
*/
|
*/
|
||||||
ignore?: RegExp | ((asset: string) => boolean);
|
ignore?: RegExp | ((asset: string) => boolean);
|
||||||
}
|
};
|
||||||
declare interface CodeGenerationContext {
|
declare interface CodeGenerationContext {
|
||||||
/**
|
/**
|
||||||
* the dependency templates
|
* the dependency templates
|
||||||
|
@ -6153,7 +6149,7 @@ declare interface Output {
|
||||||
/**
|
/**
|
||||||
* Clean the output directory before emit.
|
* Clean the output directory before emit.
|
||||||
*/
|
*/
|
||||||
clean?: boolean | CleanPluginWebpackOptions;
|
clean?: CleanPluginWebpackOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
* Check if to be emitted file already exists and have the same content before writing to output filesystem.
|
||||||
|
|
Loading…
Reference in New Issue