webpack 4.29.2 → 4.29.6

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/lib/APIPlugin.js CHANGED
@@ -58,12 +58,12 @@ class APIPlugin {
58
58
  REPLACEMENTS[key]
59
59
  )
60
60
  );
61
- parser.hooks.evaluateTypeof
62
- .for(key)
63
- .tap(
64
- "APIPlugin",
65
- ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key])
66
- );
61
+ const type = REPLACEMENT_TYPES[key];
62
+ if (type) {
63
+ parser.hooks.evaluateTypeof
64
+ .for(key)
65
+ .tap("APIPlugin", ParserHelpers.evaluateToString(type));
66
+ }
67
67
  });
68
68
  };
69
69
 
@@ -380,13 +380,12 @@ function webpackContext(req) {
380
380
  ${returnModuleObject}
381
381
  }
382
382
  function webpackContextResolve(req) {
383
- var id = map[req];
384
- if(!(id + 1)) { // check for number or string
383
+ if(!__webpack_require__.o(map, req)) {
385
384
  var e = new Error("Cannot find module '" + req + "'");
386
385
  e.code = 'MODULE_NOT_FOUND';
387
386
  throw e;
388
387
  }
389
- return id;
388
+ return map[req];
390
389
  }
391
390
  webpackContext.keys = function webpackContextKeys() {
392
391
  return Object.keys(map);
@@ -414,13 +413,12 @@ function webpackContext(req) {
414
413
  ${returnModuleObject}
415
414
  }
416
415
  function webpackContextResolve(req) {
417
- var id = map[req];
418
- if(!(id + 1)) { // check for number or string
416
+ if(!__webpack_require__.o(map, req)) {
419
417
  var e = new Error("Cannot find module '" + req + "'");
420
418
  e.code = 'MODULE_NOT_FOUND';
421
419
  throw e;
422
420
  }
423
- return id;
421
+ return map[req];
424
422
  }
425
423
  webpackContext.keys = function webpackContextKeys() {
426
424
  return Object.keys(map);
@@ -452,13 +450,12 @@ function webpackAsyncContextResolve(req) {
452
450
  // Here Promise.resolve().then() is used instead of new Promise() to prevent
453
451
  // uncaught exception popping up in devtools
454
452
  return Promise.resolve().then(function() {
455
- var id = map[req];
456
- if(!(id + 1)) { // check for number or string
453
+ if(!__webpack_require__.o(map, req)) {
457
454
  var e = new Error("Cannot find module '" + req + "'");
458
455
  e.code = 'MODULE_NOT_FOUND';
459
456
  throw e;
460
457
  }
461
- return id;
458
+ return map[req];
462
459
  });
463
460
  }
464
461
  webpackAsyncContext.keys = function webpackAsyncContextKeys() {
@@ -488,13 +485,12 @@ function webpackAsyncContextResolve(req) {
488
485
  // Here Promise.resolve().then() is used instead of new Promise() to prevent
489
486
  // uncaught exception popping up in devtools
490
487
  return Promise.resolve().then(function() {
491
- var id = map[req];
492
- if(!(id + 1)) { // check for number or string
488
+ if(!__webpack_require__.o(map, req)) {
493
489
  var e = new Error("Cannot find module '" + req + "'");
494
490
  e.code = 'MODULE_NOT_FOUND';
495
491
  throw e;
496
492
  }
497
- return id;
493
+ return map[req];
498
494
  });
499
495
  }
500
496
  webpackAsyncContext.keys = function webpackAsyncContextKeys() {
@@ -527,13 +523,12 @@ function webpackAsyncContext(req) {
527
523
  }
528
524
  function webpackAsyncContextResolve(req) {
529
525
  return ${promise}.then(function() {
530
- var id = map[req];
531
- if(!(id + 1)) { // check for number or string
526
+ if(!__webpack_require__.o(map, req)) {
532
527
  var e = new Error("Cannot find module '" + req + "'");
533
528
  e.code = 'MODULE_NOT_FOUND';
534
529
  throw e;
535
530
  }
536
- return id;
531
+ return map[req];
537
532
  });
538
533
  }
539
534
  webpackAsyncContext.keys = function webpackAsyncContextKeys() {
@@ -546,59 +541,92 @@ module.exports = webpackAsyncContext;`;
546
541
 
547
542
  getLazySource(blocks, id) {
548
543
  let hasMultipleOrNoChunks = false;
544
+ let hasNoChunk = true;
549
545
  const fakeMap = this.getFakeMap(blocks.map(b => b.dependencies[0]));
546
+ const hasFakeMap = typeof fakeMap === "object";
550
547
  const map = blocks
551
548
  .filter(block => block.dependencies[0].module)
552
- .map(block => ({
553
- dependency: block.dependencies[0],
554
- block: block,
555
- userRequest: block.dependencies[0].userRequest
556
- }))
549
+ .map(block => {
550
+ const chunks = block.chunkGroup ? block.chunkGroup.chunks : [];
551
+ if (chunks.length > 0) {
552
+ hasNoChunk = false;
553
+ }
554
+ if (chunks.length !== 1) {
555
+ hasMultipleOrNoChunks = true;
556
+ }
557
+ return {
558
+ dependency: block.dependencies[0],
559
+ block: block,
560
+ userRequest: block.dependencies[0].userRequest,
561
+ chunks
562
+ };
563
+ })
557
564
  .sort((a, b) => {
558
565
  if (a.userRequest === b.userRequest) return 0;
559
566
  return a.userRequest < b.userRequest ? -1 : 1;
560
567
  })
561
568
  .reduce((map, item) => {
562
- const chunks =
563
- (item.block.chunkGroup && item.block.chunkGroup.chunks) || [];
564
- if (chunks.length !== 1) {
565
- hasMultipleOrNoChunks = true;
566
- }
567
- const arrayStart = [item.dependency.module.id];
568
- if (typeof fakeMap === "object") {
569
- arrayStart.push(fakeMap[item.dependency.module.id]);
569
+ const chunks = item.chunks;
570
+
571
+ if (hasNoChunk && !hasFakeMap) {
572
+ map[item.userRequest] = item.dependency.module.id;
573
+ } else {
574
+ const arrayStart = [item.dependency.module.id];
575
+ if (typeof fakeMap === "object") {
576
+ arrayStart.push(fakeMap[item.dependency.module.id]);
577
+ }
578
+ map[item.userRequest] = arrayStart.concat(
579
+ chunks.map(chunk => chunk.id)
580
+ );
570
581
  }
571
- map[item.userRequest] = arrayStart.concat(
572
- chunks.map(chunk => chunk.id)
573
- );
574
582
 
575
583
  return map;
576
584
  }, Object.create(null));
577
585
 
578
- const chunksStartPosition = typeof fakeMap === "object" ? 2 : 1;
579
- const requestPrefix = hasMultipleOrNoChunks
586
+ const shortMode = hasNoChunk && !hasFakeMap;
587
+ const chunksStartPosition = hasFakeMap ? 2 : 1;
588
+ const requestPrefix = hasNoChunk
589
+ ? "Promise.resolve()"
590
+ : hasMultipleOrNoChunks
580
591
  ? `Promise.all(ids.slice(${chunksStartPosition}).map(__webpack_require__.e))`
581
592
  : `__webpack_require__.e(ids[${chunksStartPosition}])`;
582
593
  const returnModuleObject = this.getReturnModuleObjectSource(
583
594
  fakeMap,
584
- "ids[1]"
595
+ shortMode ? "invalid" : "ids[1]"
585
596
  );
586
597
 
587
- return `var map = ${JSON.stringify(map, null, "\t")};
598
+ const webpackAsyncContext =
599
+ requestPrefix === "Promise.resolve()"
600
+ ? `${shortMode ? "" : ""}
588
601
  function webpackAsyncContext(req) {
589
- var ids = map[req];
590
- if(!ids) {
602
+ return Promise.resolve().then(function() {
603
+ if(!__webpack_require__.o(map, req)) {
604
+ var e = new Error("Cannot find module '" + req + "'");
605
+ e.code = 'MODULE_NOT_FOUND';
606
+ throw e;
607
+ }
608
+
609
+ ${shortMode ? "var id = map[req];" : "var ids = map[req], id = ids[0];"}
610
+ ${returnModuleObject}
611
+ });
612
+ }`
613
+ : `function webpackAsyncContext(req) {
614
+ if(!__webpack_require__.o(map, req)) {
591
615
  return Promise.resolve().then(function() {
592
616
  var e = new Error("Cannot find module '" + req + "'");
593
617
  e.code = 'MODULE_NOT_FOUND';
594
618
  throw e;
595
619
  });
596
620
  }
621
+
622
+ var ids = map[req], id = ids[0];
597
623
  return ${requestPrefix}.then(function() {
598
- var id = ids[0];
599
624
  ${returnModuleObject}
600
625
  });
601
- }
626
+ }`;
627
+
628
+ return `var map = ${JSON.stringify(map, null, "\t")};
629
+ ${webpackAsyncContext}
602
630
  webpackAsyncContext.keys = function webpackAsyncContextKeys() {
603
631
  return Object.keys(map);
604
632
  };
@@ -4,6 +4,8 @@
4
4
  */
5
5
  "use strict";
6
6
 
7
+ const inspect = require("util").inspect.custom;
8
+
7
9
  class WebpackError extends Error {
8
10
  /**
9
11
  * Creates an instance of WebpackError.
@@ -21,7 +23,7 @@ class WebpackError extends Error {
21
23
  Error.captureStackTrace(this, this.constructor);
22
24
  }
23
25
 
24
- inspect() {
26
+ [inspect]() {
25
27
  return this.stack + (this.details ? `\n${this.details}` : "");
26
28
  }
27
29
  }
@@ -34,7 +34,10 @@ HarmonyAcceptDependency.Template = class HarmonyAcceptDependencyTemplate {
34
34
  dep.range[0],
35
35
  `function(__WEBPACK_OUTDATED_DEPENDENCIES__) { ${content}(`
36
36
  );
37
- source.insert(dep.range[1], ")(__WEBPACK_OUTDATED_DEPENDENCIES__); }");
37
+ source.insert(
38
+ dep.range[1],
39
+ ")(__WEBPACK_OUTDATED_DEPENDENCIES__); }.bind(this)"
40
+ );
38
41
  return;
39
42
  }
40
43
 
@@ -177,9 +177,12 @@ const rewriteImportedGlobals = state => bin => {
177
177
 
178
178
  globalType.mutability = "var";
179
179
 
180
- const init = createDefaultInitForGlobal(globalType);
180
+ const init = [
181
+ createDefaultInitForGlobal(globalType),
182
+ t.instruction("end")
183
+ ];
181
184
 
182
- newGlobals.push(t.global(globalType, [init]));
185
+ newGlobals.push(t.global(globalType, init));
183
186
 
184
187
  path.remove();
185
188
  }
@@ -196,7 +199,10 @@ const rewriteImportedGlobals = state => bin => {
196
199
 
197
200
  const initialGlobalidx = init.args[0];
198
201
 
199
- node.init = [createDefaultInitForGlobal(node.globalType)];
202
+ node.init = [
203
+ createDefaultInitForGlobal(node.globalType),
204
+ t.instruction("end")
205
+ ];
200
206
 
201
207
  additionalInitCode.push(
202
208
  /**
@@ -316,6 +322,8 @@ const addInitFunction = ({
316
322
  funcBody.push(instr);
317
323
  }
318
324
 
325
+ funcBody.push(t.instruction("end"));
326
+
319
327
  const funcResults = [];
320
328
 
321
329
  // Code section
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.29.2",
3
+ "version": "4.29.6",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@webassemblyjs/ast": "1.7.11",
9
- "@webassemblyjs/helper-module-context": "1.7.11",
10
- "@webassemblyjs/wasm-edit": "1.7.11",
11
- "@webassemblyjs/wasm-parser": "1.7.11",
8
+ "@webassemblyjs/ast": "1.8.5",
9
+ "@webassemblyjs/helper-module-context": "1.8.5",
10
+ "@webassemblyjs/wasm-edit": "1.8.5",
11
+ "@webassemblyjs/wasm-parser": "1.8.5",
12
12
  "acorn": "^6.0.5",
13
13
  "acorn-dynamic-import": "^4.0.0",
14
14
  "ajv": "^6.1.0",
@@ -34,6 +34,7 @@
34
34
  "@types/node": "^10.12.21",
35
35
  "@types/tapable": "^1.0.1",
36
36
  "@types/webpack-sources": "^0.1.4",
37
+ "@yarnpkg/lockfile": "^1.1.0",
37
38
  "benchmark": "^2.1.1",
38
39
  "bundle-loader": "~0.5.0",
39
40
  "coffee-loader": "^0.9.0",
@@ -119,14 +120,14 @@
119
120
  "build:examples": "cd examples && node buildAll.js",
120
121
  "pretest": "yarn lint",
121
122
  "prelint": "yarn setup",
122
- "lint": "yarn code-lint && yarn schema-lint && yarn type-lint && yarn special-lint",
123
+ "lint": "yarn code-lint && yarn jest-lint && yarn type-lint && yarn special-lint",
123
124
  "code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
124
125
  "type-lint": "tsc --pretty",
125
126
  "special-lint": "node tooling/inherit-types && node tooling/format-schemas && node tooling/compile-to-definitions",
126
127
  "special-lint-fix": "node tooling/inherit-types --write --override && node tooling/format-schemas --write && node tooling/compile-to-definitions --write",
127
128
  "fix": "yarn code-lint --fix && yarn special-lint-fix",
128
129
  "pretty": "prettier --loglevel warn --write \"*.{ts,js,json,yml,yaml}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
129
- "schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
130
+ "jest-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
130
131
  "benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
131
132
  "cover": "yarn cover:init && yarn cover:all && yarn cover:report",
132
133
  "cover:init": "rimraf coverage",