webpack 5.62.1 → 5.64.1

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.

@@ -16,6 +16,7 @@ const processAsyncTree = require("./util/processAsyncTree");
16
16
  /** @typedef {import("./Compiler")} Compiler */
17
17
  /** @typedef {import("./logging/Logger").Logger} Logger */
18
18
  /** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
19
+ /** @typedef {import("./util/fs").StatsCallback} StatsCallback */
19
20
 
20
21
  /** @typedef {(function(string):boolean)|RegExp} IgnoreItem */
21
22
  /** @typedef {function(IgnoreItem): void} AddToIgnoreCallback */
@@ -102,6 +103,20 @@ const getDiffToOldAssets = (currentAssets, oldAssets) => {
102
103
  return diff;
103
104
  };
104
105
 
106
+ /**
107
+ * @param {OutputFileSystem} fs filesystem
108
+ * @param {string} filename path to file
109
+ * @param {StatsCallback} callback callback for provided filename
110
+ * @returns {void}
111
+ */
112
+ const doStat = (fs, filename, callback) => {
113
+ if ("lstat" in fs) {
114
+ fs.lstat(filename, callback);
115
+ } else {
116
+ fs.stat(filename, callback);
117
+ }
118
+ };
119
+
105
120
  /**
106
121
  * @param {OutputFileSystem} fs filesystem
107
122
  * @param {string} outputPath output path
@@ -150,7 +165,7 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
150
165
  log(`${filename} will be kept`);
151
166
  return process.nextTick(callback);
152
167
  }
153
- fs.stat(path, (err, stats) => {
168
+ doStat(fs, path, (err, stats) => {
154
169
  if (err) return handleError(err);
155
170
  if (!stats.isDirectory()) {
156
171
  push({
@@ -2424,9 +2424,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2424
2424
  let statNew = 0;
2425
2425
  /**
2426
2426
  * @param {Module} module module
2427
- * @returns {{ modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[] }} references
2427
+ * @returns {{ id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[] }} references
2428
2428
  */
2429
2429
  const computeReferences = module => {
2430
+ const id = chunkGraph.getModuleId(module);
2430
2431
  /** @type {Map<Module, string | number | undefined>} */
2431
2432
  let modules = undefined;
2432
2433
  /** @type {(string | number)[] | undefined} */
@@ -2454,16 +2455,18 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2454
2455
  queue.push.apply(queue, block.blocks);
2455
2456
  }
2456
2457
  }
2457
- return { modules, blocks };
2458
+ return { id, modules, blocks };
2458
2459
  };
2459
2460
  /**
2460
2461
  * @param {Module} module module
2461
2462
  * @param {Object} references references
2463
+ * @param {string | number} references.id id
2462
2464
  * @param {Map<Module, string | number>=} references.modules modules
2463
2465
  * @param {(string | number)[]=} references.blocks blocks
2464
2466
  * @returns {boolean} ok?
2465
2467
  */
