webpack 4.10.1 → 4.12.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.
Files changed (118) hide show
  1. package/lib/AmdMainTemplatePlugin.js +3 -1
  2. package/lib/AsyncDependencyToInitialChunkError.js +4 -4
  3. package/lib/BannerPlugin.js +3 -1
  4. package/lib/BasicEvaluatedExpression.js +14 -11
  5. package/lib/CachePlugin.js +12 -5
  6. package/lib/CaseSensitiveModulesWarning.js +41 -45
  7. package/lib/Chunk.js +56 -19
  8. package/lib/ChunkGroup.js +14 -6
  9. package/lib/CommentCompilationWarning.js +22 -0
  10. package/lib/Compilation.js +72 -29
  11. package/lib/Compiler.js +22 -10
  12. package/lib/ConstPlugin.js +25 -9
  13. package/lib/ContextModule.js +88 -36
  14. package/lib/ContextModuleFactory.js +18 -7
  15. package/lib/ContextReplacementPlugin.js +14 -7
  16. package/lib/DefinePlugin.js +15 -6
  17. package/lib/DependenciesBlock.js +3 -1
  18. package/lib/DependenciesBlockVariable.js +2 -1
  19. package/lib/DllPlugin.js +4 -2
  20. package/lib/DynamicEntryPlugin.js +4 -2
  21. package/lib/EntryModuleNotFoundError.js +21 -22
  22. package/lib/ErrorHelpers.js +5 -2
  23. package/lib/EvalSourceMapDevToolPlugin.js +2 -1
  24. package/lib/FlagDependencyUsagePlugin.js +11 -5
  25. package/lib/FunctionModuleTemplatePlugin.js +8 -6
  26. package/lib/HarmonyLinkingError.js +1 -2
  27. package/lib/HotModuleReplacement.runtime.js +13 -4
  28. package/lib/HotModuleReplacementPlugin.js +13 -6
  29. package/lib/JavascriptGenerator.js +2 -1
  30. package/lib/JavascriptModulesPlugin.js +4 -9
  31. package/lib/JsonParser.js +2 -1
  32. package/lib/LibraryTemplatePlugin.js +2 -1
  33. package/lib/LoaderOptionsPlugin.js +2 -1
  34. package/lib/MainTemplate.js +2 -1
  35. package/lib/Module.js +13 -5
  36. package/lib/ModuleBuildError.js +22 -12
  37. package/lib/ModuleDependencyError.js +4 -4
  38. package/lib/ModuleDependencyWarning.js +4 -4
  39. package/lib/ModuleError.js +13 -5
  40. package/lib/ModuleFilenameHelpers.js +20 -8
  41. package/lib/ModuleNotFoundError.js +23 -26
  42. package/lib/ModuleParseError.js +27 -14
  43. package/lib/ModuleWarning.js +13 -7
  44. package/lib/MultiCompiler.js +19 -7
  45. package/lib/MultiModule.js +5 -2
  46. package/lib/NodeStuffPlugin.js +2 -1
  47. package/lib/NormalModule.js +80 -16
  48. package/lib/NormalModuleFactory.js +67 -24
  49. package/lib/OptionsDefaulter.js +7 -3
  50. package/lib/Parser.js +182 -75
  51. package/lib/ParserHelpers.js +6 -3
  52. package/lib/ProgressPlugin.js +17 -2
  53. package/lib/RawModule.js +4 -2
  54. package/lib/RecordIdsPlugin.js +77 -9
  55. package/lib/RemovedPluginError.js +1 -3
  56. package/lib/RequestShortener.js +15 -6
  57. package/lib/RuleSet.js +51 -18
  58. package/lib/RuntimeTemplate.js +21 -10
  59. package/lib/SourceMapDevToolPlugin.js +4 -3
  60. package/lib/Stats.js +74 -31
  61. package/lib/Template.js +7 -4
  62. package/lib/TemplatedPathPlugin.js +6 -3
  63. package/lib/UmdMainTemplatePlugin.js +8 -3
  64. package/lib/UnsupportedFeatureWarning.js +22 -21
  65. package/lib/WarnCaseSensitiveModulesPlugin.js +2 -1
  66. package/lib/Watching.js +3 -2
  67. package/lib/WebpackOptionsApply.js +51 -23
  68. package/lib/WebpackOptionsDefaulter.js +15 -9
  69. package/lib/WebpackOptionsValidationError.js +63 -34
  70. package/lib/debug/ProfilingPlugin.js +11 -2
  71. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +17 -8
  72. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -4
  73. package/lib/dependencies/HarmonyDetectionParserPlugin.js +4 -2
  74. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -3
  75. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +6 -3
  76. package/lib/dependencies/ImportParserPlugin.js +42 -11
  77. package/lib/dependencies/LoaderPlugin.js +12 -7
  78. package/lib/dependencies/LocalModulesHelpers.js +13 -6
  79. package/lib/dependencies/RequireContextPlugin.js +4 -2
  80. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +8 -4
  81. package/lib/dependencies/SystemPlugin.js +6 -6
  82. package/lib/dependencies/WebAssemblyExportImportedDependency.js +29 -0
  83. package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
  84. package/lib/formatLocation.js +15 -7
  85. package/lib/node/NodeMainTemplateAsync.runtime.js +1 -1
  86. package/lib/node/NodeMainTemplatePlugin.js +6 -3
  87. package/lib/node/NodeSourcePlugin.js +9 -5
  88. package/lib/node/NodeWatchFileSystem.js +29 -12
  89. package/lib/node/ReadFileCompileWasmTemplatePlugin.js +11 -2
  90. package/lib/optimize/AggressiveSplittingPlugin.js +12 -6
  91. package/lib/optimize/ConcatenatedModule.js +19 -8
  92. package/lib/optimize/MergeDuplicateChunksPlugin.js +6 -3
  93. package/lib/optimize/ModuleConcatenationPlugin.js +23 -10
  94. package/lib/optimize/OccurrenceOrderPlugin.js +11 -4
  95. package/lib/optimize/RemoveParentModulesPlugin.js +17 -7
  96. package/lib/optimize/SideEffectsFlagPlugin.js +14 -3
  97. package/lib/optimize/SplitChunksPlugin.js +33 -20
  98. package/lib/performance/AssetsOverSizeLimitWarning.js +7 -7
  99. package/lib/performance/EntrypointsOverSizeLimitWarning.js +6 -7
  100. package/lib/performance/NoAsyncChunksWarning.js +5 -5
  101. package/lib/util/SortableSet.js +5 -2
  102. package/lib/util/StackedSetMap.js +12 -5
  103. package/lib/wasm/UnsupportedWebAssemblyFeatureError.js +1 -2
  104. package/lib/wasm/WasmFinalizeExportsPlugin.js +66 -0
  105. package/lib/wasm/WasmMainTemplatePlugin.js +87 -43
  106. package/lib/wasm/WebAssemblyGenerator.js +117 -74
  107. package/lib/wasm/WebAssemblyJavascriptGenerator.js +92 -49
  108. package/lib/wasm/WebAssemblyModulesPlugin.js +11 -1
  109. package/lib/wasm/WebAssemblyParser.js +96 -24
  110. package/lib/wasm/WebAssemblyUtils.js +17 -6
  111. package/lib/web/FetchCompileWasmTemplatePlugin.js +13 -1
  112. package/lib/web/JsonpChunkTemplatePlugin.js +7 -0
  113. package/lib/web/JsonpMainTemplate.runtime.js +2 -1
  114. package/lib/web/JsonpMainTemplatePlugin.js +68 -63
  115. package/lib/webpack.js +2 -1
  116. package/lib/webworker/WebWorkerMainTemplate.runtime.js +2 -1
  117. package/package.json +12 -11
  118. package/schemas/WebpackOptions.json +8 -0
