webpack 5.12.1 → 5.14.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

@@ -45,7 +45,7 @@ class AutomaticPrefetchPlugin {
45
45
  (m, callback) => {
46
46
  compilation.addModuleChain(
47
47
  m.context || compiler.context,
48
- new PrefetchDependency(m.request),
48
+ new PrefetchDependency(`!!${m.request}`),
49
49
  callback
50
50
  );
51
51
  },
package/lib/ChunkGraph.js CHANGED
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const util = require("util");
9
+ const ModuleGraphConnection = require("./ModuleGraphConnection");
9
10
  const SortableSet = require("./util/SortableSet");
10
11
  const {
11
12
  compareModulesById,
@@ -272,10 +273,19 @@ class ChunkGraph {
272
273
  findGraphRoots(set, module => {
273
274
  /** @type {Set<Module>} */
274
275
  const set = new Set();
275
- for (const connection of moduleGraph.getOutgoingConnections(module)) {
276
- if (!connection.module) continue;
277
- set.add(connection.module);
278
- }
276
+ const addDependencies = module => {
277
+ for (const connection of moduleGraph.getOutgoingConnections(module)) {
278
+ if (!connection.module) continue;
279
+ const activeState = connection.getActiveState(undefined);
280
+ if (activeState === false) continue;
281
+ if (activeState === ModuleGraphConnection.TRANSITIVE_ONLY) {
282
+ addDependencies(connection.module);
283
+ continue;
284
+ }
285
+ set.add(connection.module);
286
+ }
287
+ };
288
+ addDependencies(module);
279
289
  return set;
280
290
  })
281
291
  ).sort(compareModulesByIdentifier);
package/lib/Compiler.js CHANGED
@@ -222,9 +222,9 @@ class Compiler {
222
222
  this.modifiedFiles = undefined;
223
223
  /** @type {Set<string>} */
224
224
  this.removedFiles = undefined;
225
- /** @type {Map<string, FileSystemInfoEntry | null>} */
225
+ /** @type {Map<string, FileSystemInfoEntry | "ignore" | null>} */
226
226
  this.fileTimestamps = undefined;
227
- /** @type {Map<string, FileSystemInfoEntry | null>} */
227
+ /** @type {Map<string, FileSystemInfoEntry | "ignore" | null>} */
228
228
  this.contextTimestamps = undefined;
229
229
 
230
230
  /** @type {ResolverFactory} */
@@ -724,7 +724,10 @@ ${other}`);
724
724
  return this.outputFileSystem.readFile(
725
725
  targetPath,
726
726
  (err, existingContent) => {
727
- if (err || !content.equals(existingContent)) {
727
+ if (
728
+ err ||
729
+ !content.equals(/** @type {Buffer} */ (existingContent))
730
+ ) {
728
731
  return doWrite(content);
729
732
  } else {
730
733
  return alreadyWritten();
@@ -298,11 +298,13 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
298
298
  const addDirectory = (directory, addSubDirectory, callback) => {
299
299
  fs.readdir(directory, (err, files) => {
300
300
  if (err) return callback(err);
301
- files = files.map(file => file.normalize("NFC"));
302
- files = cmf.hooks.contextModuleFiles.call(files);
303
- if (!files || files.length === 0) return callback(null, []);
301
+ const processedFiles = cmf.hooks.contextModuleFiles.call(
302
+ /** @type {string[]} */ (files).map(file => file.normalize("NFC"))
303
+ );
304
+ if (!processedFiles || processedFiles.length === 0)
305
+ return callback(null, []);
304
306
  asyncLib.map(
305
- files.filter(p => p.indexOf(".") !== 0),
307
+ processedFiles.filter(p => p.indexOf(".") !== 0),
306
308
  (segment, callback) => {
307
309
  const subResource = join(fs, directory, segment);
308
310
 
@@ -16,6 +16,8 @@ const makeSerializable = require("./util/makeSerializable");
16
16
  /** @typedef {import("./logging/Logger").Logger} Logger */
17
17
  /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
18
18
 
19
+ const supportsEsm = +process.versions.modules >= 83;
20
+
19
21
  const resolveContext = createResolver({
20
22
  resolveToContext: true,
21
23
  exportsFields: []
@@ -880,6 +882,8 @@ class FileSystemInfo {
880
882
  this._cachedDeprecatedFileTimestamps = undefined;
881
883
  this._cachedDeprecatedContextTimestamps = undefined;
882
884
 
885
+ this._warnAboutExperimentalEsmTracking = false;
886
+
883
887
  this._statCreatedSnapshots = 0;
884
888
  this._statTestedSnapshotsCached = 0;
885
889
  this._statTestedSnapshotsNotCached = 0;
@@ -1171,8 +1175,9 @@ class FileSystemInfo {
1171
1175
  callback();
1172
1176
  break;
1173
1177
  }
1174
- this.fs.realpath(path, (err, realPath) => {
1178
+ this.fs.realpath(path, (err, _realPath) => {
1175
1179
  if (err) return callback(err);
1180
+ const realPath = /** @type {string} */ (_realPath);
1176
1181
  if (realPath !== path) {
1177
1182
  resolveFiles.add(path);
1178
1183
  }
@@ -1192,8 +1197,9 @@ class FileSystemInfo {
1192
1197
  callback();
1193
1198
  break;
1194
1199
  }
1195
- this.fs.realpath(path, (err, realPath) => {
1200
+ this.fs.realpath(path, (err, _realPath) => {
1196
1201
  if (err) return callback(err);
1202
+ const realPath = /** @type {string} */ (_realPath);
1197
1203
  if (realPath !== path) {
1198
1204
  resolveFiles.add(path);
1199
1205
  }
@@ -1209,7 +1215,12 @@ class FileSystemInfo {
1209
1215
  break;
1210
1216
  }
1211
1217
  case RBDT_FILE_DEPENDENCIES: {
1212
- // TODO this probably doesn't work correctly with ESM dependencies
1218
+ // Check for known files without dependencies
1219
+ if (/\.json5?$|\.yarn-integrity$|yarn\.lock$|\.ya?ml/.test(path)) {
1220
+ process.nextTick(callback);
1221
+ break;
1222
+ }
1223
+ // Check commonjs cache for the module
1213
1224
  /** @type {NodeModule} */
1214
1225
  const module = require.cache[path];
1215
1226
  if (module && Array.isArray(module.children)) {
@@ -1246,15 +1257,73 @@ class FileSystemInfo {
1246
1257
  });
1247
1258
  }
1248
1259
  }
1260
+ } else if (supportsEsm && /\.m?js$/.test(path)) {
1261
+ if (!this._warnAboutExperimentalEsmTracking) {
1262
+ this.logger.info(
1263
+ "Node.js doesn't offer a (nice) way to introspect the ESM dependency graph yet.\n" +
1264
+ "Until a full solution is available webpack uses an experimental ESM tracking based on parsing.\n" +
1265
+ "As best effort webpack parses the ESM files to guess dependencies. But this can lead to expensive and incorrect tracking."
1266
+ );
1267
+ this._warnAboutExperimentalEsmTracking = true;
1268
+ }
1269
+ const lexer = require("es-module-lexer");
1270
+ lexer.init.then(() => {
1271
+ this.fs.readFile(path, (err, content) => {
1272
+ if (err) return callback(err);
1273
+ try {
1274
+ const context = dirname(this.fs, path);
1275
+ const source = content.toString();
1276
+ const [imports] = lexer.parse(source);
1277
+ for (const imp of imports) {
1278
+ try {
1279
+ let dependency;
1280
+ if (imp.d === -1) {
1281
+ // import ... from "..."
1282
+ dependency = JSON.parse(
1283
+ source.substring(imp.s - 1, imp.e + 1)
1284
+ );
1285
+ } else if (imp.d > -1) {
1286
+ // import()
1287
+ let expr = source.substring(imp.s, imp.e).trim();
1288
+ if (expr[0] === "'")
1289
+ expr = `"${expr
1290
+ .slice(1, -1)
1291
+ .replace(/"/g, '\\"')}"`;
1292
+ dependency = JSON.parse(expr);
1293
+ } else {
1294
+ // e.g. import.meta
1295
+ continue;
1296
+ }
1297
+ queue.push({
1298
+ type: RBDT_RESOLVE_FILE,
1299
+ context,
1300
+ path: dependency
1301
+ });
1302
+ } catch (e) {
1303
+ this.logger.warn(
1304
+ `Parsing of ${path} for build dependencies failed at 'import(${source.substring(
1305
+ imp.s,
1306
+ imp.e
1307
+ )})'.\n` +
1308
+ "Build dependencies behind this expression are ignored and might cause incorrect cache invalidation."
1309
+ );
1310
+ this.logger.debug(e.stack);
1311
+ }
1312
+ }
1313
+ } catch (e) {
1314
+ this.logger.warn(
1315
+ `Parsing of ${path} for build dependencies failed and all dependencies of this file are ignored, which might cause incorrect cache invalidation..`
1316
+ );
1317
+ this.logger.debug(e.stack);
1318
+ }
1319
+ process.nextTick(callback);
1320
+ });
1321
+ }, callback);
1322
+ break;
1249
1323
  } else {
1250
- // Unable to get dependencies from module system
1251
- // This may be because of an incomplete require.cache implementation like in jest
1252
- // Assume requires stay in directory and add the whole directory
1253
- const directory = dirname(this.fs, path);
1254
- queue.push({
1255
- type: RBDT_DIRECTORY,
1256
- path: directory
1257
- });
1324
+ this.logger.log(
1325
+ `Assuming ${path} has no dependencies as we were unable to assign it to any module system.`
1326
+ );
1258
1327
  }
