@ohos-ports/rspack-core 2.2.2-beta.0 → 2.3.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/compiled/@rspack/lite-tapable/dist/index.d.ts +20 -6
- package/compiled/@rspack/lite-tapable/package.json +1 -1
- package/compiled/http-proxy-middleware/index.d.ts +10 -10
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/open/package.json +1 -1
- package/compiled/tinypool/README.md +4 -4
- package/compiled/tinypool/dist/index.d.ts +3 -2
- package/compiled/tinypool/dist/index.js +3 -3
- package/compiled/tinypool/package.json +1 -1
- package/compiled/watchpack/index.js +276 -49
- package/compiled/watchpack/package.json +1 -1
- package/compiled/watchpack/types/DirectoryWatcher.d.ts +24 -0
- package/compiled/watchpack/types/index.d.ts +1 -1
- package/compiled/watchpack/types/watchEventSource.d.ts +9 -0
- package/compiled/webpack-sources/index.d.ts +61 -0
- package/compiled/webpack-sources/index.js +858 -224
- package/compiled/webpack-sources/package.json +8 -1
- package/compiled/webpack-sources/types/CachedSource.d.ts +192 -0
- package/compiled/webpack-sources/types/CompatSource.d.ts +87 -0
- package/compiled/webpack-sources/types/ConcatSource.d.ts +75 -0
- package/compiled/webpack-sources/types/OriginalSource.d.ts +87 -0
- package/compiled/webpack-sources/types/PrefixSource.d.ts +59 -0
- package/compiled/webpack-sources/types/RawSource.d.ts +75 -0
- package/compiled/webpack-sources/types/ReplaceSource.d.ts +107 -0
- package/compiled/webpack-sources/types/SizeOnlySource.d.ts +24 -0
- package/compiled/webpack-sources/types/Source.d.ts +189 -0
- package/compiled/webpack-sources/types/SourceMapSource.d.ts +136 -0
- package/compiled/webpack-sources/types/helpers/createMappingsSerializer.d.ts +60 -0
- package/compiled/webpack-sources/types/helpers/getFromStreamChunks.d.ts +16 -0
- package/compiled/webpack-sources/types/helpers/getGeneratedSourceInfo.d.ts +31 -0
- package/compiled/webpack-sources/types/helpers/getName.d.ts +15 -0
- package/compiled/webpack-sources/types/helpers/getSource.d.ts +15 -0
- package/compiled/webpack-sources/types/helpers/readMappings.d.ts +19 -0
- package/compiled/webpack-sources/types/helpers/scopes.d.ts +119 -0
- package/compiled/webpack-sources/types/helpers/splitIntoLines.d.ts +6 -0
- package/compiled/webpack-sources/types/helpers/splitIntoPotentialTokens.d.ts +37 -0
- package/compiled/webpack-sources/types/helpers/streamAndGetSourceAndMap.d.ts +39 -0
- package/compiled/webpack-sources/types/helpers/streamChunks.d.ts +56 -0
- package/compiled/webpack-sources/types/helpers/streamChunksOfCombinedSourceMap.d.ts +42 -0
- package/compiled/webpack-sources/types/helpers/streamChunksOfRawSource.d.ts +16 -0
- package/compiled/webpack-sources/types/helpers/streamChunksOfSourceMap.d.ts +19 -0
- package/compiled/webpack-sources/types/helpers/stringBufferUtils.d.ts +55 -0
- package/compiled/webpack-sources/types/index.d.ts +50 -0
- package/dist/BuildInfo.d.ts +13 -4
- package/dist/Chunk.d.ts +3 -3
- package/dist/ChunkGraph.d.ts +2 -2
- package/dist/Chunks.d.ts +2 -2
- package/dist/CodeGenerationResults.d.ts +6 -1
- package/dist/Compilation.d.ts +16 -53
- package/dist/Compiler.d.ts +9 -10
- package/dist/ConcatenatedModule.d.ts +5 -1
- package/dist/ContextModule.d.ts +3 -1
- package/dist/Diagnostics.d.ts +2 -6
- package/dist/Entrypoint.d.ts +1 -1
- package/dist/ExportsInfo.d.ts +1 -1
- package/dist/ExternalModule.d.ts +7 -6
- package/dist/FileSystem.d.ts +3 -1
- package/dist/FileSystemDependencies.d.ts +15 -0
- package/dist/FileSystemInfo.d.ts +1 -0
- package/dist/Module.d.ts +19 -11
- package/dist/ModuleGraph.d.ts +6 -6
- package/dist/ModuleGraphConnection.d.ts +9 -3
- package/dist/Modules.d.ts +3 -0
- package/dist/NativeWatchFileSystem.d.ts +20 -8
- package/dist/NormalModule.d.ts +14 -6
- package/dist/NormalModuleFactory.d.ts +2 -1
- package/dist/Resolver.d.ts +10 -2
- package/dist/ResolverFactory.d.ts +1 -1
- package/dist/RspackError.d.ts +2 -2
- package/dist/RuntimeGlobals.d.ts +4 -3
- package/dist/RuntimeModule.d.ts +1 -1
- package/dist/RuntimeTemplate.d.ts +1 -0
- package/dist/Stats.d.ts +1 -1
- package/dist/builtin-loader/lightningcss/target.d.ts +1 -1
- package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/BannerPlugin.d.ts +2 -2
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CaseSensitivePlugin.d.ts +1 -1
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CircularCheckRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CircularDependencyRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CircularModulesInfoPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CompactHashedChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CompactHashedModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +2 -2
- package/dist/builtin-plugin/CssChunkingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CssHttpExternalsRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DllEntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/DllReferenceAgencyPlugin.d.ts +2 -2
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +2 -2
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +5 -4
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagAllModulesAsUsedPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
- package/dist/builtin-plugin/HashedModuleIdsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +1 -1
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/HttpUriPlugin.d.ts +5 -1
- package/dist/builtin-plugin/IgnorePlugin.d.ts +2 -2
- package/dist/builtin-plugin/ImportedByDeferModulesPlugin.d.ts +9 -0
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/InlineExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LibManifestPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ModuleInfoHeaderPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NoEmitOnErrorsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
- package/dist/builtin-plugin/NormalModuleReplacementPlugin.d.ts +1 -1
- package/dist/builtin-plugin/OccurrenceChunkIdsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/ProgressPlugin.d.ts +2 -2
- package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/RsdoctorPlugin.d.ts +2 -2
- package/dist/builtin-plugin/RslibPlugin.d.ts +4 -4
- package/dist/builtin-plugin/RstestPlugin.d.ts +2 -2
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +2 -2
- package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +2 -2
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +3 -2
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/SyncModuleIdsPlugin.d.ts +1 -1
- package/dist/builtin-plugin/URLPlugin.d.ts +1 -1
- package/dist/builtin-plugin/WorkerPlugin.d.ts +1 -1
- package/dist/builtin-plugin/base.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/utils.d.ts +4 -1
- package/dist/builtin-plugin/html-plugin/hooks.d.ts +1 -1
- package/dist/builtin-plugin/html-plugin/plugin.d.ts +2 -2
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +3 -3
- package/dist/builtin-plugin/rsc/RscClientPlugin.d.ts +1 -1
- package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +1 -1
- package/dist/config/adapter.d.ts +1 -1
- package/dist/config/adapterRuleUse.d.ts +3 -2
- package/dist/config/normalization.d.ts +5 -8
- package/dist/config/target.d.ts +2 -0
- package/dist/config/types.d.ts +104 -19
- package/dist/container/ContainerPlugin.d.ts +1 -1
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/container/ModuleFederationManifestPlugin.d.ts +1 -1
- package/dist/container/ModuleFederationPluginV1.d.ts +5 -1
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
- package/dist/cssExtractHmr.js +1 -1
- package/dist/cssExtractLoader.js +7 -5
- package/dist/exports.d.ts +7 -7
- package/dist/index.js +1845 -1070
- package/dist/lib/Cache.d.ts +3 -0
- package/dist/lib/DllReferencePlugin.d.ts +1 -1
- package/dist/lib/WebpackError.d.ts +1 -1
- package/dist/loader-runner/codeFilter.d.ts +9 -0
- package/dist/loader-runner/dependencies.d.ts +5 -4
- package/dist/loader-runner/index.d.ts +3 -2
- package/dist/loader-runner/service.d.ts +6 -5
- package/dist/loader-runner/worker.d.ts +5 -2
- package/dist/l~0.js +34 -0
- package/dist/l~3.js +34 -0
- package/dist/node/NodeWatchFileSystem.d.ts +7 -4
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +1 -1
- package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
- package/dist/sharing/ProvideSharedPlugin.d.ts +1 -1
- package/dist/sharing/SharePlugin.d.ts +13 -1
- package/dist/sharing/ShareRuntimePlugin.d.ts +1 -1
- package/dist/sharing/SharedContainerPlugin.d.ts +1 -1
- package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +2 -2
- package/dist/sources.d.ts +3 -0
- package/dist/stats/StatsFactory.d.ts +4 -2
- package/dist/stats/StatsPrinter.d.ts +5 -5
- package/dist/stats/statsFactoryUtils.d.ts +12 -6
- package/dist/swc.d.ts +1 -1
- package/dist/taps/compilation.d.ts +1 -1
- package/dist/taps/types.d.ts +1 -1
- package/dist/util/SplitChunkSize.d.ts +1 -1
- package/dist/util/bindingHelpers.d.ts +9 -0
- package/dist/util/createModule.d.ts +3 -0
- package/dist/util/fs.d.ts +22 -16
- package/dist/util/resolveLayerExternals.d.ts +1 -0
- package/dist/util/source.d.ts +13 -4
- package/dist/util/symbols.d.ts +10 -0
- package/dist/util/watchTimeInfo.d.ts +11 -0
- package/dist/worker.js +386 -353
- package/hot/lazy-compilation-node.js +1 -1
- package/hot/lazy-compilation-web.js +1 -1
- package/package.json +8 -32
- package/compiled/webpack-sources/types.d.ts +0 -500
- package/dist/612~0.js +0 -32
- package/dist/612~3.js +0 -32
- package/dist/loader-runner/cache.d.ts +0 -18
- package/dist/util/MergeCaller.d.ts +0 -10
- package/dist/util/fake.d.ts +0 -11
|
@@ -974,7 +974,7 @@ function patch (fs) {
|
|
|
974
974
|
|
|
975
975
|
/***/ }),
|
|
976
976
|
|
|
977
|
-
/***/
|
|
977
|
+
/***/ 539:
|
|
978
978
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
979
979
|
|
|
980
980
|
"use strict";
|
|
@@ -988,7 +988,7 @@ const { EventEmitter } = __nccwpck_require__(434);
|
|
|
988
988
|
const path = __nccwpck_require__(928);
|
|
989
989
|
const fs = __nccwpck_require__(692);
|
|
990
990
|
|
|
991
|
-
const watchEventSource = __nccwpck_require__(
|
|
991
|
+
const watchEventSource = __nccwpck_require__(370);
|
|
992
992
|
|
|
993
993
|
/** @typedef {import("./index").IgnoredFunction} IgnoredFunction */
|
|
994
994
|
/** @typedef {import("./index").EventType} EventType */
|
|
@@ -1005,6 +1005,12 @@ const EXISTANCE_ONLY_TIME_ENTRY = Object.freeze({});
|
|
|
1005
1005
|
|
|
1006
1006
|
let FS_ACCURACY = 2000;
|
|
1007
1007
|
|
|
1008
|
+
// the OS has no watcher left for the directory, which is still there
|
|
1009
|
+
const WATCHER_LIMIT_ERRORS = new Set(["ENOSPC", "EMFILE"]);
|
|
1010
|
+
// the polling interval of `poll: true`
|
|
1011
|
+
const WATCHER_LIMIT_POLL_INTERVAL = 5007;
|
|
1012
|
+
let watcherLimitReported = false;
|
|
1013
|
+
|
|
1008
1014
|
const IS_OSX = (__nccwpck_require__(857).platform)() === "darwin";
|
|
1009
1015
|
const IS_WIN = (__nccwpck_require__(857).platform)() === "win32";
|
|
1010
1016
|
|
|
@@ -1030,6 +1036,27 @@ const BUSY_RETRIES = (() => {
|
|
|
1030
1036
|
})();
|
|
1031
1037
|
const BUSY_RETRY_DELAY = 100;
|
|
1032
1038
|
|
|
1039
|
+
// A path that is not yet a directory (a file, or a dangling symlink) emits
|
|
1040
|
+
// nothing when it becomes one, so watching it is retried on this interval.
|
|
1041
|
+
const NOT_A_DIRECTORY_RETRY_DELAY = 1000;
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* @param {string} target a path
|
|
1045
|
+
* @returns {"directory" | "missing" | "other"} "other" when the path exists but is not, or does not resolve to, a directory
|
|
1046
|
+
*/
|
|
1047
|
+
const getPathKind = (target) => {
|
|
1048
|
+
try {
|
|
1049
|
+
return fs.statSync(target).isDirectory() ? "directory" : "other";
|
|
1050
|
+
} catch (_err) {
|
|
1051
|
+
try {
|
|
1052
|
+
fs.lstatSync(target);
|
|
1053
|
+
return "other";
|
|
1054
|
+
} catch (_err2) {
|
|
1055
|
+
return "missing";
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1033
1060
|
/**
|
|
1034
1061
|
* @param {string} str string
|
|
1035
1062
|
* @returns {string} lower cased string
|
|
@@ -1192,8 +1219,15 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1192
1219
|
this.files = new Map();
|
|
1193
1220
|
/** @type {Map<string, number>} */
|
|
1194
1221
|
this.filesWithoutCase = new Map();
|
|
1222
|
+
// whether names in this directory ignore case, learned the first time a
|
|
1223
|
+
// watched path differs from a file on disk only by case
|
|
1224
|
+
/** @type {boolean | undefined} */
|
|
1225
|
+
this.caseInsensitive = undefined;
|
|
1195
1226
|
/** @type {Map<string, Watcher<DirectoryWatcherEvents> | boolean>} */
|
|
1196
1227
|
this.directories = new Map();
|
|
1228
|
+
// when each directory was noticed, for watchers that attach later
|
|
1229
|
+
/** @type {Map<string, number>} */
|
|
1230
|
+
this.directorySafeTimes = new Map();
|
|
1197
1231
|
/** @type {Map<string, Watcher<FileWatcherEvents>>} */
|
|
1198
1232
|
this._symlinkTargetWatchers = new Map();
|
|
1199
1233
|
this.lastWatchEvent = 0;
|
|
@@ -1213,10 +1247,16 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1213
1247
|
this.initialScanRemoved = new Set();
|
|
1214
1248
|
/** @type {undefined | number} */
|
|
1215
1249
|
this.initialScanFinished = undefined;
|
|
1250
|
+
// when a known file was removed, so a watcher attaching later with an
|
|
1251
|
+
// earlier start time learns of the removal, as it learns of a change
|
|
1252
|
+
/** @type {Map<string, number>} */
|
|
1253
|
+
this.removedTimes = new Map();
|
|
1216
1254
|
/** @type {Map<string, Set<Watcher<DirectoryWatcherEvents> | Watcher<FileWatcherEvents>>>} */
|
|
1217
1255
|
this.watchers = new Map();
|
|
1218
1256
|
/** @type {Watcher<FileWatcherEvents> | null} */
|
|
1219
1257
|
this.parentWatcher = null;
|
|
1258
|
+
/** @type {undefined | NodeJS.Timeout} */
|
|
1259
|
+
this.retryTimeout = undefined;
|
|
1220
1260
|
this.refs = 0;
|
|
1221
1261
|
/** @type {Map<string, boolean>} */
|
|
1222
1262
|
this._activeEvents = new Map();
|
|
@@ -1250,6 +1290,11 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1250
1290
|
(watchEventSource.watch(this.path));
|
|
1251
1291
|
this.watcher.on("change", this.onWatchEvent.bind(this));
|
|
1252
1292
|
this.watcher.on("error", this.onWatcherError.bind(this));
|
|
1293
|
+
// events lost while the event source restarted show up in a scan
|
|
1294
|
+
this.watcher.on("rescan", () => {
|
|
1295
|
+
if (this.closed || this.initialScan) return;
|
|
1296
|
+
this.doScan(false);
|
|
1297
|
+
});
|
|
1253
1298
|
}
|
|
1254
1299
|
} catch (err) {
|
|
1255
1300
|
this.onWatcherError(err);
|
|
@@ -1288,6 +1333,7 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1288
1333
|
(oldDirectory).close();
|
|
1289
1334
|
}
|
|
1290
1335
|
this.directories.delete(itemPath);
|
|
1336
|
+
this.directorySafeTimes.delete(itemPath);
|
|
1291
1337
|
this.forEachWatcher(itemPath, (w) => w.emit("remove", type));
|
|
1292
1338
|
if (!initial) {
|
|
1293
1339
|
this.forEachWatcher(this.path, (w) =>
|
|
@@ -1299,6 +1345,7 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1299
1345
|
const oldFile = this.files.get(itemPath);
|
|
1300
1346
|
if (oldFile) {
|
|
1301
1347
|
this.files.delete(itemPath);
|
|
1348
|
+
if (!initial) this.removedTimes.set(withoutCase(itemPath), Date.now());
|
|
1302
1349
|
const key = withoutCase(itemPath);
|
|
1303
1350
|
const count = /** @type {number} */ (this.filesWithoutCase.get(key)) - 1;
|
|
1304
1351
|
if (count <= 0) {
|
|
@@ -1357,6 +1404,7 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1357
1404
|
});
|
|
1358
1405
|
|
|
1359
1406
|
if (!old) {
|
|
1407
|
+
this.removedTimes.delete(withoutCase(target));
|
|
1360
1408
|
const key = withoutCase(target);
|
|
1361
1409
|
const count = this.filesWithoutCase.get(key);
|
|
1362
1410
|
this.filesWithoutCase.set(key, (count || 0) + 1);
|
|
@@ -1410,6 +1458,9 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1410
1458
|
}
|
|
1411
1459
|
|
|
1412
1460
|
const safeTime = initial ? Math.min(now, birthtime) + FS_ACCURACY : now;
|
|
1461
|
+
// when it was noticed, not created: a poll can notice it after the
|
|
1462
|
+
// next build started, which then did not see it either
|
|
1463
|
+
this.directorySafeTimes.set(directoryPath, safeTime);
|
|
1413
1464
|
|
|
1414
1465
|
this.forEachWatcher(directoryPath, (w) => {
|
|
1415
1466
|
if (!initial || w.checkStartTime(safeTime, false)) {
|
|
@@ -1506,7 +1557,13 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1506
1557
|
fixupEntryAccuracy(entry);
|
|
1507
1558
|
safeTime = entry.safeTime;
|
|
1508
1559
|
} else {
|
|
1509
|
-
|
|
1560
|
+
// a directory that appeared while no watcher listened, e.g. during
|
|
1561
|
+
// a build whose paused watcher is replaced by this one; internal
|
|
1562
|
+
// watchers attach with start time 1 to wait for a directory to
|
|
1563
|
+
// appear, which one already known is not
|
|
1564
|
+
safeTime =
|
|
1565
|
+
(startTime && startTime > 1 && this.directorySafeTimes.get(target)) ||
|
|
1566
|
+
0;
|
|
1510
1567
|
}
|
|
1511
1568
|
}
|
|
1512
1569
|
if (safeTime) {
|
|
@@ -1546,11 +1603,17 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1546
1603
|
} else if (
|
|
1547
1604
|
target !== this.path &&
|
|
1548
1605
|
!this.directories.has(target) &&
|
|
1549
|
-
watcher.checkStartTime(
|
|
1606
|
+
(watcher.checkStartTime(
|
|
1550
1607
|
/** @type {number} */
|
|
1551
1608
|
(this.initialScanFinished),
|
|
1552
1609
|
false,
|
|
1553
|
-
)
|
|
1610
|
+
) ||
|
|
1611
|
+
(this.removedTimes.has(withoutCase(target)) &&
|
|
1612
|
+
watcher.checkStartTime(
|
|
1613
|
+
/** @type {number} */
|
|
1614
|
+
(this.removedTimes.get(withoutCase(target))),
|
|
1615
|
+
false,
|
|
1616
|
+
)))
|
|
1554
1617
|
) {
|
|
1555
1618
|
process.nextTick(() => {
|
|
1556
1619
|
if (this.closed) return;
|
|
@@ -1595,11 +1658,18 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1595
1658
|
// EBUSY happens when another process has the file locked (e.g.
|
|
1596
1659
|
// Windows AV scanner). lstatWithRetry already retried before
|
|
1597
1660
|
// giving up here.
|
|
1661
|
+
// EACCES / ENODEV / EINVAL-on-Windows happen for entries that
|
|
1662
|
+
// can never be stat'ed (protected system files like
|
|
1663
|
+
// `pagefile.sys`, unreadable mounts, unmounted devices; see
|
|
1664
|
+
// #187) and are treated as missing.
|
|
1598
1665
|
if (err) {
|
|
1599
1666
|
if (
|
|
1600
1667
|
err.code !== "ENOENT" &&
|
|
1601
1668
|
err.code !== "EPERM" &&
|
|
1602
|
-
err.code !== "EBUSY"
|
|
1669
|
+
err.code !== "EBUSY" &&
|
|
1670
|
+
err.code !== "EACCES" &&
|
|
1671
|
+
err.code !== "ENODEV" &&
|
|
1672
|
+
!(err.code === "EINVAL" && IS_WIN)
|
|
1603
1673
|
) {
|
|
1604
1674
|
this.onStatsError(err);
|
|
1605
1675
|
} else if (
|
|
@@ -1620,6 +1690,7 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1620
1690
|
}
|
|
1621
1691
|
this.setMissing(target, false, eventType);
|
|
1622
1692
|
} else if (stats.isDirectory()) {
|
|
1693
|
+
if (stats.mtime) ensureFsAccuracy(+stats.mtime);
|
|
1623
1694
|
this.setDirectory(target, +stats.birthtime || 1, false, eventType);
|
|
1624
1695
|
} else if (stats.isFile() || stats.isSymbolicLink()) {
|
|
1625
1696
|
if (stats.mtime) {
|
|
@@ -1647,6 +1718,16 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1647
1718
|
onWatcherError(err) {
|
|
1648
1719
|
if (this.closed) return;
|
|
1649
1720
|
if (err) {
|
|
1721
|
+
if (
|
|
1722
|
+
WATCHER_LIMIT_ERRORS.has(
|
|
1723
|
+
/** @type {string} */ (
|
|
1724
|
+
/** @type {NodeJS.ErrnoException} */ (err).code
|
|
1725
|
+
),
|
|
1726
|
+
)
|
|
1727
|
+
) {
|
|
1728
|
+
this.pollAfterWatcherLimit(err);
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1650
1731
|
if (
|
|
1651
1732
|
/** @type {NodeJS.ErrnoException} */
|
|
1652
1733
|
(err).code !== "EPERM" &&
|
|
@@ -1660,6 +1741,25 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1660
1741
|
}
|
|
1661
1742
|
}
|
|
1662
1743
|
|
|
1744
|
+
/**
|
|
1745
|
+
* Polls the directory, which still exists, when the OS cannot watch it.
|
|
1746
|
+
* @param {unknown} err watcher limit error
|
|
1747
|
+
*/
|
|
1748
|
+
pollAfterWatcherLimit(err) {
|
|
1749
|
+
if (!watcherLimitReported) {
|
|
1750
|
+
watcherLimitReported = true;
|
|
1751
|
+
// eslint-disable-next-line no-console
|
|
1752
|
+
console.error(
|
|
1753
|
+
`Watchpack Error (watcher): ${err}\nWatchpack polls the directories it cannot watch. Raise the limit of the system (e.g. fs.inotify.max_user_watches on Linux) or set WATCHPACK_POLLING.`,
|
|
1754
|
+
);
|
|
1755
|
+
}
|
|
1756
|
+
if (this.watcher) this.watcher.close();
|
|
1757
|
+
this.polledWatching = WATCHER_LIMIT_POLL_INTERVAL;
|
|
1758
|
+
this.createWatcher();
|
|
1759
|
+
// a finishing initial scan starts the polling by itself
|
|
1760
|
+
if (!this.initialScan) this.doScan(false);
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1663
1763
|
/**
|
|
1664
1764
|
* @param {Error | NodeJS.ErrnoException=} err error
|
|
1665
1765
|
*/
|
|
@@ -1708,6 +1808,36 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1708
1808
|
}
|
|
1709
1809
|
}
|
|
1710
1810
|
|
|
1811
|
+
/**
|
|
1812
|
+
* Creates the watcher once the parent directory reports this path.
|
|
1813
|
+
* @param {number} mtime mtime
|
|
1814
|
+
* @param {EventType} type type
|
|
1815
|
+
*/
|
|
1816
|
+
retryWatcher(mtime, type) {
|
|
1817
|
+
if (this.watcher || this.retryTimeout) return;
|
|
1818
|
+
const kind = getPathKind(this.path);
|
|
1819
|
+
// gone again: wait for the parent directory to report it
|
|
1820
|
+
if (kind === "missing") {
|
|
1821
|
+
this.watchInParentDirectory();
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
// not a directory yet: retrying at once would loop (#342)
|
|
1825
|
+
if (kind === "other") {
|
|
1826
|
+
this.retryTimeout = setTimeout(() => {
|
|
1827
|
+
this.retryTimeout = undefined;
|
|
1828
|
+
if (!this.closed) this.retryWatcher(mtime, type);
|
|
1829
|
+
}, NOT_A_DIRECTORY_RETRY_DELAY);
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1832
|
+
this.createWatcher();
|
|
1833
|
+
this.doScan(false);
|
|
1834
|
+
|
|
1835
|
+
// directory was created so we emit an event
|
|
1836
|
+
this.forEachWatcher(this.path, (w) =>
|
|
1837
|
+
w.emit("change", this.path, mtime, type, false),
|
|
1838
|
+
);
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1711
1841
|
watchInParentDirectory() {
|
|
1712
1842
|
if (!this.parentWatcher) {
|
|
1713
1843
|
const parentDir = path.dirname(this.path);
|
|
@@ -1726,16 +1856,7 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1726
1856
|
this.parentWatcher.close();
|
|
1727
1857
|
this.parentWatcher = null;
|
|
1728
1858
|
}
|
|
1729
|
-
|
|
1730
|
-
if (!this.watcher) {
|
|
1731
|
-
this.createWatcher();
|
|
1732
|
-
this.doScan(false);
|
|
1733
|
-
|
|
1734
|
-
// directory was created so we emit an event
|
|
1735
|
-
this.forEachWatcher(this.path, (w) =>
|
|
1736
|
-
w.emit("change", this.path, mtime, type, false),
|
|
1737
|
-
);
|
|
1738
|
-
}
|
|
1859
|
+
this.retryWatcher(mtime, type);
|
|
1739
1860
|
});
|
|
1740
1861
|
/** @type {Watcher<FileWatcherEvents>} */
|
|
1741
1862
|
(this.parentWatcher).on("remove", () => {
|
|
@@ -1776,6 +1897,9 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1776
1897
|
// (see #187).
|
|
1777
1898
|
if (
|
|
1778
1899
|
err.code === "ENOENT" ||
|
|
1900
|
+
// a file where the directory should be, e.g. `src/foo` for a
|
|
1901
|
+
// missing `src/foo/index.js` that a resolver tried (#226)
|
|
1902
|
+
err.code === "ENOTDIR" ||
|
|
1779
1903
|
err.code === "EPERM" ||
|
|
1780
1904
|
err.code === "EACCES" ||
|
|
1781
1905
|
err.code === "ENODEV" ||
|
|
@@ -1872,13 +1996,11 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1872
1996
|
// readdir saw the entry but we can't stat it due to a
|
|
1873
1997
|
// transient lock — keep the previously-known entry instead
|
|
1874
1998
|
// of incorrectly flagging it as missing.
|
|
1875
|
-
if (
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
)
|
|
1881
|
-
) {
|
|
1999
|
+
if (!(
|
|
2000
|
+
err2.code === "EBUSY" &&
|
|
2001
|
+
BUSY_RETRIES > 0 &&
|
|
2002
|
+
this.files.has(itemPath)
|
|
2003
|
+
)) {
|
|
1882
2004
|
this.setMissing(itemPath, initial, `scan (${err2.code})`);
|
|
1883
2005
|
}
|
|
1884
2006
|
} else {
|
|
@@ -1914,6 +2036,9 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1914
2036
|
stats.isDirectory() &&
|
|
1915
2037
|
(!initial || !this.directories.has(itemPath))
|
|
1916
2038
|
) {
|
|
2039
|
+
// mtime, not birthtime: FAT keeps creation times finer than
|
|
2040
|
+
// modification times, so only mtime shows the real accuracy
|
|
2041
|
+
if (stats.mtime) ensureFsAccuracy(+stats.mtime);
|
|
1917
2042
|
this.setDirectory(
|
|
1918
2043
|
itemPath,
|
|
1919
2044
|
+stats.birthtime || 1,
|
|
@@ -1959,6 +2084,9 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
1959
2084
|
// Treat a symlink whose target is a directory as a
|
|
1960
2085
|
// nested watched directory so files inside the target
|
|
1961
2086
|
// propagate change events to the symlink path.
|
|
2087
|
+
if (targetStats.mtime) {
|
|
2088
|
+
ensureFsAccuracy(+targetStats.mtime);
|
|
2089
|
+
}
|
|
1962
2090
|
this.setDirectory(
|
|
1963
2091
|
itemPath,
|
|
1964
2092
|
+targetStats.birthtime || +stats.birthtime || 1,
|
|
@@ -2062,7 +2190,13 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
2062
2190
|
for (const watcher of watchers) {
|
|
2063
2191
|
const { path } = watcher;
|
|
2064
2192
|
if (!fileTimestamps.has(path)) {
|
|
2065
|
-
|
|
2193
|
+
// on a case-insensitive file system a path with other casing
|
|
2194
|
+
// is the same file and must change with it
|
|
2195
|
+
const file = this.getFileWithOtherCase(path);
|
|
2196
|
+
fileTimestamps.set(
|
|
2197
|
+
path,
|
|
2198
|
+
(file !== undefined && this.files.get(file)) || null,
|
|
2199
|
+
);
|
|
2066
2200
|
}
|
|
2067
2201
|
}
|
|
2068
2202
|
}
|
|
@@ -2070,6 +2204,49 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
2070
2204
|
return safeTime;
|
|
2071
2205
|
}
|
|
2072
2206
|
|
|
2207
|
+
/**
|
|
2208
|
+
* @param {string} target a watched path that is not in `files`
|
|
2209
|
+
* @returns {string | undefined} the file it names on a case-insensitive file system
|
|
2210
|
+
*/
|
|
2211
|
+
getFileWithOtherCase(target) {
|
|
2212
|
+
if (this.caseInsensitive === false) return;
|
|
2213
|
+
const key = withoutCase(target);
|
|
2214
|
+
if (!this.filesWithoutCase.has(key)) return;
|
|
2215
|
+
let file;
|
|
2216
|
+
for (const item of this.files.keys()) {
|
|
2217
|
+
if (withoutCase(item) === key) {
|
|
2218
|
+
file = item;
|
|
2219
|
+
break;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
if (file === undefined) return;
|
|
2223
|
+
if (this.caseInsensitive === undefined) {
|
|
2224
|
+
let fileStats;
|
|
2225
|
+
try {
|
|
2226
|
+
fileStats = fs.lstatSync(file);
|
|
2227
|
+
} catch (_err) {
|
|
2228
|
+
// changed meanwhile, the next scan updates `files`
|
|
2229
|
+
return;
|
|
2230
|
+
}
|
|
2231
|
+
try {
|
|
2232
|
+
const targetStats = fs.lstatSync(target);
|
|
2233
|
+
this.caseInsensitive =
|
|
2234
|
+
targetStats.ino === fileStats.ino &&
|
|
2235
|
+
targetStats.dev === fileStats.dev;
|
|
2236
|
+
} catch (err) {
|
|
2237
|
+
// only a missing name proves case matters; EBUSY and the like
|
|
2238
|
+
// leave it to the next collection
|
|
2239
|
+
if (/** @type {NodeJS.ErrnoException} */ (err).code !== "ENOENT") {
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
2242
|
+
// a file removed meanwhile says nothing about the file system
|
|
2243
|
+
if (!fs.existsSync(file)) return;
|
|
2244
|
+
this.caseInsensitive = false;
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
return this.caseInsensitive ? file : undefined;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2073
2250
|
close() {
|
|
2074
2251
|
if (this.closed) return;
|
|
2075
2252
|
this.closed = true;
|
|
@@ -2093,6 +2270,10 @@ class DirectoryWatcher extends EventEmitter {
|
|
|
2093
2270
|
this.parentWatcher.close();
|
|
2094
2271
|
this.parentWatcher = null;
|
|
2095
2272
|
}
|
|
2273
|
+
if (this.retryTimeout) {
|
|
2274
|
+
clearTimeout(this.retryTimeout);
|
|
2275
|
+
this.retryTimeout = undefined;
|
|
2276
|
+
}
|
|
2096
2277
|
this.emit("closed");
|
|
2097
2278
|
}
|
|
2098
2279
|
}
|
|
@@ -2104,7 +2285,7 @@ module.exports.Watcher = Watcher;
|
|
|
2104
2285
|
|
|
2105
2286
|
/***/ }),
|
|
2106
2287
|
|
|
2107
|
-
/***/
|
|
2288
|
+
/***/ 864:
|
|
2108
2289
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2109
2290
|
|
|
2110
2291
|
"use strict";
|
|
@@ -2226,7 +2407,7 @@ module.exports = LinkResolver;
|
|
|
2226
2407
|
|
|
2227
2408
|
/***/ }),
|
|
2228
2409
|
|
|
2229
|
-
/***/
|
|
2410
|
+
/***/ 171:
|
|
2230
2411
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2231
2412
|
|
|
2232
2413
|
"use strict";
|
|
@@ -2237,7 +2418,7 @@ module.exports = LinkResolver;
|
|
|
2237
2418
|
|
|
2238
2419
|
|
|
2239
2420
|
const path = __nccwpck_require__(928);
|
|
2240
|
-
const DirectoryWatcher = __nccwpck_require__(
|
|
2421
|
+
const DirectoryWatcher = __nccwpck_require__(539);
|
|
2241
2422
|
|
|
2242
2423
|
/** @typedef {import("./index").EventMap} EventMap */
|
|
2243
2424
|
/** @typedef {import("./DirectoryWatcher").DirectoryWatcherOptions} DirectoryWatcherOptions */
|
|
@@ -2314,7 +2495,7 @@ module.exports.WatcherManager = WatcherManager;
|
|
|
2314
2495
|
|
|
2315
2496
|
/***/ }),
|
|
2316
2497
|
|
|
2317
|
-
/***/
|
|
2498
|
+
/***/ 260:
|
|
2318
2499
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2319
2500
|
|
|
2320
2501
|
"use strict";
|
|
@@ -2325,10 +2506,10 @@ module.exports.WatcherManager = WatcherManager;
|
|
|
2325
2506
|
|
|
2326
2507
|
|
|
2327
2508
|
const { EventEmitter } = __nccwpck_require__(434);
|
|
2328
|
-
const LinkResolver = __nccwpck_require__(
|
|
2329
|
-
const getWatcherManager = __nccwpck_require__(
|
|
2330
|
-
const globToRegExp = __nccwpck_require__(
|
|
2331
|
-
const watchEventSource = __nccwpck_require__(
|
|
2509
|
+
const LinkResolver = __nccwpck_require__(864);
|
|
2510
|
+
const getWatcherManager = __nccwpck_require__(171);
|
|
2511
|
+
const globToRegExp = __nccwpck_require__(167);
|
|
2512
|
+
const watchEventSource = __nccwpck_require__(370);
|
|
2332
2513
|
|
|
2333
2514
|
/** @typedef {import("./getWatcherManager").WatcherManager} WatcherManager */
|
|
2334
2515
|
/** @typedef {import("./DirectoryWatcher")} DirectoryWatcher */
|
|
@@ -2344,7 +2525,7 @@ const watchEventSource = __nccwpck_require__(92);
|
|
|
2344
2525
|
*/
|
|
2345
2526
|
|
|
2346
2527
|
/** @typedef {(item: string) => boolean} IgnoredFunction */
|
|
2347
|
-
/** @typedef {string[] | RegExp | string | IgnoredFunction} Ignored */
|
|
2528
|
+
/** @typedef {(string | RegExp)[] | RegExp | string | IgnoredFunction} Ignored */
|
|
2348
2529
|
|
|
2349
2530
|
/**
|
|
2350
2531
|
* @typedef {object} WatcherOptions
|
|
@@ -2415,17 +2596,28 @@ const normalizeSeparators = (item) =>
|
|
|
2415
2596
|
*/
|
|
2416
2597
|
const ignoredToFunction = (ignored) => {
|
|
2417
2598
|
if (Array.isArray(ignored)) {
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2599
|
+
/** @type {string[]} */
|
|
2600
|
+
const stringRegexps = [];
|
|
2601
|
+
/** @type {RegExp[]} */
|
|
2602
|
+
const regexps = [];
|
|
2603
|
+
for (const item of ignored) {
|
|
2604
|
+
if (item instanceof RegExp) {
|
|
2605
|
+
regexps.push(item);
|
|
2606
|
+
} else {
|
|
2607
|
+
const stringRegexp = stringToRegexp(item);
|
|
2608
|
+
if (stringRegexp) stringRegexps.push(stringRegexp);
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
if (stringRegexps.length === 0 && regexps.length === 0) {
|
|
2422
2612
|
return () => false;
|
|
2423
2613
|
}
|
|
2424
|
-
|
|
2425
|
-
stringRegexps.
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2614
|
+
if (stringRegexps.length > 0) {
|
|
2615
|
+
regexps.push(new RegExp(stringRegexps.join("|")));
|
|
2616
|
+
}
|
|
2617
|
+
return (item) => {
|
|
2618
|
+
const normalized = normalizeSeparators(item);
|
|
2619
|
+
return regexps.some((regexp) => regexp.test(normalized));
|
|
2620
|
+
};
|
|
2429
2621
|
} else if (typeof ignored === "string") {
|
|
2430
2622
|
const stringRegexp = stringToRegexp(ignored);
|
|
2431
2623
|
if (!stringRegexp) {
|
|
@@ -2916,7 +3108,7 @@ module.exports = /** @type {WatchpackExports} */ (
|
|
|
2916
3108
|
|
|
2917
3109
|
/***/ }),
|
|
2918
3110
|
|
|
2919
|
-
/***/
|
|
3111
|
+
/***/ 875:
|
|
2920
3112
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2921
3113
|
|
|
2922
3114
|
"use strict";
|
|
@@ -3083,7 +3275,7 @@ module.exports = (plan, limit) => {
|
|
|
3083
3275
|
|
|
3084
3276
|
/***/ }),
|
|
3085
3277
|
|
|
3086
|
-
/***/
|
|
3278
|
+
/***/ 167:
|
|
3087
3279
|
/***/ ((module) => {
|
|
3088
3280
|
|
|
3089
3281
|
"use strict";
|
|
@@ -3233,7 +3425,7 @@ module.exports = (glob) => {
|
|
|
3233
3425
|
|
|
3234
3426
|
/***/ }),
|
|
3235
3427
|
|
|
3236
|
-
/***/
|
|
3428
|
+
/***/ 370:
|
|
3237
3429
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3238
3430
|
|
|
3239
3431
|
"use strict";
|
|
@@ -3246,7 +3438,7 @@ module.exports = (glob) => {
|
|
|
3246
3438
|
const { EventEmitter } = __nccwpck_require__(434);
|
|
3247
3439
|
const fs = __nccwpck_require__(896);
|
|
3248
3440
|
const path = __nccwpck_require__(928);
|
|
3249
|
-
const reducePlan = __nccwpck_require__(
|
|
3441
|
+
const reducePlan = __nccwpck_require__(875);
|
|
3250
3442
|
|
|
3251
3443
|
/** @typedef {import("fs").FSWatcher} FSWatcher */
|
|
3252
3444
|
/** @typedef {import("./index").EventType} EventType */
|
|
@@ -3266,6 +3458,14 @@ const recursiveWatcherLogging = Boolean(
|
|
|
3266
3458
|
process.env.WATCHPACK_RECURSIVE_WATCHER_LOGGING,
|
|
3267
3459
|
);
|
|
3268
3460
|
|
|
3461
|
+
// On macOS libuv shares one FSEventStream between all directory watchers of a
|
|
3462
|
+
// process and recreates it from "now" whenever one starts or stops, so events
|
|
3463
|
+
// it had not delivered yet are lost. Every watcher rescans once that settles.
|
|
3464
|
+
const RESCAN_ON_RESTART =
|
|
3465
|
+
IS_OSX || Boolean(process.env.WATCHPACK_RESCAN_ON_RESTART);
|
|
3466
|
+
// @ts-expect-error avoid additional checks
|
|
3467
|
+
const RESCAN_DELAY = +process.env.WATCHPACK_RESCAN_DELAY || 200;
|
|
3468
|
+
|
|
3269
3469
|
let isBatch = false;
|
|
3270
3470
|
let watcherCount = 0;
|
|
3271
3471
|
|
|
@@ -3281,6 +3481,22 @@ const directWatchers = new Map();
|
|
|
3281
3481
|
/** @type {Map<Watcher, RecursiveWatcher | DirectWatcher>} */
|
|
3282
3482
|
const underlyingWatcher = new Map();
|
|
3283
3483
|
|
|
3484
|
+
/** @type {Set<Watcher>} */
|
|
3485
|
+
const activeWatchers = new Set();
|
|
3486
|
+
|
|
3487
|
+
/** @type {NodeJS.Timeout | undefined} */
|
|
3488
|
+
let rescanTimer;
|
|
3489
|
+
|
|
3490
|
+
const streamRestarted = () => {
|
|
3491
|
+
if (!RESCAN_ON_RESTART) return;
|
|
3492
|
+
if (rescanTimer) clearTimeout(rescanTimer);
|
|
3493
|
+
rescanTimer = setTimeout(() => {
|
|
3494
|
+
rescanTimer = undefined;
|
|
3495
|
+
for (const w of activeWatchers) w.emit("rescan");
|
|
3496
|
+
}, RESCAN_DELAY);
|
|
3497
|
+
if (rescanTimer.unref) rescanTimer.unref();
|
|
3498
|
+
};
|
|
3499
|
+
|
|
3284
3500
|
/**
|
|
3285
3501
|
* @param {string} filePath file path
|
|
3286
3502
|
* @returns {NodeJS.ErrnoException} new error with file path in the message
|
|
@@ -3359,6 +3575,7 @@ class DirectWatcher {
|
|
|
3359
3575
|
});
|
|
3360
3576
|
}
|
|
3361
3577
|
watcherCount++;
|
|
3578
|
+
streamRestarted();
|
|
3362
3579
|
}
|
|
3363
3580
|
|
|
3364
3581
|
/**
|
|
@@ -3377,7 +3594,10 @@ class DirectWatcher {
|
|
|
3377
3594
|
if (this.watchers.size === 0) {
|
|
3378
3595
|
directWatchers.delete(this.filePath);
|
|
3379
3596
|
watcherCount--;
|
|
3380
|
-
if (this.watcher)
|
|
3597
|
+
if (this.watcher) {
|
|
3598
|
+
this.watcher.close();
|
|
3599
|
+
streamRestarted();
|
|
3600
|
+
}
|
|
3381
3601
|
}
|
|
3382
3602
|
}
|
|
3383
3603
|
|
|
@@ -3449,6 +3669,7 @@ class RecursiveWatcher {
|
|
|
3449
3669
|
});
|
|
3450
3670
|
}
|
|
3451
3671
|
watcherCount++;
|
|
3672
|
+
streamRestarted();
|
|
3452
3673
|
if (recursiveWatcherLogging) {
|
|
3453
3674
|
process.stderr.write(
|
|
3454
3675
|
`[watchpack] created recursive watcher at ${rootPath}\n`,
|
|
@@ -3489,7 +3710,10 @@ class RecursiveWatcher {
|
|
|
3489
3710
|
if (this.mapWatcherToPath.size === 0) {
|
|
3490
3711
|
recursiveWatchers.delete(this.rootPath);
|
|
3491
3712
|
watcherCount--;
|
|
3492
|
-
if (this.watcher)
|
|
3713
|
+
if (this.watcher) {
|
|
3714
|
+
this.watcher.close();
|
|
3715
|
+
streamRestarted();
|
|
3716
|
+
}
|
|
3493
3717
|
if (recursiveWatcherLogging) {
|
|
3494
3718
|
process.stderr.write(
|
|
3495
3719
|
`[watchpack] closed recursive watcher at ${this.rootPath}\n`,
|
|
@@ -3507,6 +3731,7 @@ class RecursiveWatcher {
|
|
|
3507
3731
|
* @typedef {object} WatcherEvents
|
|
3508
3732
|
* @property {(eventType: EventType, filename?: string) => void} change change event
|
|
3509
3733
|
* @property {(err: unknown) => void} error error event
|
|
3734
|
+
* @property {() => void} rescan rescan event, when events may have been lost
|
|
3510
3735
|
*/
|
|
3511
3736
|
|
|
3512
3737
|
/**
|
|
@@ -3518,6 +3743,7 @@ class Watcher extends EventEmitter {
|
|
|
3518
3743
|
}
|
|
3519
3744
|
|
|
3520
3745
|
close() {
|
|
3746
|
+
activeWatchers.delete(this);
|
|
3521
3747
|
if (pendingWatchers.has(this)) {
|
|
3522
3748
|
pendingWatchers.delete(this);
|
|
3523
3749
|
return;
|
|
@@ -3665,6 +3891,7 @@ module.exports.getNumberOfWatchers = () => watcherCount;
|
|
|
3665
3891
|
*/
|
|
3666
3892
|
module.exports.watch = (filePath) => {
|
|
3667
3893
|
const watcher = new Watcher();
|
|
3894
|
+
activeWatchers.add(watcher);
|
|
3668
3895
|
// Find an existing watcher
|
|
3669
3896
|
const directWatcher = directWatchers.get(filePath);
|
|
3670
3897
|
if (directWatcher !== undefined) {
|
|
@@ -3804,7 +4031,7 @@ module.exports = require("util");
|
|
|
3804
4031
|
/******/ // startup
|
|
3805
4032
|
/******/ // Load entry module and return exports
|
|
3806
4033
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
3807
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(
|
|
4034
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(260);
|
|
3808
4035
|
/******/ module.exports = __webpack_exports__;
|
|
3809
4036
|
/******/
|
|
3810
4037
|
/******/ })()
|