added unmanagedPaths to snapshot options

This commit is contained in:
Sayan751 2023-10-04 23:28:11 +02:00
parent 36d70c0a6a
commit 7d8799ac4b
No known key found for this signature in database
GPG Key ID: 7E49E200745A666C
9 changed files with 44 additions and 3 deletions

View File

@ -29,3 +29,5 @@ schemas/**/*.check.js
# Ignore example fixtures
examples/
!examples/**/webpack.config.js
.vscode/**/*.*

View File

@ -2376,6 +2376,10 @@ export interface SnapshotOptions {
*/
timestamp?: boolean;
};
/**
* List of paths that are not managed by a package manager and the contents are subject to change.
*/
unmanagedPaths?: (RegExp | string)[];
}
/**
* Stats options object.

View File

@ -885,6 +885,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
this.resolverFactory = compiler.resolverFactory;
this.inputFileSystem = compiler.inputFileSystem;
this.fileSystemInfo = new FileSystemInfo(this.inputFileSystem, {
unmanagedPaths: compiler.unmanagedPaths,
managedPaths: compiler.managedPaths,
immutablePaths: compiler.immutablePaths,
logger: this.getLogger("webpack.FileSystemInfo"),

View File

@ -228,6 +228,8 @@ class Compiler {
/** @type {Set<string | RegExp>} */
this.managedPaths = new Set();
/** @type {Set<string | RegExp>} */
this.unmanagedPaths = new Set();
/** @type {Set<string | RegExp>} */
this.immutablePaths = new Set();
/** @type {ReadonlySet<string> | undefined} */

View File

@ -588,7 +588,8 @@ class WebpackOptionsApply extends OptionsApply {
const AddManagedPathsPlugin = require("./cache/AddManagedPathsPlugin");
new AddManagedPathsPlugin(
options.snapshot.managedPaths,
options.snapshot.immutablePaths
options.snapshot.immutablePaths,
options.snapshot.unmanagedPaths
).apply(compiler);
if (options.cache && typeof options.cache === "object") {

View File

@ -11,10 +11,12 @@ class AddManagedPathsPlugin {
/**
* @param {Iterable<string | RegExp>} managedPaths list of managed paths
* @param {Iterable<string | RegExp>} immutablePaths list of immutable paths
* @param {Iterable<string | RegExp>} unmanagedPaths list of unmanaged paths
*/
constructor(managedPaths, immutablePaths) {
constructor(managedPaths, immutablePaths, unmanagedPaths) {
this.managedPaths = new Set(managedPaths);
this.immutablePaths = new Set(immutablePaths);
this.unmanagedPaths = new Set(unmanagedPaths);
}
/**
@ -29,6 +31,9 @@ class AddManagedPathsPlugin {
for (const immutablePath of this.immutablePaths) {
compiler.immutablePaths.add(immutablePath);
}
for (const unmanagedPath of this.unmanagedPaths) {
compiler.unmanagedPaths.add(unmanagedPath);
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -4614,6 +4614,26 @@
"type": "boolean"
}
}
},
"unmanagedPaths": {
"description": "List of paths that are not managed by a package manager and the contents are subject to change.",
"type": "array",
"items": {
"description": "List of paths that are not managed by a package manager and the contents are subject to change.",
"anyOf": [
{
"description": "A RegExp matching an unmanaged directory.",
"instanceof": "RegExp",
"tsType": "RegExp"
},
{
"description": "A path to an unmanaged directory.",
"type": "string",
"absolutePath": true,
"minLength": 1
}
]
}
}
}
},

6
types.d.ts vendored
View File

@ -2242,6 +2242,7 @@ declare class Compiler {
recordsOutputPath: null | string;
records: object;
managedPaths: Set<string | RegExp>;
unmanagedPaths: Set<string | RegExp>;
immutablePaths: Set<string | RegExp>;
modifiedFiles?: ReadonlySet<string>;
removedFiles?: ReadonlySet<string>;
@ -11941,6 +11942,11 @@ declare interface SnapshotOptionsWebpackOptions {
*/
timestamp?: boolean;
};
/**
* List of paths that are not managed by a package manager and the contents are subject to change.
*/
unmanagedPaths?: (string | RegExp)[];
}
declare abstract class SortableSet<T> extends Set<T> {
/**