1259
1328
  process.nextTick(callback);
1260
1329
  break;
@@ -1604,7 +1673,7 @@ class FileSystemInfo {
1604
1673
  if (err) {
1605
1674
  if (this.logger) {
1606
1675
  this.logger.debug(
1607
- `Error snapshotting file timestamp hash combination of ${path}: ${err}`
1676
+ `Error snapshotting file timestamp hash combination of ${path}: ${err.stack}`
1608
1677
  );
1609
1678
  }
1610
1679
  jobError();
@@ -1632,7 +1701,7 @@ class FileSystemInfo {
1632
1701
  if (err) {
1633
1702
  if (this.logger) {
1634
1703
  this.logger.debug(
1635
- `Error snapshotting file hash of ${path}: ${err}`
1704
+ `Error snapshotting file hash of ${path}: ${err.stack}`
1636
1705
  );
1637
1706
  }
1638
1707
  jobError();
@@ -1662,7 +1731,7 @@ class FileSystemInfo {
1662
1731
  if (err) {
1663
1732
  if (this.logger) {
1664
1733
  this.logger.debug(
1665
- `Error snapshotting file timestamp of ${path}: ${err}`
1734
+ `Error snapshotting file timestamp of ${path}: ${err.stack}`
1666
1735
  );
1667
1736
  }
1668
1737
  jobError();
@@ -1698,7 +1767,7 @@ class FileSystemInfo {
1698
1767
  if (err) {
1699
1768
  if (this.logger) {
1700
1769
  this.logger.debug(
1701
- `Error snapshotting context timestamp hash combination of ${path}: ${err}`
1770
+ `Error snapshotting context timestamp hash combination of ${path}: ${err.stack}`
1702
1771
  );
1703
1772
  }
1704
1773
  jobError();
@@ -1726,7 +1795,7 @@ class FileSystemInfo {
1726
1795
  if (err) {
1727
1796
  if (this.logger) {
1728
1797
  this.logger.debug(
1729
- `Error snapshotting context hash of ${path}: ${err}`
1798
+ `Error snapshotting context hash of ${path}: ${err.stack}`
1730
1799
  );
1731
1800
  }
1732
1801
  jobError();
@@ -1756,7 +1825,7 @@ class FileSystemInfo {
1756
1825
  if (err) {
1757
1826
  if (this.logger) {
1758
1827
  this.logger.debug(
1759
- `Error snapshotting context timestamp of ${path}: ${err}`
1828
+ `Error snapshotting context timestamp of ${path}: ${err.stack}`
1760
1829
  );
1761
1830
  }
1762
1831
  jobError();
@@ -1789,7 +1858,7 @@ class FileSystemInfo {
1789
1858
  if (err) {
1790
1859
  if (this.logger) {
1791
1860
  this.logger.debug(
1792
- `Error snapshotting missing timestamp of ${path}: ${err}`
1861
+ `Error snapshotting missing timestamp of ${path}: ${err.stack}`
1793
1862
  );
1794
1863
  }
1795
1864
  jobError();
@@ -1816,7 +1885,7 @@ class FileSystemInfo {
1816
1885
  if (err) {
1817
1886
  if (this.logger) {
1818
1887
  this.logger.debug(
1819
- `Error snapshotting managed item ${path}: ${err}`
1888
+ `Error snapshotting managed item ${path}: ${err.stack}`
1820
1889
  );
1821
1890
  }
1822
1891
  jobError();
@@ -2346,6 +2415,11 @@ class FileSystemInfo {
2346
2415
  this._fileHashes.set(path, null);
2347
2416
  return callback(null, null);
2348
2417
  }
2418
+ if (err.code === "ERR_FS_FILE_TOO_LARGE") {
2419
+ this.logger.warn(`Ignoring ${path} for hashing as it's very large`);
2420
+ this._fileHashes.set(path, "too large");
2421
+ return callback(null, "too large");
2422
+ }
2349
2423
  return callback(err);
2350
2424
  }
2351
2425
 
@@ -2405,7 +2479,7 @@ class FileSystemInfo {
2405
2479
  }
2406
2480
 
2407
2481
  _readContextTimestamp(path, callback) {
2408
- this.fs.readdir(path, (err, files) => {
2482
+ this.fs.readdir(path, (err, _files) => {
2409
2483
  if (err) {
2410
2484
  if (err.code === "ENOENT") {
2411
2485
  this._contextTimestamps.set(path, null);
@@ -2414,7 +2488,7 @@ class FileSystemInfo {
2414
2488
  }
2415
2489
  return callback(err);
2416
2490
  }
2417
- files = files
2491
+ const files = /** @type {string[]} */ (_files)
2418
2492
  .map(file => file.normalize("NFC"))
2419
2493
  .filter(file => !/^\./.test(file))
2420
2494
  .sort();
@@ -2501,7 +2575,7 @@ class FileSystemInfo {
2501
2575
  }
2502
2576
 
2503
2577
  _readContextHash(path, callback) {
2504
- this.fs.readdir(path, (err, files) => {
2578
+ this.fs.readdir(path, (err, _files) => {
2505
2579
  if (err) {
2506
2580
  if (err.code === "ENOENT") {
2507
2581
  this._contextHashes.set(path, null);
@@ -2509,7 +2583,7 @@ class FileSystemInfo {
2509
2583
  }
2510
2584
  return callback(err);
2511
2585
  }
2512
- files = files
2586
+ const files = /** @type {string[]} */ (_files)
2513
2587
  .map(file => file.normalize("NFC"))
2514
2588
  .filter(file => !/^\./.test(file))
2515
2589
  .sort();
@@ -2624,7 +2698,9 @@ class FileSystemInfo {
2624
2698
  return callback(err);
2625
2699
  }
2626
2700
  const set = new Set(
2627
- elements.map(element => join(this.fs, path, element))
2701
+ /** @type {string[]} */ (elements).map(element =>
2702
+ join(this.fs, path, element)
2703
+ )
2628
2704
  );
2629
2705
  callback(null, set);
2630
2706
  });
@@ -226,6 +226,7 @@ module.exports = class MultiCompiler {
226
226
  }
227
227
  }
228
228
  }
229
+ /** @type {string[]} */
229
230
  const errors = missing.map(m => `Compiler dependency \`${m}\` not found.`);
230
231
  const stack = this.compilers.filter(c => !targetFound(c));
231
232
  while (stack.length > 0) {
@@ -241,6 +242,7 @@ module.exports = class MultiCompiler {
241
242
  }
242
243
  }
243
244
  if (edges.size > 0) {
245
+ /** @type {string[]} */
244
246
  const lines = Array.from(edges)
245
247
  .sort(sortEdges)
246
248
  .map(edge => `${edge.source.name} -> ${edge.target.name}`);
@@ -10,10 +10,15 @@ const schema = require("../schemas/plugins/WatchIgnorePlugin.json");
10
10
 
11
11
  /** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */
12
12
  /** @typedef {import("./Compiler")} Compiler */
13
+ /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */
13
14
 
14
15
  const IGNORE_TIME_ENTRY = "ignore";
15
16
 
16
17
  class IgnoringWatchFileSystem {
18
+ /**
19
+ * @param {WatchFileSystem} wfs original file system
20
+ * @param {(string|RegExp)[]} paths ignored paths
21
+ */
17
22
  constructor(wfs, paths) {
18
23
  this.wfs = wfs;
19
24
  this.paths = paths;
@@ -63,7 +68,7 @@ class IgnoringWatchFileSystem {
63
68
  close: () => watcher.close(),
64
69
  pause: () => watcher.pause(),
65
70
  getContextTimeInfoEntries: () => {
66
- const dirTimestamps = watcher.getContextInfoEntries();
71
+ const dirTimestamps = watcher.getContextTimeInfoEntries();
67
72
  for (const path of ignoredDirs) {
68
73
  dirTimestamps.set(path, IGNORE_TIME_ENTRY);
69
74
  }
@@ -1072,18 +1072,18 @@ class PackFileCacheStrategy {
1072
1072
  return promise.then(() => {
1073
1073
  if (reportProgress) reportProgress(0.8, "serialize pack");
1074
1074
  this.logger.time(`store pack`);
1075
+ const updatedBuildDependencies = new Set(this.buildDependencies);
1076
+ for (const dep of newBuildDependencies) {
1077
+ updatedBuildDependencies.add(dep);
1078
+ }
1075
1079
  const content = new PackContainer(
1076
1080
  pack,
1077
1081
  this.version,
1078
1082
  this.buildSnapshot,
1079
- this.buildDependencies,
1083
+ updatedBuildDependencies,
1080
1084
  this.resolveResults,
1081
1085
  this.resolveBuildDependenciesSnapshot
1082
1086
  );
1083
- // You might think this breaks all access to the existing pack
1084
- // which are still referenced, but serializing the pack memorizes
1085
- // all data in the pack and makes it no longer need the backing file
1086
- // So it's safe to replace the pack file
1087
1087
  return this.fileSerializer
1088
1088
  .serialize(content, {
1089
1089
  filename: `${this.cacheLocation}/index.pack`,
@@ -77,9 +77,14 @@ const shortenLongString = (string, delimiter) => {
77
77
  * @returns {string} short module name
78
78
  */
79
79
  const getShortModuleName = (module, context, associatedObjectForCache) => {
80
- return avoidNumber(
81
- module.libIdent({ context, associatedObjectForCache }) || ""
82
- );
80
+ const libIdent = module.libIdent({ context, associatedObjectForCache });
81
+ if (libIdent) return avoidNumber(libIdent);
82
+ const nameForCondition = module.nameForCondition();
83
+ if (nameForCondition)
84
+ return avoidNumber(
85
+ makePathsRelative(context, nameForCondition, associatedObjectForCache)
86
+ );
87
+ return "";
83
88
  };
84
89
  exports.getShortModuleName = getShortModuleName;
85
90
 
@@ -441,7 +441,7 @@ class FileMiddleware extends SerializerMiddleware {
441
441
  reject(err);
442
442
  return;
443
443
  }
444
- let remaining = stats.size;
444
+ let remaining = /** @type {number} */ (stats.size);
445
445
  let currentBuffer;
446
446
  let currentBufferUsed;
447
447
  const buf = [];
@@ -11,6 +11,12 @@
11
11
 
12
12
  const plural = (n, singular, plural) => (n === 1 ? singular : plural);
13
13
 
14
+ /**
15
+ * @param {Record<string, number>} sizes sizes by source type
16
+ * @param {Object} options options
17
+ * @param {(number) => string=} options.formatSize size formatter
18
+ * @returns {string} text
19
+ */
14
20
  const printSizes = (sizes, { formatSize = n => `${n}` }) => {
15
21
  const keys = Object.keys(sizes);
16
22
  if (keys.length > 1) {
package/lib/util/fs.js CHANGED
@@ -7,25 +7,65 @@
7
7
 
8
8
  const path = require("path");
9
9
 
10
- /** @typedef {import("fs").Stats} NodeFsStats */
11
10
  /** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */
12
11
  /** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
13
12
 
13
+ /**
14
+ * @typedef {Object} IStats
15
+ * @property {() => boolean} isFile
16
+ * @property {() => boolean} isDirectory
17
+ * @property {() => boolean} isBlockDevice
18
+ * @property {() => boolean} isCharacterDevice
19
+ * @property {() => boolean} isSymbolicLink
20
+ * @property {() => boolean} isFIFO
21
+ * @property {() => boolean} isSocket
22
+ * @property {number | bigint} dev
23
+ * @property {number | bigint} ino
24
+ * @property {number | bigint} mode
25
+ * @property {number | bigint} nlink
26
+ * @property {number | bigint} uid
27
+ * @property {number | bigint} gid
28
+ * @property {number | bigint} rdev
29
+ * @property {number | bigint} size
30
+ * @property {number | bigint} blksize
31
+ * @property {number | bigint} blocks
32
+ * @property {number | bigint} atimeMs
33
+ * @property {number | bigint} mtimeMs
34
+ * @property {number | bigint} ctimeMs
35
+ * @property {number | bigint} birthtimeMs
36
+ * @property {Date} atime
37
+ * @property {Date} mtime
38
+ * @property {Date} ctime
39
+ * @property {Date} birthtime
40
+ */
41
+
42
+ /**
43
+ * @typedef {Object} IDirent
44
+ * @property {() => boolean} isFile
45
+ * @property {() => boolean} isDirectory
46
+ * @property {() => boolean} isBlockDevice
47
+ * @property {() => boolean} isCharacterDevice
48
+ * @property {() => boolean} isSymbolicLink
49
+ * @property {() => boolean} isFIFO
50
+ * @property {() => boolean} isSocket
51
+ * @property {string | Buffer} name
52
+ */
53
+
14
54
  /** @typedef {function(NodeJS.ErrnoException=): void} Callback */
15
55
  /** @typedef {function(NodeJS.ErrnoException=, Buffer=): void} BufferCallback */
16
56
  /** @typedef {function(NodeJS.ErrnoException=, Buffer|string=): void} BufferOrStringCallback */
17
- /** @typedef {function(NodeJS.ErrnoException=, string[]=): void} StringArrayCallback */
57
+ /** @typedef {function(NodeJS.ErrnoException=, (string | Buffer)[] | IDirent[]=): void} DirentArrayCallback */
18
58
  /** @typedef {function(NodeJS.ErrnoException=, string=): void} StringCallback */
19
59
  /** @typedef {function(NodeJS.ErrnoException=, number=): void} NumberCallback */
20
- /** @typedef {function(NodeJS.ErrnoException=, NodeFsStats=): void} StatsCallback */
60
+ /** @typedef {function(NodeJS.ErrnoException=, IStats=): void} StatsCallback */
21
61
  /** @typedef {function((NodeJS.ErrnoException | Error)=, any=): void} ReadJsonCallback */
22
62
 
23
63
  /**
24
64
  * @typedef {Object} Watcher
25
65
  * @property {function(): void} close closes the watcher and all underlying file watchers
26
66
  * @property {function(): void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
27
- * @property {function(): Map<string, FileSystemInfoEntry>} getFileTimeInfoEntries get info about files
28
- * @property {function(): Map<string, FileSystemInfoEntry>} getContextTimeInfoEntries get info about directories
67
+ * @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getFileTimeInfoEntries get info about files
68
+ * @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getContextTimeInfoEntries get info about directories
29
69
  */
30
70
 
31
71
  /**
@@ -35,7 +75,7 @@ const path = require("path");
35
75
  * @param {Iterable<string>} missing watched exitance entries
36
76
  * @param {number} startTime timestamp of start time
37
77
  * @param {WatchOptions} options options object
38
- * @param {function(Error=, Map<string, FileSystemInfoEntry>, Map<string, FileSystemInfoEntry>, Set<string>, Set<string>): void} callback aggregated callback
78
+ * @param {function(Error=, Map<string, FileSystemInfoEntry | "ignore">, Map<string, FileSystemInfoEntry | "ignore">, Set<string>, Set<string>): void} callback aggregated callback
39
79
  * @param {function(string, number): void} callbackUndelayed callback when the first change was detected
40
80
  * @returns {Watcher} a watcher
41
81
  */
@@ -45,7 +85,7 @@ const path = require("path");
45
85
  * @property {function(string, Buffer|string, Callback): void} writeFile
46
86
  * @property {function(string, Callback): void} mkdir
47
87
  * @property {function(string, StatsCallback): void} stat
48
- * @property {function(string, BufferCallback): void} readFile
88
+ * @property {function(string, BufferOrStringCallback): void} readFile
49
89
  * @property {(function(string, string): string)=} join
50
90
  * @property {(function(string, string): string)=} relative
51
91
  * @property {(function(string): string)=} dirname
@@ -53,12 +93,12 @@ const path = require("path");
53
93
 
54
94
  /**
55
95
  * @typedef {Object} InputFileSystem
56
- * @property {function(string, BufferCallback): void} readFile
96
+ * @property {function(string, BufferOrStringCallback): void} readFile
57
97
  * @property {(function(string, ReadJsonCallback): void)=} readJson
58
98
  * @property {function(string, BufferOrStringCallback): void} readlink
59
- * @property {function(string, StringArrayCallback): void} readdir
99
+ * @property {function(string, DirentArrayCallback): void} readdir
60
100
  * @property {function(string, StatsCallback): void} stat
61
- * @property {(function(string, StringCallback): void)=} realpath
101
+ * @property {(function(string, BufferOrStringCallback): void)=} realpath
62
102
  * @property {(function(string=): void)=} purge
63
103
  * @property {(function(string, string): string)=} join
64
104
  * @property {(function(string, string): string)=} relative
@@ -73,7 +113,7 @@ const path = require("path");
73
113
  /**
74
114
  * @typedef {Object} IntermediateFileSystemExtras
75
115
  * @property {function(string): void} mkdirSync
76
- * @property {function(string): import("fs").WriteStream} createWriteStream
116
+ * @property {function(string): NodeJS.WritableStream} createWriteStream
77
117
  * @property {function(string, string, NumberCallback): void} open
78
118
  * @property {function(number, Buffer, number, number, number, NumberCallback): void} read
79
119
  * @property {function(number, Callback): void} close
@@ -10,9 +10,7 @@ const Generator = require("../Generator");
10
10
  const WebAssemblyUtils = require("./WebAssemblyUtils");
11
11
 
12
12
  const t = require("@webassemblyjs/ast");
13
- const {
14
- moduleContextFromModuleAST
15
- } = require("@webassemblyjs/helper-module-context");
13
+ const { moduleContextFromModuleAST } = require("@webassemblyjs/ast");
16
14
  const { editWithAST, addWithAST } = require("@webassemblyjs/wasm-edit");
17
15
  const { decode } = require("@webassemblyjs/wasm-parser");
18
16
 
@@ -6,9 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const t = require("@webassemblyjs/ast");
9
- const {
10
- moduleContextFromModuleAST
11
- } = require("@webassemblyjs/helper-module-context");
9
+ const { moduleContextFromModuleAST } = require("@webassemblyjs/ast");
12
10
  const { decode } = require("@webassemblyjs/wasm-parser");
13
11
  const Parser = require("../Parser");
14
12
  const StaticExportsDependency = require("../dependencies/StaticExportsDependency");