@@ -6,16 +6,53 @@
6
6
 
7
7
  const identifierUtils = require("./util/identifier");
8
8
 
9
+ /** @typedef {import("./Compiler")} Compiler */
10
+ /** @typedef {import("./Chunk")} Chunk */
11
+ /** @typedef {import("./Module")} Module */
12
+
13
+ /**
14
+ * @typedef {Object} RecordsChunks
15
+ * @property {Record<string, number>=} byName
16
+ * @property {Record<string, number>=} bySource
17
+ * @property {number[]=} usedIds
18
+ */
19
+
20
+ /**
21
+ * @typedef {Object} RecordsModules
22
+ * @property {Record<string, number>=} byIdentifier
23
+ * @property {Record<string, number>=} bySource
24
+ * @property {Record<number, number>=} usedIds
25
+ */
26
+
27
+ /**
28
+ * @typedef {Object} Records
29
+ * @property {RecordsChunks=} chunks
30
+ * @property {RecordsModules=} modules
31
+ */
32
+
9
33
  class RecordIdsPlugin {
34
+ /**
35
+ * @param {Object} options Options object
36
+ * @param {boolean=} options.portableIds true, when ids need to be portable
37
+ */
10
38
  constructor(options) {
11
39
  this.options = options || {};
12
40
  }
13
41
 
42
+ /**
43
+ * @param {Compiler} compiler the Compiler
44
+ * @returns {void}
45
+ */
14
46
  apply(compiler) {
15
47
  const portableIds = this.options.portableIds;
16
48
  compiler.hooks.compilation.tap("RecordIdsPlugin", compilation => {
17
49
  compilation.hooks.recordModules.tap(
18
50
  "RecordIdsPlugin",
51
+ /**
52
+ * @param {Module[]} modules the modules array
53
+ * @param {Records} records the records object
54
+ * @returns {void}
55
+ */
19
56
  (modules, records) => {
20
57
  if (!records.modules) records.modules = {};
21
58
  if (!records.modules.byIdentifier) records.modules.byIdentifier = {};
@@ -36,9 +73,15 @@ class RecordIdsPlugin {
36
73
  );
37
74
  compilation.hooks.reviveModules.tap(
38
75
  "RecordIdsPlugin",
76
+ /**
77
+ * @param {Module[]} modules the modules array
78
+ * @param {Records} records the records object
79
+ * @returns {void}
80
+ */
39
81
  (modules, records) => {
40
82
  if (!records.modules) return;
41
83
  if (records.modules.byIdentifier) {
84
+ /** @type {Set<number>} */
42
85
  const usedIds = new Set();
43
86
  for (const module of modules) {
44
87
  if (module.id !== null) continue;
@@ -56,47 +99,59 @@ class RecordIdsPlugin {
56
99
  module.id = id;
57
100
  }
58
101
  }
59
- if (Array.isArray(records.modules.usedIds))
102
+ if (Array.isArray(records.modules.usedIds)) {
60
103
  compilation.usedModuleIds = new Set(records.modules.usedIds);
104
+ }
61
105
  }
62
106
  );
63
107
 
108
+ /**
109
+ * @param {Module} module the module
110
+ * @returns {string} the (portable) identifier
111
+ */
64
112
  const getModuleIdentifier = module => {
65
- if (portableIds)
113
+ if (portableIds) {
66
114
  return identifierUtils.makePathsRelative(
67
115
  compiler.context,
68
116
  module.identifier(),
69
117
  compilation.cache
70
118
  );
119
+ }
71
120
  return module.identifier();
72
121
  };
73
122
 
123
+ /**
124
+ * @param {Chunk} chunk the chunk
125
+ * @returns {string[]} sources of the chunk
126
+ */
74
127
  const getChunkSources = chunk => {
128
+ /** @type {string[]} */
75
129
  const sources = [];
76
130
  for (const chunkGroup of chunk.groupsIterable) {
77
131
  const index = chunkGroup.chunks.indexOf(chunk);
78
132
  for (const origin of chunkGroup.origins) {
79
133
  if (origin.module) {
80
- if (origin.request)
134
+ if (origin.request) {
81
135
  sources.push(
82
136
  `${index} ${getModuleIdentifier(origin.module)} ${
83
137
  origin.request
84
138
  }`
85
139
  );
86
- else if (typeof origin.loc === "string")
140
+ } else if (typeof origin.loc === "string") {
87
141
  sources.push(
88
142
  `${index} ${getModuleIdentifier(origin.module)} ${origin.loc}`
89
143
  );
90
- else if (
144
+ } else if (
91
145
  origin.loc &&
92
146
  typeof origin.loc === "object" &&
93
147
  origin.loc.start
94
- )
148
+ ) {
95
149
  sources.push(
96
150
  `${index} ${getModuleIdentifier(
97
151
  origin.module
98
152
  )} ${JSON.stringify(origin.loc.start)}`
99
153
  );
154
+ }
100
155
  }
101
156
  }
102
157
  }
@@ -105,10 +160,16 @@ class RecordIdsPlugin {
105
160
 
106
161
  compilation.hooks.recordChunks.tap(
107
162
  "RecordIdsPlugin",
163
+ /**
164
+ * @param {Chunk[]} chunks the chunks array
165
+ * @param {Records} records the records object
166
+ * @returns {void}
167
+ */
108
168
  (chunks, records) => {
109
169
  if (!records.chunks) records.chunks = {};
110
170
  if (!records.chunks.byName) records.chunks.byName = {};
111
171
  if (!records.chunks.bySource) records.chunks.bySource = {};
172
+ /** @type {Set<number>} */
112
173
  const usedIds = new Set();
113
174
  for (const chunk of chunks) {
114
175
  if (typeof chunk.id !== "number") continue;
@@ -125,8 +186,14 @@ class RecordIdsPlugin {
125
186
  );
126
187
  compilation.hooks.reviveChunks.tap(
127
188
  "RecordIdsPlugin",
189
+ /**
190
+ * @param {Chunk[]} chunks the chunks array
191
+ * @param {Records} records the records object
192
+ * @returns {void}
193
+ */
128
194
  (chunks, records) => {
129
195
  if (!records.chunks) return;
196
+ /** @type {Set<number>} */
130
197
  const usedIds = new Set();
131
198
  if (records.chunks.byName) {
132
199
  for (const chunk of chunks) {
@@ -145,15 +212,16 @@ class RecordIdsPlugin {
145
212
  for (const source of sources) {
146
213
  const id = records.chunks.bySource[source];
147
214
  if (id === undefined) continue;
148
- if (usedIds[id]) continue;
149
- usedIds[id] = true;
215
+ if (usedIds.has(id)) continue;
216
+ usedIds.add(id);
150
217
  chunk.id = id;
151
218
  break;
152
219
  }
153
220
  }
154
221
  }
155
- if (Array.isArray(records.chunks.usedIds))
222
+ if (Array.isArray(records.chunks.usedIds)) {
156
223
  compilation.usedChunkIds = new Set(records.chunks.usedIds);
224
+ }
157
225
  }
158
226
  );
159
227
  });
@@ -4,9 +4,7 @@ const WebpackError = require("./WebpackError");
4
4
 
5
5
  module.exports = class RemovedPluginError extends WebpackError {
6
6
  constructor(message) {
7
- super();
8
-
9
- this.message = message;
7
+ super(message);
10
8
 
11
9
  Error.captureStackTrace(this, this.constructor);
12
10
  }
@@ -10,6 +10,7 @@ const PATH_CHARS_REGEXP = /[-[\]{}()*+?.,\\^$|#\s]/g;
10
10
  const SEPARATOR_REGEXP = /[/\\]$/;
11
11
  const FRONT_OR_BACK_BANG_REGEXP = /^!|!$/g;
12
12
  const INDEX_JS_REGEXP = /\/index.js(!|\?|\(query\))/g;
13
+ const MATCH_RESOURCE_REGEXP = /!=!/;
13
14
 
14
15
  const normalizeBackSlashDirection = request => {
15
16
  return request.replace(NORMALIZE_SLASH_DIRECTION_REGEXP, "/");
@@ -23,8 +24,9 @@ const createRegExpForPath = path => {
23
24
  class RequestShortener {
24
25
  constructor(directory) {
25
26
  directory = normalizeBackSlashDirection(directory);
26
- if (SEPARATOR_REGEXP.test(directory))
27
+ if (SEPARATOR_REGEXP.test(directory)) {
27
28
  directory = directory.substr(0, directory.length - 1);
29
+ }
28
30
 
29
31
  if (directory) {
30
32
  this.currentDirectoryRegExp = createRegExpForPath(directory);
@@ -54,18 +56,25 @@ class RequestShortener {
54
56
  shorten(request) {
55
57
  if (!request) return request;
56
58
  const cacheEntry = this.cache.get(request);
57
- if (cacheEntry !== undefined) return cacheEntry;
59
+ if (cacheEntry !== undefined) {
60
+ return cacheEntry;
61
+ }
58
62
  let result = normalizeBackSlashDirection(request);
59
- if (this.buildinsAsModule && this.buildinsRegExp)
63
+ if (this.buildinsAsModule && this.buildinsRegExp) {
60
64
  result = result.replace(this.buildinsRegExp, "!(webpack)");
61
- if (this.currentDirectoryRegExp)
65
+ }
66
+ if (this.currentDirectoryRegExp) {
62
67
  result = result.replace(this.currentDirectoryRegExp, "!.");
63
- if (this.parentDirectoryRegExp)
68
+ }
69
+ if (this.parentDirectoryRegExp) {
64
70
  result = result.replace(this.parentDirectoryRegExp, "!..");
65
- if (!this.buildinsAsModule && this.buildinsRegExp)
71
+ }
72
+ if (!this.buildinsAsModule && this.buildinsRegExp) {
66
73
  result = result.replace(this.buildinsRegExp, "!(webpack)");
74
+ }
67
75
  result = result.replace(INDEX_JS_REGEXP, "$1");
68
76
  result = result.replace(FRONT_OR_BACK_BANG_REGEXP, "");
77
+ result = result.replace(MATCH_RESOURCE_REGEXP, " = ");
69
78
  this.cache.set(request, result);
70
79
  return result;
71
80
  }
package/lib/RuleSet.js CHANGED
@@ -117,7 +117,7 @@ module.exports = class RuleSet {
117
117
  }
118
118
 
119
119
  static normalizeRule(rule, refs, ident) {
120
- if (typeof rule === "string")
120
+ if (typeof rule === "string") {
121
121
  return {
122
122
  use: [
123
123
  {
@@ -125,9 +125,11 @@ module.exports = class RuleSet {
125
125
  }
126
126
  ]
127
127
  };
128
- if (!rule)
128
+ }
129
+ if (!rule) {
129
130
  throw new Error("Unexcepted null when object was expected as rule");
130
- if (typeof rule !== "object")
131
+ }
132
+ if (typeof rule !== "object") {
131
133
  throw new Error(
132
134
  "Unexcepted " +
133
135
  typeof rule +
@@ -135,6 +137,7 @@ module.exports = class RuleSet {
135
137
  rule +
136
138
  ")"
137
139
  );
140
+ }
138
141
 
139
142
  const newRule = {};
140
143
  let useSource;
@@ -142,7 +145,7 @@ module.exports = class RuleSet {
142
145
  let condition;
143
146
 
144
147
  const checkUseSource = newSource => {
145
- if (useSource && useSource !== newSource)
148
+ if (useSource && useSource !== newSource) {
146
149
  throw new Error(
147
150
  RuleSet.buildErrorMessage(
148
151
  rule,
@@ -155,11 +158,12 @@ module.exports = class RuleSet {
155
158
  )
156
159
  )
157
160
  );
161
+ }
158
162
  useSource = newSource;
159
163
  };
160
164
 
161
165
  const checkResourceSource = newSource => {
162
- if (resourceSource && resourceSource !== newSource)
166
+ if (resourceSource && resourceSource !== newSource) {
163
167
  throw new Error(
164
168
  RuleSet.buildErrorMessage(
165
169
  rule,
@@ -172,6 +176,7 @@ module.exports = class RuleSet {
172
176
  )
173
177
  )
174
178
  );
179
+ }
175
180
  resourceSource = newSource;
176
181
  };
177
182
 
@@ -198,6 +203,14 @@ module.exports = class RuleSet {
198
203
  }
199
204
  }
200
205
 
206
+ if (rule.realResource) {
207
+ try {
208
+ newRule.realResource = RuleSet.normalizeCondition(rule.realResource);
209
+ } catch (error) {
210
+ throw new Error(RuleSet.buildErrorMessage(rule.realResource, error));
211
+ }
212
+ }
213
+
201
214
  if (rule.resourceQuery) {
202
215
  try {
203
216
  newRule.resourceQuery = RuleSet.normalizeCondition(rule.resourceQuery);
@@ -222,7 +235,7 @@ module.exports = class RuleSet {
222
235
  }
223
236
  }
224
237
 
225
- if (rule.loader && rule.loaders)
238
+ if (rule.loader && rule.loaders) {
226
239
  throw new Error(
227
240
  RuleSet.buildErrorMessage(
228
241
  rule,
@@ -231,6 +244,7 @@ module.exports = class RuleSet {
231
244
  )
232
245
  )
233
246
  );
247
+ }
234
248
 
235
249
  const loader = rule.loaders || rule.loader;
236
250
  if (typeof loader === "string" && !rule.options && !rule.query) {
@@ -274,19 +288,21 @@ module.exports = class RuleSet {
274
288
  newRule.use = RuleSet.normalizeUse(rule.use, ident);
275
289
  }
276
290
 
277
- if (rule.rules)
291
+ if (rule.rules) {
278
292
  newRule.rules = RuleSet.normalizeRules(
279
293
  rule.rules,
280
294
  refs,
281
295
  `${ident}-rules`
282
296
  );
297
+ }
283
298
 
284
- if (rule.oneOf)
299
+ if (rule.oneOf) {
285
300
  newRule.oneOf = RuleSet.normalizeRules(
286
301
  rule.oneOf,
287
302
  refs,
288
303
  `${ident}-oneOf`
289
304
  );
305
+ }
290
306
 
291
307
  const keys = Object.keys(rule).filter(key => {
292
308
  return ![
@@ -365,16 +381,22 @@ module.exports = class RuleSet {
365
381
 
366
382
  const newItem = {};
367
383
 
368
- if (item.options && item.query)
384
+ if (item.options && item.query) {
369
385
  throw new Error("Provided options and query in use");
386
+ }
370
387
 
371
- if (!item.loader) throw new Error("No loader specified");
388
+ if (!item.loader) {
389
+ throw new Error("No loader specified");
390
+ }
372
391
 
373
392
  newItem.options = item.options || item.query;
374
393
 
375
394
  if (typeof newItem.options === "object" && newItem.options) {
376
- if (newItem.options.ident) newItem.ident = newItem.options.ident;
377
- else newItem.ident = ident;
395
+ if (newItem.options.ident) {
396
+ newItem.ident = newItem.options.ident;
397
+ } else {
398
+ newItem.ident = ident;
399
+ }
378
400
  }
379
401
 
380
402
  const keys = Object.keys(item).filter(function(key) {
@@ -403,7 +425,7 @@ module.exports = class RuleSet {
403
425
  const items = condition.map(c => RuleSet.normalizeCondition(c));
404
426
  return orMatcher(items);
405
427
  }
406
- if (typeof condition !== "object")
428
+ if (typeof condition !== "object") {
407
429
  throw Error(
408
430
  "Unexcepted " +
409
431
  typeof condition +
@@ -411,6 +433,7 @@ module.exports = class RuleSet {
411
433
  condition +
412
434
  ")"
413
435
  );
436
+ }
414
437
 
415
438
  const matchers = [];
416
439
  Object.keys(condition).forEach(key => {
@@ -438,9 +461,12 @@ module.exports = class RuleSet {
438
461
  throw new Error("Unexcepted property " + key + " in condition");
439
462
  }
440
463
  });
441
- if (matchers.length === 0)
464
+ if (matchers.length === 0) {
442
465
  throw new Error("Excepted condition but got " + condition);
443
- if (matchers.length === 1) return matchers[0];
466
+ }
467
+ if (matchers.length === 1) {
468
+ return matchers[0];
469
+ }
444
470
  return andMatcher(matchers);
445
471
  }
446
472
 
@@ -459,24 +485,30 @@ module.exports = class RuleSet {
459
485
  _run(data, rule, result) {
460
486
  // test conditions
461
487
  if (rule.resource && !data.resource) return false;
488
+ if (rule.realResource && !data.realResource) return false;
462
489
  if (rule.resourceQuery && !data.resourceQuery) return false;
463
490
  if (rule.compiler && !data.compiler) return false;
464
491
  if (rule.issuer && !data.issuer) return false;
465
492
  if (rule.resource && !rule.resource(data.resource)) return false;
493
+ if (rule.realResource && !rule.realResource(data.realResource))
494
+ return false;
466
495
  if (data.issuer && rule.issuer && !rule.issuer(data.issuer)) return false;
467
496
  if (
468
497
  data.resourceQuery &&
469
498
  rule.resourceQuery &&
470
499
  !rule.resourceQuery(data.resourceQuery)
471
- )
500
+ ) {
472
501
  return false;
473
- if (data.compiler && rule.compiler && !rule.compiler(data.compiler))
502
+ }
503
+ if (data.compiler && rule.compiler && !rule.compiler(data.compiler)) {
474
504
  return false;
505
+ }
475
506
 
476
507
  // apply
477
508
  const keys = Object.keys(rule).filter(key => {
478
509
  return ![
479
510
  "resource",
511
+ "realResource",
480
512
  "resourceQuery",
481
513
  "compiler",
482
514
  "issuer",
@@ -527,8 +559,9 @@ module.exports = class RuleSet {
527
559
 
528
560
  findOptionsByIdent(ident) {
529
561
  const options = this.references[ident];
530
- if (!options)
562
+ if (!options) {
531
563
  throw new Error("Can't find options with ident '" + ident + "'");
564
+ }
532
565
  return options;
533
566
  }
534
567
  };
@@ -79,10 +79,11 @@ module.exports = class RuntimeTemplate {
79
79
  }
80
80
 
81
81
  moduleRaw({ module, request }) {
82
- if (!module)
82
+ if (!module) {
83
83
  return this.missingModule({
84
84
  request
85
85
  });
86
+ }
86
87
  return `__webpack_require__(${this.moduleId({ module, request })})`;
87
88
  }
88
89
 
@@ -94,10 +95,11 @@ module.exports = class RuntimeTemplate {
94
95
  }
95
96
 
96
97
  moduleNamespace({ module, request, strict }) {
97
- if (!module)
98
+ if (!module) {
98
99
  return this.missingModule({
99
100
  request
100
101
  });
102
+ }
101
103
  const moduleId = this.moduleId({
102
104
  module,
103
105
  request
@@ -205,10 +207,11 @@ module.exports = class RuntimeTemplate {
205
207
  content += `/* harmony import */ ${optDeclaration}${importVar}_default = /*#__PURE__*/__webpack_require__.n(${importVar});\n`;
206
208
  }
207
209
  if (exportsType === "named") {
208
- if (Array.isArray(module.buildMeta.providedExports))
210
+ if (Array.isArray(module.buildMeta.providedExports)) {
209
211
  content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/__webpack_require__.t(${moduleId}, 1);\n`;
210
- else
212
+ } else {
211
213
  content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/__webpack_require__.t(${moduleId});\n`;
214
+ }
212
215
  }
213
216
  return content;
214
217
  }
@@ -223,18 +226,23 @@ module.exports = class RuntimeTemplate {
223
226
  callContext,
224
227
  importVar
225
228
  }) {
226
- if (!module)
229
+ if (!module) {
227
230
  return this.missingModule({
228
231
  request
229
232
  });
233
+ }
230
234
  const exportsType = module.buildMeta && module.buildMeta.exportsType;
231
235
 
232
236
  if (!exportsType) {
233
237
  if (exportName === "default") {
234
238
  if (!originModule.buildMeta.strictHarmonyModule) {
235
- if (isCall) return `${importVar}_default()`;
236
- else if (asiSafe) return `(${importVar}_default())`;
237
- else return `${importVar}_default.a`;
239
+ if (isCall) {
240
+ return `${importVar}_default()`;
241
+ } else if (asiSafe) {
242
+ return `(${importVar}_default())`;
243
+ } else {
244
+ return `${importVar}_default.a`;
245
+ }
238
246
  } else {
239
247
  return importVar;
240
248
  }
@@ -261,8 +269,11 @@ module.exports = class RuntimeTemplate {
261
269
  used !== exportName ? Template.toNormalComment(exportName) + " " : "";
262
270
  const access = `${importVar}[${comment}${JSON.stringify(used)}]`;
263
271
  if (isCall) {
264
- if (callContext === false && asiSafe) return `(0,${access})`;
265
- else if (callContext === false) return `Object(${access})`;
272
+ if (callContext === false && asiSafe) {
273
+ return `(0,${access})`;
274
+ } else if (callContext === false) {
275
+ return `Object(${access})`;
276
+ }
266
277
  }
267
278
  return access;
268
279
  } else {
@@ -53,10 +53,11 @@ const getTaskForFile = (file, chunk, options, compilation) => {
53
53
 
54
54
  class SourceMapDevToolPlugin {
55
55
  constructor(options) {
56
- if (arguments.length > 1)
56
+ if (arguments.length > 1) {
57
57
  throw new Error(
58
58
  "SourceMapDevToolPlugin only takes one argument (pass an options object)"
59
59
  );
60
+ }
60
61
 
61
62
  validateOptions(schema, options || {}, "SourceMap DevTool Plugin");
62
63
 
@@ -121,7 +122,7 @@ class SourceMapDevToolPlugin {
121
122
  const tasks = [];
122
123
  files.forEach(({ file, chunk }, idx) => {
123
124
  reportProgress(
124
- 0.5 * idx / files.length,
125
+ (0.5 * idx) / files.length,
125
126
  file,
126
127
  "generate SourceMap"
127
128
  );
@@ -205,7 +206,7 @@ class SourceMapDevToolPlugin {
205
206
  }
206
207
  tasks.forEach((task, index) => {
207
208
  reportProgress(
208
- 0.5 + 0.5 * index / tasks.length,
209
+ 0.5 + (0.5 * index) / tasks.length,
209
210
  task.file,
210
211
  "attach SourceMap"
211
212
  );