@ohos-ports/rspack-core 2.2.9-beta.0 → 2.3.4-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 +7 -7
- package/compiled/http-proxy-middleware/index.d.ts +12 -10
- package/compiled/http-proxy-middleware/package.json +1 -1
- package/compiled/tinypool/dist/index.js +5 -3
- package/compiled/watchpack/index.js +459 -60
- 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 +2 -0
- package/compiled/webpack-sources/index.js +207 -94
- package/compiled/webpack-sources/package.json +1 -1
- package/compiled/webpack-sources/types/RawSource.d.ts +0 -10
- package/compiled/webpack-sources/types/helpers/sourceMap.d.ts +47 -0
- package/compiled/webpack-sources/types/index.d.ts +1 -0
- package/dist/BuildInfo.d.ts +7 -0
- package/dist/Compilation.d.ts +3 -1
- package/dist/Compiler.d.ts +5 -6
- package/dist/ConcatenatedModule.d.ts +5 -1
- package/dist/ContextModule.d.ts +3 -1
- package/dist/ExternalModule.d.ts +7 -6
- package/dist/FileSystemInfo.d.ts +1 -0
- package/dist/Module.d.ts +12 -8
- package/dist/ModuleGraphConnection.d.ts +9 -3
- package/dist/NativeWatchFileSystem.d.ts +19 -7
- package/dist/NormalModule.d.ts +14 -6
- package/dist/RuntimeGlobals.d.ts +2 -1
- package/dist/RuntimeTemplate.d.ts +2 -0
- package/dist/Stats.d.ts +1 -1
- package/dist/builtin-loader/lightningcss/index.d.ts +5 -1
- package/dist/builtin-plugin/CompactHashedChunkIdsPlugin.d.ts +1 -0
- package/dist/builtin-plugin/CompactHashedModuleIdsPlugin.d.ts +1 -0
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +5 -0
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +3 -2
- package/dist/builtin-plugin/ImportedByDeferModulesPlugin.d.ts +9 -0
- package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +1 -0
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +2 -2
- package/dist/config/adapterRuleUse.d.ts +1 -0
- package/dist/config/normalization.d.ts +2 -2
- package/dist/config/target.d.ts +6 -0
- package/dist/config/types.d.ts +69 -36
- package/dist/cssExtractHmr.js +1 -1
- package/dist/cssExtractLoader.js +1 -1
- package/dist/exports.d.ts +5 -4
- package/dist/index.js +1577 -1151
- package/dist/loader-runner/codeFilter.d.ts +9 -0
- package/dist/loader-runner/dependencies.d.ts +1 -1
- package/dist/loader-runner/index.d.ts +2 -1
- package/dist/loader-runner/service.d.ts +0 -4
- package/dist/loader-runner/worker.d.ts +4 -1
- package/dist/node/NodeWatchFileSystem.d.ts +7 -4
- package/dist/sharing/IndependentSharedPlugin.d.ts +1 -2
- package/dist/sharing/utils.d.ts +1 -1
- package/dist/sources.d.ts +3 -0
- package/dist/stats/statsFactoryUtils.d.ts +7 -0
- package/dist/util/bindingHelpers.d.ts +2 -0
- package/dist/util/createModule.d.ts +3 -0
- package/dist/util/fs.d.ts +13 -7
- package/dist/util/resolveLayerExternals.d.ts +1 -0
- package/dist/util/source.d.ts +12 -3
- package/dist/util/symbols.d.ts +10 -0
- package/dist/util/watchTimeInfo.d.ts +5 -1
- package/dist/worker.js +327 -326
- package/hot/lazy-compilation-node.js +1 -1
- package/hot/lazy-compilation-web.js +1 -1
- package/package.json +4 -4
- package/dist/loader-runner/cache.d.ts +0 -27
|
@@ -974,7 +974,7 @@ function patch (fs) {
|
|
|
974
974
|
|
|
975
975
|
/***/ }),
|
|
976
976
|
|
|
977
|
-
/***/
|
|
977
|
+
/***/ 674:
|
|
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__(487);
|
|
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
|
+
/***/ 377:
|
|
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
|
+
/***/ 548:
|
|
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__(674);
|
|
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
|
+
/***/ 375:
|
|
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__(377);
|
|
2510
|
+
const getWatcherManager = __nccwpck_require__(548);
|
|
2511
|
+
const globToRegExp = __nccwpck_require__(256);
|
|
2512
|
+
const watchEventSource = __nccwpck_require__(487);
|
|
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
|
+
/***/ 890:
|
|
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
|
+
/***/ 256:
|
|
3087
3279
|
/***/ ((module) => {
|
|
3088
3280
|
|
|
3089
3281
|
"use strict";
|
|
@@ -3116,15 +3308,20 @@ const CC_LEFT_BRACE = 123; // "{"
|
|
|
3116
3308
|
const CC_PIPE = 124; // "|"
|
|
3117
3309
|
const CC_RIGHT_BRACE = 125; // "}"
|
|
3118
3310
|
|
|
3311
|
+
const CC_BACKSLASH = 92; // "\\"
|
|
3312
|
+
|
|
3313
|
+
// A globstar segment followed by more of the pattern: whole segments, each
|
|
3314
|
+
// ending in "/", so no two ways split the same path and nothing backtracks.
|
|
3315
|
+
const GLOBSTAR_SEGMENTS = "((?:[^/]*\\/)*)";
|
|
3316
|
+
// A globstar that ends the pattern matches whatever is left.
|
|
3317
|
+
const GLOBSTAR_REST = "(.*)";
|
|
3318
|
+
|
|
3119
3319
|
/**
|
|
3120
3320
|
* @param {string} glob glob pattern
|
|
3321
|
+
* @param {boolean} literal whether brackets, braces and backslashes are literal characters
|
|
3121
3322
|
* @returns {string} regexp source without anchors
|
|
3122
3323
|
*/
|
|
3123
|
-
|
|
3124
|
-
if (typeof glob !== "string") {
|
|
3125
|
-
throw new TypeError("Expected a string");
|
|
3126
|
-
}
|
|
3127
|
-
|
|
3324
|
+
const translate = (glob, literal) => {
|
|
3128
3325
|
const len = glob.length;
|
|
3129
3326
|
let reStr = "";
|
|
3130
3327
|
let inGroup = false;
|
|
@@ -3171,18 +3368,22 @@ module.exports = (glob) => {
|
|
|
3171
3368
|
mapped = ".";
|
|
3172
3369
|
break;
|
|
3173
3370
|
case CC_LEFT_BRACKET:
|
|
3174
|
-
mapped = "[";
|
|
3371
|
+
mapped = literal ? "\\[" : "[";
|
|
3175
3372
|
break;
|
|
3176
3373
|
case CC_RIGHT_BRACKET:
|
|
3177
|
-
mapped = "]";
|
|
3374
|
+
mapped = literal ? "\\]" : "]";
|
|
3178
3375
|
break;
|
|
3179
3376
|
case CC_LEFT_BRACE:
|
|
3180
|
-
inGroup =
|
|
3181
|
-
mapped = "(";
|
|
3377
|
+
inGroup = !literal;
|
|
3378
|
+
mapped = literal ? "\\{" : "(";
|
|
3182
3379
|
break;
|
|
3183
3380
|
case CC_RIGHT_BRACE:
|
|
3184
3381
|
inGroup = false;
|
|
3185
|
-
mapped = ")";
|
|
3382
|
+
mapped = literal ? "\\}" : ")";
|
|
3383
|
+
break;
|
|
3384
|
+
case CC_BACKSLASH:
|
|
3385
|
+
if (!literal) continue;
|
|
3386
|
+
mapped = "\\\\";
|
|
3186
3387
|
break;
|
|
3187
3388
|
case CC_COMMA:
|
|
3188
3389
|
mapped = inGroup ? "|" : "\\,";
|
|
@@ -3203,8 +3404,18 @@ module.exports = (glob) => {
|
|
|
3203
3404
|
(atEnd || beforeSlash)
|
|
3204
3405
|
) {
|
|
3205
3406
|
// Globstar segment, matches zero or more path segments
|
|
3206
|
-
mapped = "((?:[^/]*(?:\\/|$))*)";
|
|
3207
3407
|
i++; // Move over the "/"
|
|
3408
|
+
if (i + 1 >= len) {
|
|
3409
|
+
mapped = GLOBSTAR_REST;
|
|
3410
|
+
} else if (
|
|
3411
|
+
reStr.endsWith(GLOBSTAR_SEGMENTS) &&
|
|
3412
|
+
literalStart === tokenStart
|
|
3413
|
+
) {
|
|
3414
|
+
// `**/**/` matches what one `**/` does
|
|
3415
|
+
mapped = "";
|
|
3416
|
+
} else {
|
|
3417
|
+
mapped = GLOBSTAR_SEGMENTS;
|
|
3418
|
+
}
|
|
3208
3419
|
} else {
|
|
3209
3420
|
// Not a globstar, matches one path segment
|
|
3210
3421
|
mapped = "([^/]*)";
|
|
@@ -3230,10 +3441,163 @@ module.exports = (glob) => {
|
|
|
3230
3441
|
return reStr;
|
|
3231
3442
|
};
|
|
3232
3443
|
|
|
3444
|
+
const CC_HYPHEN = 45; // "-"
|
|
3445
|
+
|
|
3446
|
+
/**
|
|
3447
|
+
* @param {number} cc char code
|
|
3448
|
+
* @returns {boolean} true for an ASCII hex digit
|
|
3449
|
+
*/
|
|
3450
|
+
const isHexDigit = (cc) =>
|
|
3451
|
+
(cc >= 48 && cc <= 57) || (cc >= 65 && cc <= 70) || (cc >= 97 && cc <= 102);
|
|
3452
|
+
|
|
3453
|
+
/**
|
|
3454
|
+
* @param {string} source regexp source
|
|
3455
|
+
* @param {number} start index after the opening "["
|
|
3456
|
+
* @returns {number} index of the closing "]", or -1 when the class is unclosed or holds a reversed range
|
|
3457
|
+
*/
|
|
3458
|
+
const readClass = (source, start) => {
|
|
3459
|
+
const len = source.length;
|
|
3460
|
+
let i = start;
|
|
3461
|
+
if (source.charCodeAt(i) === CC_CARET) i++;
|
|
3462
|
+
// Value of the atom at `i`, -1 for a set (`\d` and the like); moves `i` past it
|
|
3463
|
+
const readAtom = () => {
|
|
3464
|
+
const cc = source.charCodeAt(i++);
|
|
3465
|
+
if (cc !== CC_BACKSLASH) return cc;
|
|
3466
|
+
const next = source.charCodeAt(i++);
|
|
3467
|
+
switch (next) {
|
|
3468
|
+
case 100: // d
|
|
3469
|
+
case 68: // D
|
|
3470
|
+
case 115: // s
|
|
3471
|
+
case 83: // S
|
|
3472
|
+
case 119: // w
|
|
3473
|
+
case 87: // W
|
|
3474
|
+
return -1;
|
|
3475
|
+
case 98: // b
|
|
3476
|
+
return 8;
|
|
3477
|
+
case 102: // f
|
|
3478
|
+
return 12;
|
|
3479
|
+
case 110: // n
|
|
3480
|
+
return 10;
|
|
3481
|
+
case 114: // r
|
|
3482
|
+
return 13;
|
|
3483
|
+
case 116: // t
|
|
3484
|
+
return 9;
|
|
3485
|
+
case 118: // v
|
|
3486
|
+
return 11;
|
|
3487
|
+
case 120: // x
|
|
3488
|
+
if (
|
|
3489
|
+
isHexDigit(source.charCodeAt(i)) &&
|
|
3490
|
+
isHexDigit(source.charCodeAt(i + 1))
|
|
3491
|
+
) {
|
|
3492
|
+
i += 2;
|
|
3493
|
+
return Number.parseInt(source.slice(i - 2, i), 16);
|
|
3494
|
+
}
|
|
3495
|
+
return next;
|
|
3496
|
+
case 117: {
|
|
3497
|
+
// u
|
|
3498
|
+
let digits = 0;
|
|
3499
|
+
while (digits < 4 && isHexDigit(source.charCodeAt(i + digits))) {
|
|
3500
|
+
digits++;
|
|
3501
|
+
}
|
|
3502
|
+
if (digits < 4) return next;
|
|
3503
|
+
i += 4;
|
|
3504
|
+
return Number.parseInt(source.slice(i - 4, i), 16);
|
|
3505
|
+
}
|
|
3506
|
+
case 99: {
|
|
3507
|
+
// c
|
|
3508
|
+
const letter = source.charCodeAt(i);
|
|
3509
|
+
if (
|
|
3510
|
+
(letter >= 65 && letter <= 90) ||
|
|
3511
|
+
(letter >= 97 && letter <= 122) ||
|
|
3512
|
+
(letter >= 48 && letter <= 57) ||
|
|
3513
|
+
letter === 95
|
|
3514
|
+
) {
|
|
3515
|
+
i++;
|
|
3516
|
+
return letter % 32;
|
|
3517
|
+
}
|
|
3518
|
+
// A lone `\c` is a backslash; the `c` is the next atom
|
|
3519
|
+
i--;
|
|
3520
|
+
return CC_BACKSLASH;
|
|
3521
|
+
}
|
|
3522
|
+
default:
|
|
3523
|
+
if (next >= 48 && next <= 55) {
|
|
3524
|
+
// Legacy octal escape, up to `\377`
|
|
3525
|
+
let value = next - 48;
|
|
3526
|
+
const max = next <= 51 ? 2 : 1;
|
|
3527
|
+
for (let digits = 0; digits < max; digits++) {
|
|
3528
|
+
const digit = source.charCodeAt(i);
|
|
3529
|
+
if (digit < 48 || digit > 55) break;
|
|
3530
|
+
value = value * 8 + digit - 48;
|
|
3531
|
+
i++;
|
|
3532
|
+
}
|
|
3533
|
+
return value;
|
|
3534
|
+
}
|
|
3535
|
+
return next;
|
|
3536
|
+
}
|
|
3537
|
+
};
|
|
3538
|
+
while (i < len) {
|
|
3539
|
+
const cc = source.charCodeAt(i);
|
|
3540
|
+
if (cc === CC_RIGHT_BRACKET) return i;
|
|
3541
|
+
if (cc === CC_BACKSLASH && i + 1 >= len) return -1;
|
|
3542
|
+
const from = readAtom();
|
|
3543
|
+
if (
|
|
3544
|
+
source.charCodeAt(i) === CC_HYPHEN &&
|
|
3545
|
+
i + 1 < len &&
|
|
3546
|
+
source.charCodeAt(i + 1) !== CC_RIGHT_BRACKET
|
|
3547
|
+
) {
|
|
3548
|
+
i++;
|
|
3549
|
+
if (source.charCodeAt(i) === CC_BACKSLASH && i + 1 >= len) return -1;
|
|
3550
|
+
const to = readAtom();
|
|
3551
|
+
if (from !== -1 && to !== -1 && from > to) return -1;
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
return -1;
|
|
3555
|
+
};
|
|
3556
|
+
|
|
3557
|
+
/**
|
|
3558
|
+
* Whether `new RegExp(source)` would accept a source `translate` gave,
|
|
3559
|
+
* without building one.
|
|
3560
|
+
* @param {string} source regexp source
|
|
3561
|
+
* @returns {boolean} true when the source compiles
|
|
3562
|
+
*/
|
|
3563
|
+
const compiles = (source) => {
|
|
3564
|
+
const len = source.length;
|
|
3565
|
+
let depth = 0;
|
|
3566
|
+
for (let i = 0; i < len; i++) {
|
|
3567
|
+
const cc = source.charCodeAt(i);
|
|
3568
|
+
if (cc === CC_BACKSLASH) {
|
|
3569
|
+
if (++i >= len) return false;
|
|
3570
|
+
} else if (cc === CC_LEFT_PARENTHESIS) {
|
|
3571
|
+
depth++;
|
|
3572
|
+
} else if (cc === CC_RIGHT_PARENTHESIS) {
|
|
3573
|
+
if (--depth < 0) return false;
|
|
3574
|
+
} else if (cc === CC_LEFT_BRACKET) {
|
|
3575
|
+
i = readClass(source, i + 1);
|
|
3576
|
+
if (i === -1) return false;
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
return depth === 0;
|
|
3580
|
+
};
|
|
3581
|
+
|
|
3582
|
+
/**
|
|
3583
|
+
* @param {string} glob glob pattern
|
|
3584
|
+
* @returns {string} regexp source without anchors
|
|
3585
|
+
*/
|
|
3586
|
+
module.exports = (glob) => {
|
|
3587
|
+
if (typeof glob !== "string") {
|
|
3588
|
+
throw new TypeError("Expected a string");
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
const source = translate(glob, false);
|
|
3592
|
+
// An unbalanced or invalid bracket or brace: read those as the
|
|
3593
|
+
// characters they are rather than give a regexp that cannot compile.
|
|
3594
|
+
return compiles(source) ? source : translate(glob, true);
|
|
3595
|
+
};
|
|
3596
|
+
|
|
3233
3597
|
|
|
3234
3598
|
/***/ }),
|
|
3235
3599
|
|
|
3236
|
-
/***/
|
|
3600
|
+
/***/ 487:
|
|
3237
3601
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3238
3602
|
|
|
3239
3603
|
"use strict";
|
|
@@ -3246,7 +3610,7 @@ module.exports = (glob) => {
|
|
|
3246
3610
|
const { EventEmitter } = __nccwpck_require__(434);
|
|
3247
3611
|
const fs = __nccwpck_require__(896);
|
|
3248
3612
|
const path = __nccwpck_require__(928);
|
|
3249
|
-
const reducePlan = __nccwpck_require__(
|
|
3613
|
+
const reducePlan = __nccwpck_require__(890);
|
|
3250
3614
|
|
|
3251
3615
|
/** @typedef {import("fs").FSWatcher} FSWatcher */
|
|
3252
3616
|
/** @typedef {import("./index").EventType} EventType */
|
|
@@ -3266,6 +3630,14 @@ const recursiveWatcherLogging = Boolean(
|
|
|
3266
3630
|
process.env.WATCHPACK_RECURSIVE_WATCHER_LOGGING,
|
|
3267
3631
|
);
|
|
3268
3632
|
|
|
3633
|
+
// On macOS libuv shares one FSEventStream between all directory watchers of a
|
|
3634
|
+
// process and recreates it from "now" whenever one starts or stops, so events
|
|
3635
|
+
// it had not delivered yet are lost. Every watcher rescans once that settles.
|
|
3636
|
+
const RESCAN_ON_RESTART =
|
|
3637
|
+
IS_OSX || Boolean(process.env.WATCHPACK_RESCAN_ON_RESTART);
|
|
3638
|
+
// @ts-expect-error avoid additional checks
|
|
3639
|
+
const RESCAN_DELAY = +process.env.WATCHPACK_RESCAN_DELAY || 200;
|
|
3640
|
+
|
|
3269
3641
|
let isBatch = false;
|
|
3270
3642
|
let watcherCount = 0;
|
|
3271
3643
|
|
|
@@ -3281,6 +3653,22 @@ const directWatchers = new Map();
|
|
|
3281
3653
|
/** @type {Map<Watcher, RecursiveWatcher | DirectWatcher>} */
|
|
3282
3654
|
const underlyingWatcher = new Map();
|
|
3283
3655
|
|
|
3656
|
+
/** @type {Set<Watcher>} */
|
|
3657
|
+
const activeWatchers = new Set();
|
|
3658
|
+
|
|
3659
|
+
/** @type {NodeJS.Timeout | undefined} */
|
|
3660
|
+
let rescanTimer;
|
|
3661
|
+
|
|
3662
|
+
const streamRestarted = () => {
|
|
3663
|
+
if (!RESCAN_ON_RESTART) return;
|
|
3664
|
+
if (rescanTimer) clearTimeout(rescanTimer);
|
|
3665
|
+
rescanTimer = setTimeout(() => {
|
|
3666
|
+
rescanTimer = undefined;
|
|
3667
|
+
for (const w of activeWatchers) w.emit("rescan");
|
|
3668
|
+
}, RESCAN_DELAY);
|
|
3669
|
+
if (rescanTimer.unref) rescanTimer.unref();
|
|
3670
|
+
};
|
|
3671
|
+
|
|
3284
3672
|
/**
|
|
3285
3673
|
* @param {string} filePath file path
|
|
3286
3674
|
* @returns {NodeJS.ErrnoException} new error with file path in the message
|
|
@@ -3359,6 +3747,7 @@ class DirectWatcher {
|
|
|
3359
3747
|
});
|
|
3360
3748
|
}
|
|
3361
3749
|
watcherCount++;
|
|
3750
|
+
streamRestarted();
|
|
3362
3751
|
}
|
|
3363
3752
|
|
|
3364
3753
|
/**
|
|
@@ -3377,7 +3766,10 @@ class DirectWatcher {
|
|
|
3377
3766
|
if (this.watchers.size === 0) {
|
|
3378
3767
|
directWatchers.delete(this.filePath);
|
|
3379
3768
|
watcherCount--;
|
|
3380
|
-
if (this.watcher)
|
|
3769
|
+
if (this.watcher) {
|
|
3770
|
+
this.watcher.close();
|
|
3771
|
+
streamRestarted();
|
|
3772
|
+
}
|
|
3381
3773
|
}
|
|
3382
3774
|
}
|
|
3383
3775
|
|
|
@@ -3449,6 +3841,7 @@ class RecursiveWatcher {
|
|
|
3449
3841
|
});
|
|
3450
3842
|
}
|
|
3451
3843
|
watcherCount++;
|
|
3844
|
+
streamRestarted();
|
|
3452
3845
|
if (recursiveWatcherLogging) {
|
|
3453
3846
|
process.stderr.write(
|
|
3454
3847
|
`[watchpack] created recursive watcher at ${rootPath}\n`,
|
|
@@ -3489,7 +3882,10 @@ class RecursiveWatcher {
|
|
|
3489
3882
|
if (this.mapWatcherToPath.size === 0) {
|
|
3490
3883
|
recursiveWatchers.delete(this.rootPath);
|
|
3491
3884
|
watcherCount--;
|
|
3492
|
-
if (this.watcher)
|
|
3885
|
+
if (this.watcher) {
|
|
3886
|
+
this.watcher.close();
|
|
3887
|
+
streamRestarted();
|
|
3888
|
+
}
|
|
3493
3889
|
if (recursiveWatcherLogging) {
|
|
3494
3890
|
process.stderr.write(
|
|
3495
3891
|
`[watchpack] closed recursive watcher at ${this.rootPath}\n`,
|
|
@@ -3507,6 +3903,7 @@ class RecursiveWatcher {
|
|
|
3507
3903
|
* @typedef {object} WatcherEvents
|
|
3508
3904
|
* @property {(eventType: EventType, filename?: string) => void} change change event
|
|
3509
3905
|
* @property {(err: unknown) => void} error error event
|
|
3906
|
+
* @property {() => void} rescan rescan event, when events may have been lost
|
|
3510
3907
|
*/
|
|
3511
3908
|
|
|
3512
3909
|
/**
|
|
@@ -3518,6 +3915,7 @@ class Watcher extends EventEmitter {
|
|
|
3518
3915
|
}
|
|
3519
3916
|
|
|
3520
3917
|
close() {
|
|
3918
|
+
activeWatchers.delete(this);
|
|
3521
3919
|
if (pendingWatchers.has(this)) {
|
|
3522
3920
|
pendingWatchers.delete(this);
|
|
3523
3921
|
return;
|
|
@@ -3665,6 +4063,7 @@ module.exports.getNumberOfWatchers = () => watcherCount;
|
|
|
3665
4063
|
*/
|
|
3666
4064
|
module.exports.watch = (filePath) => {
|
|
3667
4065
|
const watcher = new Watcher();
|
|
4066
|
+
activeWatchers.add(watcher);
|
|
3668
4067
|
// Find an existing watcher
|
|
3669
4068
|
const directWatcher = directWatchers.get(filePath);
|
|
3670
4069
|
if (directWatcher !== undefined) {
|
|
@@ -3804,7 +4203,7 @@ module.exports = require("util");
|
|
|
3804
4203
|
/******/ // startup
|
|
3805
4204
|
/******/ // Load entry module and return exports
|
|
3806
4205
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
3807
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(
|
|
4206
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(375);
|
|
3808
4207
|
/******/ module.exports = __webpack_exports__;
|
|
3809
4208
|
/******/
|
|
3810
4209
|
/******/ })()
|