2466
- const compareReferences = (module, { modules, blocks }) => {
2468
+ const compareReferences = (module, { id, modules, blocks }) => {
2469
+ if (id !== chunkGraph.getModuleId(module)) return false;
2467
2470
  if (modules !== undefined) {
2468
2471
  for (const [module, id] of modules) {
2469
2472
  if (chunkGraph.getModuleId(module) !== id) return false;
@@ -2489,7 +2492,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2489
2492
  };
2490
2493
 
2491
2494
  for (const [module, memCache] of moduleMemCaches) {
2492
- /** @type {{ references: { modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[]}, memCache: WeakTupleMap<any[], any> }} */
2495
+ /** @type {{ references: { id: string | number, modules?: Map<Module, string | number | undefined>, blocks?: (string | number)[]}, memCache: WeakTupleMap<any[], any> }} */
2493
2496
  const cache = memCache.get(key);
2494
2497
  if (cache === undefined) {
2495
2498
  const memCache2 = new WeakTupleMap();
@@ -64,6 +64,7 @@ class EntryOptionPlugin {
64
64
  dependOn: desc.dependOn,
65
65
  publicPath: desc.publicPath,
66
66
  chunkLoading: desc.chunkLoading,
67
+ asyncChunks: desc.asyncChunks,
67
68
  wasmLoading: desc.wasmLoading,
68
69
  library: desc.library
69
70
  };
@@ -692,6 +692,11 @@ class SnapshotOptimization {
692
692
  }
693
693
  }
694
694
 
695
+ const parseString = str => {
696
+ if (str[0] === "'") str = `"${str.slice(1, -1).replace(/"/g, '\\"')}"`;
697
+ return JSON.parse(str);
698
+ };
699
+
695
700
  /* istanbul ignore next */
696
701
  /**
697
702
  * @param {number} mtime mtime
@@ -1657,17 +1662,13 @@ class FileSystemInfo {
1657
1662
  let dependency;
1658
1663
  if (imp.d === -1) {
1659
1664
  // import ... from "..."
1660
- dependency = JSON.parse(
1665
+ dependency = parseString(
1661
1666
  source.substring(imp.s - 1, imp.e + 1)
1662
1667
  );
1663
1668
  } else if (imp.d > -1) {
1664
1669
  // import()
1665
1670
  let expr = source.substring(imp.s, imp.e).trim();
1666
- if (expr[0] === "'")
1667
- expr = `"${expr
1668
- .slice(1, -1)
1669
- .replace(/"/g, '\\"')}"`;
1670
- dependency = JSON.parse(expr);
1671
+ dependency = parseString(expr);
1671
1672
  } else {
1672
1673
  // e.g. import.meta
1673
1674
  continue;
@@ -2015,8 +2016,7 @@ class FileSystemInfo {
2015
2016
  }
2016
2017
  return capturedItems;
2017
2018
  };
2018
- if (files) {
2019
- const capturedFiles = captureNonManaged(files, managedFiles);
2019
+ const processCapturedFiles = capturedFiles => {
2020
2020
  switch (mode) {
2021
2021
  case 3:
2022
2022
  this._fileTshsOptimization.optimize(snapshot, capturedFiles);
@@ -2093,12 +2093,11 @@ class FileSystemInfo {
2093
2093
  }
2094
2094
  break;
2095
2095
  }
2096
+ };
2097
+ if (files) {
2098
+ processCapturedFiles(captureNonManaged(files, managedFiles));
2096
2099
  }
2097
- if (directories) {
2098
- const capturedDirectories = captureNonManaged(
2099
- directories,
2100
- managedContexts
2101
- );
2100
+ const processCapturedDirectories = capturedDirectories => {
2102
2101
  switch (mode) {
2103
2102
  case 3:
2104
2103
  this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
@@ -2218,9 +2217,13 @@ class FileSystemInfo {
2218
2217
  }
2219
2218
  break;
2220
2219
  }
2220
+ };
2221
+ if (directories) {
2222
+ processCapturedDirectories(
2223
+ captureNonManaged(directories, managedContexts)
2224
+ );
2221
2225
  }
2222
- if (missing) {
2223
- const capturedMissing = captureNonManaged(missing, managedMissing);
2226
+ const processCapturedMissing = capturedMissing => {
2224
2227
  this._missingExistenceOptimization.optimize(snapshot, capturedMissing);
2225
2228
  for (const path of capturedMissing) {
2226
2229
  const cache = this._fileTimestamps.get(path);
@@ -2245,11 +2248,15 @@ class FileSystemInfo {
2245
2248
  });
2246
2249
  }
2247
2250
  }
2251
+ };
2252
+ if (missing) {
2253
+ processCapturedMissing(captureNonManaged(missing, managedMissing));
2248
2254
  }
2249
2255
  this._managedItemInfoOptimization.optimize(snapshot, managedItems);
2250
2256
  for (const path of managedItems) {
2251
2257
  const cache = this._managedItems.get(path);
2252
2258
  if (cache !== undefined) {
2259
+ managedFiles.add(join(this.fs, path, "package.json"));
2253
2260
  managedItemInfo.set(path, cache);
2254
2261
  } else {
2255
2262
  jobs++;
@@ -2261,9 +2268,24 @@ class FileSystemInfo {
2261
2268
  );
2262
2269
  }
2263
2270
  jobError();
2264
- } else {
2271
+ } else if (entry) {
2272
+ managedFiles.add(join(this.fs, path, "package.json"));
2265
2273
  managedItemInfo.set(path, entry);
2266
2274
  jobDone();
2275
+ } else {
2276
+ // Fallback to normal snapshotting
2277
+ const process = (set, fn) => {
2278
+ if (set.size === 0) return;
2279
+ const captured = new Set();
2280
+ for (const file of set) {
2281
+ if (file.startsWith(path)) captured.add(file);
2282
+ }
2283
+ if (captured.size > 0) fn(captured);
2284
+ };
2285
+ process(managedFiles, processCapturedFiles);
2286
+ process(managedContexts, processCapturedDirectories);
2287
+ process(managedMissing, processCapturedMissing);
2288
+ jobDone();
2267
2289
  }
2268
2290
  });
2269
2291
  }
@@ -3476,9 +3498,10 @@ class FileSystemInfo {
3476
3498
  this._managedItems.set(path, "nested");
3477
3499
  return callback(null, "nested");
3478
3500
  }
3479
- const problem = `Managed item ${path} isn't a directory or doesn't contain a package.json`;
3480
- this.logger.warn(problem);
3481
- return callback(new Error(problem));
3501
+ this.logger.warn(
3502
+ `Managed item ${path} isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)`
3503
+ );
3504
+ return callback();
3482
3505
  });
3483
3506
  return;
3484
3507
  }
@@ -3490,6 +3513,12 @@ class FileSystemInfo {
3490
3513
  } catch (e) {
3491
3514
  return callback(e);
3492
3515
  }
3516
+ if (!data.name) {
3517
+ this.logger.warn(
3518
+ `${packageJsonPath} doesn't contain a "name" property (see snapshot.managedPaths option)`
3519
+ );
3520
+ return callback();
3521
+ }
3493
3522
  const info = `${data.name || ""}@${data.version || ""}`;
3494
3523
  this._managedItems.set(path, info);
3495
3524
  callback(null, info);
@@ -218,7 +218,15 @@ class RuntimePlugin {
218
218
  compilation.hooks.runtimeRequirementInTree
219
219
  .for(RuntimeGlobals.systemContext)
220
220
  .tap("RuntimePlugin", chunk => {
221
- if (compilation.outputOptions.library.type === "system") {
221
+ const { outputOptions } = compilation;
222
+ const { library: globalLibrary } = outputOptions;
223
+ const entryOptions = chunk.getEntryOptions();
224
+ const libraryType =
225
+ entryOptions && entryOptions.library !== undefined
226
+ ? entryOptions.library.type
227
+ : globalLibrary.type;
228
+
229
+ if (libraryType === "system") {
222
230
  compilation.addRuntimeModule(
223
231
  chunk,
224
232
  new SystemContextRuntimeModule()
@@ -5,6 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const { groupBy } = require("./util/ArrayHelpers");
8
9
  const createSchemaValidation = require("./util/create-schema-validation");
9
10
 
10
11
  /** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */
@@ -40,14 +41,12 @@ class IgnoringWatchFileSystem {
40
41
  p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0
41
42
  );
42
43
 
43
- const notIgnored = path => !ignored(path);
44
-
45
- const ignoredFiles = files.filter(ignored);
46
- const ignoredDirs = dirs.filter(ignored);
44
+ const [ignoredFiles, notIgnoredFiles] = groupBy(files, ignored);
45
+ const [ignoredDirs, notIgnoredDirs] = groupBy(dirs, ignored);
47
46
 
48
47
  const watcher = this.wfs.watch(
49
- files.filter(notIgnored),
50
- dirs.filter(notIgnored),
48
+ notIgnoredFiles,
49
+ notIgnoredDirs,
51
50
  missing,
52
51
  startTime,
53
52
  options,
@@ -50,6 +50,8 @@ const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
50
50
  * @property {Set<ChunkGroupInfo>} availableChildren set of chunk groups which depend on the this chunk group as availableSource
51
51
  * @property {number} preOrderIndex next pre order index
52
52
  * @property {number} postOrderIndex next post order index
53
+ * @property {boolean} chunkLoading has a chunk loading mechanism
54
+ * @property {boolean} asyncChunks create async chunks
53
55
  */
54
56
 
55
57
  /**
@@ -304,7 +306,15 @@ const visitModules = (
304
306
  availableSources: undefined,
305
307
  availableChildren: undefined,
306
308
  preOrderIndex: 0,
307
- postOrderIndex: 0
309
+ postOrderIndex: 0,
310
+ chunkLoading:
311
+ chunkGroup.options.chunkLoading !== undefined
312
+ ? chunkGroup.options.chunkLoading !== false
313
+ : compilation.outputOptions.chunkLoading !== false,
314
+ asyncChunks:
315
+ chunkGroup.options.asyncChunks !== undefined
316
+ ? chunkGroup.options.asyncChunks
317
+ : compilation.outputOptions.asyncChunks !== false
308
318
  };
309
319
  chunkGroup.index = nextChunkGroupIndex++;
310
320
  if (chunkGroup.getNumberOfParents() > 0) {
@@ -418,7 +428,15 @@ const visitModules = (
418
428
  availableSources: undefined,
419
429
  availableChildren: undefined,
420
430
  preOrderIndex: 0,
421
- postOrderIndex: 0
431
+ postOrderIndex: 0,
432
+ chunkLoading:
433
+ entryOptions.chunkLoading !== undefined
434
+ ? entryOptions.chunkLoading !== false
435
+ : chunkGroupInfo.chunkLoading,
436
+ asyncChunks:
437
+ entryOptions.asyncChunks !== undefined
438
+ ? entryOptions.asyncChunks
439
+ : chunkGroupInfo.asyncChunks
422
440
  };
423
441
  chunkGroupInfoMap.set(entrypoint, cgi);
424
442
 
@@ -442,8 +460,18 @@ const visitModules = (
442
460
  chunkGroup: entrypoint,
443
461
  chunkGroupInfo: cgi
444
462
  });
463
+ } else if (!chunkGroupInfo.asyncChunks || !chunkGroupInfo.chunkLoading) {
464
+ // Just queue the block into the current chunk group
465
+ queue.push({
466
+ action: PROCESS_BLOCK,
467
+ block: b,
468
+ module: module,
469
+ chunk,
470
+ chunkGroup,
471
+ chunkGroupInfo
472
+ });
445
473
  } else {
446
- cgi = namedChunkGroups.get(chunkName);
474
+ cgi = chunkName && namedChunkGroups.get(chunkName);
447
475
  if (!cgi) {
448
476
  c = compilation.addChunkInGroup(
449
477
  b.groupOptions || b.chunkName,
@@ -464,7 +492,9 @@ const visitModules = (
464
492
  availableSources: undefined,
465
493
  availableChildren: undefined,
466
494
  preOrderIndex: 0,
467
- postOrderIndex: 0
495
+ postOrderIndex: 0,
496
+ chunkLoading: chunkGroupInfo.chunkLoading,
497
+ asyncChunks: chunkGroupInfo.asyncChunks
468
498
  };
469
499
  allCreatedChunkGroups.add(c);
470
500
  chunkGroupInfoMap.set(c, cgi);
@@ -518,7 +548,7 @@ const visitModules = (
518
548
  chunkGroup: c,
519
549
  chunkGroupInfo: cgi
520
550
  });
521
- } else {
551
+ } else if (entrypoint !== undefined) {
522
552
  chunkGroupInfo.chunkGroup.addAsyncEntrypoint(entrypoint);
523
553
  }
524
554
  };
@@ -183,7 +183,8 @@ const applyWebpackOptionsDefaults = options => {
183
183
  applyModuleDefaults(options.module, {
184
184
  cache,
185
185
  syncWebAssembly: options.experiments.syncWebAssembly,
186
- asyncWebAssembly: options.experiments.asyncWebAssembly
186
+ asyncWebAssembly: options.experiments.asyncWebAssembly,
187
+ futureDefaults
187
188
  });
188
189
 
189
190
  applyOutputDefaults(options.output, {
@@ -382,7 +383,7 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
382
383
  return [path.resolve(match[1], "unplugged")];
383
384
  }
384
385
  } else {
385
- const match = /^(.+?[\\/]node_modules)[\\/]/.exec(
386
+ const match = /^(.+?[\\/]node_modules[\\/])/.exec(
386
387
  // eslint-disable-next-line node/no-extraneous-require
387
388
  require.resolve("watchpack")
388
389
  );
@@ -428,9 +429,14 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
428
429
 
429
430
  /**
430
431
  * @param {JavascriptParserOptions} parserOptions parser options
432
+ * @param {Object} options options
433
+ * @param {boolean} options.futureDefaults is future defaults enabled
431
434
  * @returns {void}
432
435
  */
433
- const applyJavascriptParserOptionsDefaults = parserOptions => {
436
+ const applyJavascriptParserOptionsDefaults = (
437
+ parserOptions,
438
+ { futureDefaults }
439
+ ) => {
434
440
  D(parserOptions, "unknownContextRequest", ".");
435
441
  D(parserOptions, "unknownContextRegExp", false);
436
442
  D(parserOptions, "unknownContextRecursive", true);
@@ -443,6 +449,7 @@ const applyJavascriptParserOptionsDefaults = parserOptions => {
443
449
  D(parserOptions, "wrappedContextRecursive", true);
444
450
  D(parserOptions, "wrappedContextCritical", false);
445
451
  D(parserOptions, "strictThisContextOnImports", false);
452
+ if (futureDefaults) D(parserOptions, "exportsPresence", "error");
446
453
  };
447
454
 
448
455
  /**
@@ -451,11 +458,12 @@ const applyJavascriptParserOptionsDefaults = parserOptions => {
451
458
  * @param {boolean} options.cache is caching enabled
452
459
  * @param {boolean} options.syncWebAssembly is syncWebAssembly enabled
453
460
  * @param {boolean} options.asyncWebAssembly is asyncWebAssembly enabled
461
+ * @param {boolean} options.futureDefaults is future defaults enabled
454
462
  * @returns {void}
455
463
  */
456
464
  const applyModuleDefaults = (
457
465
  module,
458
- { cache, syncWebAssembly, asyncWebAssembly }
466
+ { cache, syncWebAssembly, asyncWebAssembly, futureDefaults }
459
467
  ) => {
460
468
  if (cache) {
461
469
  D(module, "unsafeCache", module => {
@@ -473,7 +481,9 @@ const applyModuleDefaults = (
473
481
  }
474
482
 
475
483
  F(module.parser, "javascript", () => ({}));
476
- applyJavascriptParserOptionsDefaults(module.parser.javascript);
484
+ applyJavascriptParserOptionsDefaults(module.parser.javascript, {
485
+ futureDefaults
486
+ });
477
487
 
478
488
  A(module, "defaultRules", () => {
479
489
  const esm = {
@@ -734,6 +744,7 @@ const applyOutputDefaults = (
734
744
  "Chunk format can't be selected by default when no target is specified"
735
745
  );
736
746
  });
747
+ D(output, "asyncChunks", true);
737
748
  F(output, "chunkLoading", () => {
738
749
  if (tp) {
739
750
  switch (output.chunkFormat) {
@@ -229,6 +229,7 @@ const getNormalizedWebpackOptions = config => {
229
229
  wrappedContextRegExp: module.wrappedContextRegExp,
230
230
  wrappedContextRecursive: module.wrappedContextRecursive,
231
231
  wrappedContextCritical: module.wrappedContextCritical,
232
+ // TODO webpack 6 remove
232
233
  strictExportPresence: module.strictExportPresence,
233
234
  strictThisContextOnImports: module.strictThisContextOnImports,
234
235
  ...parserOptions
@@ -289,6 +290,7 @@ const getNormalizedWebpackOptions = config => {
289
290
  /** @type {OutputNormalized} */
290
291
  const result = {
291
292
  assetModuleFilename: output.assetModuleFilename,
293
+ asyncChunks: output.asyncChunks,
292
294
  charset: output.charset,
293
295
  chunkFilename: output.chunkFilename,
294
296
  chunkFormat: output.chunkFormat,
@@ -483,6 +485,7 @@ const getNormalizedEntryStatic = entry => {
483
485
  runtime: value.runtime,
484
486
  publicPath: value.publicPath,
485
487
  chunkLoading: value.chunkLoading,
488
+ asyncChunks: value.asyncChunks,
486
489
  wasmLoading: value.wasmLoading,
487
490
  dependOn:
488
491
  value.dependOn &&
@@ -203,15 +203,17 @@ class ProfilingPlugin {
203
203
 
204
204
  // Compiler Hooks
205
205
  Object.keys(compiler.hooks).forEach(hookName => {
206
- compiler.hooks[hookName].intercept(
207
- makeInterceptorFor("Compiler", tracer)(hookName)
208
- );
206
+ const hook = compiler.hooks[hookName];
207
+ if (hook) {
208
+ hook.intercept(makeInterceptorFor("Compiler", tracer)(hookName));
209
+ }
209
210
  });
210
211
 
211
212
  Object.keys(compiler.resolverFactory.hooks).forEach(hookName => {
212
- compiler.resolverFactory.hooks[hookName].intercept(
213
- makeInterceptorFor("Resolver", tracer)(hookName)
214
- );
213
+ const hook = compiler.resolverFactory.hooks[hookName];
214
+ if (hook) {
215
+ hook.intercept(makeInterceptorFor("Resolver", tracer)(hookName));
216
+ }
215
217
  });
216
218
 
217
219
  compiler.hooks.compilation.tap(
@@ -303,7 +305,7 @@ const interceptAllHooksFor = (instance, tracer, logLabel) => {
303
305
  if (Reflect.has(instance, "hooks")) {
304
306
  Object.keys(instance.hooks).forEach(hookName => {
305
307
  const hook = instance.hooks[hookName];
306
- if (!hook._fakeHook) {
308
+ if (hook && !hook._fakeHook) {
307
309
  hook.intercept(makeInterceptorFor(logLabel, tracer)(hookName));
308
310
  }
309
311
  });
@@ -282,7 +282,7 @@ class CommonJsImportsParserPlugin {
282
282
  dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
283
283
  dep.optional = !!parser.scope.inTry;
284
284
  dep.loc = expr.loc;
285
- parser.state.module.addDependency(dep);
285
+ parser.state.current.addDependency(dep);
286
286
  return true;
287
287
  }
288
288
  };
@@ -299,7 +299,7 @@ class CommonJsImportsParserPlugin {
299
299
  dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
300
300
  dep.optional = !!parser.scope.inTry;
301
301
  dep.loc = expr.callee.loc;
302
- parser.state.module.addDependency(dep);
302
+ parser.state.current.addDependency(dep);
303
303
  parser.walkExpressions(expr.arguments);
304
304
  return true;
305
305
  }
@@ -23,10 +23,10 @@ const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency;
23
23
  module.exports = class HarmonyExportDependencyParserPlugin {
24
24
  constructor(options) {
25
25
  this.exportPresenceMode =
26
- options.reexportExportPresence !== undefined
27
- ? ExportPresenceModes.fromUserOption(options.reexportExportPresence)
28
- : options.exportPresence !== undefined
29
- ? ExportPresenceModes.fromUserOption(options.exportPresence)
26
+ options.reexportExportsPresence !== undefined
27
+ ? ExportPresenceModes.fromUserOption(options.reexportExportsPresence)
28
+ : options.exportsPresence !== undefined
29
+ ? ExportPresenceModes.fromUserOption(options.exportsPresence)
30
30
  : options.strictExportPresence
31
31
  ? ExportPresenceModes.ERROR
32
32
  : ExportPresenceModes.AUTO;
@@ -755,8 +755,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
755
755
  * @returns {WebpackError[]} warnings
756
756
  */
757
757
  getWarnings(moduleGraph) {
758
- const exportPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
759
- if (exportPresence === ExportPresenceModes.WARN) {
758
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
759
+ if (exportsPresence === ExportPresenceModes.WARN) {
760
760
  return this._getErrors(moduleGraph);
761
761
  }
762
762
  return null;
@@ -768,8 +768,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
768
768
  * @returns {WebpackError[]} errors
769
769
  */
770
770
  getErrors(moduleGraph) {
771
- const exportPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
772
- if (exportPresence === ExportPresenceModes.ERROR) {
771
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
772
+ if (exportsPresence === ExportPresenceModes.ERROR) {
773
773
  return this._getErrors(moduleGraph);
774
774
  }
775
775
  return null;
@@ -38,6 +38,8 @@ const ExportPresenceModes = {
38
38
  return ExportPresenceModes.ERROR;
39
39
  case "warn":
40
40
  return ExportPresenceModes.WARN;
41
+ case "auto":
42
+ return ExportPresenceModes.AUTO;
41
43
  case false:
42
44
  return ExportPresenceModes.NONE;
43
45
  default:
@@ -67,10 +67,10 @@ module.exports = class HarmonyImportDependencyParserPlugin {
67
67
  */
68
68
  constructor(options) {
69
69
  this.exportPresenceMode =
70
- options.importExportPresence !== undefined
71
- ? ExportPresenceModes.fromUserOption(options.importExportPresence)
72
- : options.exportPresence !== undefined
73
- ? ExportPresenceModes.fromUserOption(options.exportPresence)
70
+ options.importExportsPresence !== undefined
71
+ ? ExportPresenceModes.fromUserOption(options.importExportsPresence)
72
+ : options.exportsPresence !== undefined
73
+ ? ExportPresenceModes.fromUserOption(options.exportsPresence)
74
74
  : options.strictExportPresence
75
75
  ? ExportPresenceModes.ERROR
76
76
  : ExportPresenceModes.AUTO;
@@ -173,8 +173,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
173
173
  * @returns {WebpackError[]} warnings
174
174
  */
175
175
  getWarnings(moduleGraph) {
176
- const exportPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
177
- if (exportPresence === ExportPresenceModes.WARN) {
176
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
177
+ if (exportsPresence === ExportPresenceModes.WARN) {
178
178
  return this._getErrors(moduleGraph);
179
179
  }
180
180
  return null;
@@ -186,8 +186,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
186
186
  * @returns {WebpackError[]} errors
187
187
  */
188
188
  getErrors(moduleGraph) {
189
- const exportPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
190
- if (exportPresence === ExportPresenceModes.ERROR) {
189
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
190
+ if (exportsPresence === ExportPresenceModes.ERROR) {
191
191
  return this._getErrors(moduleGraph);
192
192
  }
193
193
  return null;
@@ -82,7 +82,7 @@ class URLPlugin {
82
82
  relative
83
83
  );
84
84
  dep.loc = expr.loc;
85
- parser.state.module.addDependency(dep);
85
+ parser.state.current.addDependency(dep);
86
86
  InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e));
87
87
  return true;
88
88
  });
@@ -1160,7 +1160,7 @@ const AVAILABLE_FORMATS = {
1160
1160
  },
1161
1161
  { regExp: /(\(module has no exports\))/g, format: red },
1162
1162
  { regExp: /\(possible exports: (.+)\)/g, format: green },
1163
- { regExp: /\s*(.+ doesn't exist)/g, format: red },
1163
+ { regExp: /\s*([^\s].* doesn't exist)/g, format: red },
1164
1164
  { regExp: /('\w+' option has not been set)/g, format: red },
1165
1165
  {
1166
1166
  regExp: /(Emitted value instead of an instance of Error)/g,
@@ -12,3 +12,19 @@ exports.equals = (a, b) => {
12
12
  }
13
13
  return true;
14
14
  };
15
+
16
+ /**
17
+ *
18
+ * @param {Array} arr Array of values to be partitioned
19
+ * @param {(value: any) => boolean} fn Partition function which partitions based on truthiness of result.
20
+ * @returns {[Array, Array]} returns the values of `arr` partitioned into two new arrays based on fn predicate.
21
+ */
22
+ exports.groupBy = (arr = [], fn) => {
23
+ return arr.reduce(
24
+ (groups, value) => {
25
+ groups[fn(value) ? 0 : 1].push(value);
26
+ return groups;
27
+ },
28
+ [[], []]
29
+ );
30
+ };
package/lib/util/fs.js CHANGED
@@ -93,6 +93,7 @@ const path = require("path");
93
93
  * @property {function(string, Callback): void=} rmdir
94
94
  * @property {function(string, Callback): void=} unlink
95
95
  * @property {function(string, StatsCallback): void} stat
96
+ * @property {function(string, StatsCallback): void=} lstat
96
97
  * @property {function(string, BufferOrStringCallback): void} readFile
97
98
  * @property {(function(string, string): string)=} join
98
99
  * @property {(function(string, string): string)=} relative