webpack 4.16.1 → 4.16.5
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/hot/log.js +2 -0
- package/lib/Chunk.js +32 -10
- package/lib/ChunkGroup.js +3 -3
- package/lib/Compilation.js +58 -13
- package/lib/ContextExclusionPlugin.js +11 -0
- package/lib/ContextModule.js +116 -30
- package/lib/ContextModuleFactory.js +6 -0
- package/lib/DelegatedModule.js +5 -0
- package/lib/DependenciesBlock.js +1 -1
- package/lib/DllModule.js +6 -0
- package/lib/DllReferencePlugin.js +51 -3
- package/lib/ExternalModule.js +6 -0
- package/lib/Generator.js +11 -3
- package/lib/HotModuleReplacementPlugin.js +1 -5
- package/lib/Module.js +52 -12
- package/lib/MultiModule.js +6 -0
- package/lib/NodeStuffPlugin.js +18 -0
- package/lib/NormalModule.js +6 -0
- package/lib/Parser.js +12 -3
- package/lib/RuntimeTemplate.js +12 -0
- package/lib/Stats.js +19 -2
- package/lib/Template.js +44 -43
- package/lib/WatchIgnorePlugin.js +18 -18
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +6 -0
- package/lib/dependencies/ContextDependencyHelpers.js +78 -43
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/node/NodeTargetPlugin.js +1 -0
- package/lib/optimize/ConcatenatedModule.js +5 -0
- package/lib/util/SortableSet.js +1 -0
- package/lib/util/StackedSetMap.js +12 -3
- package/lib/wasm/WebAssemblyGenerator.js +22 -5
- package/lib/wasm/WebAssemblyJavascriptGenerator.js +16 -2
- package/lib/webpack.js +1 -0
- package/package.json +8 -16
package/hot/log.js
CHANGED
@@ -30,9 +30,11 @@ module.exports = function(level, msg) {
|
|
30
30
|
}
|
31
31
|
};
|
32
32
|
|
33
|
+
/* eslint-disable node/no-unsupported-features/node-builtins */
|
33
34
|
var group = console.group || dummy;
|
34
35
|
var groupCollapsed = console.groupCollapsed || dummy;
|
35
36
|
var groupEnd = console.groupEnd || dummy;
|
37
|
+
/* eslint-enable node/no-unsupported-features/node-builtins */
|
36
38
|
|
37
39
|
module.exports.group = logGroup(group);
|
38
40
|
|
package/lib/Chunk.js
CHANGED
@@ -8,6 +8,7 @@ const util = require("util");
|
|
8
8
|
const SortableSet = require("./util/SortableSet");
|
9
9
|
const intersect = require("./util/SetHelpers").intersect;
|
10
10
|
const GraphHelpers = require("./GraphHelpers");
|
11
|
+
const Entrypoint = require("./Entrypoint");
|
11
12
|
let debugId = 1000;
|
12
13
|
const ERR_CHUNK_ENTRY = "Chunk.entry was removed. Use hasRuntime()";
|
13
14
|
const ERR_CHUNK_INITIAL =
|
@@ -123,9 +124,6 @@ class Chunk {
|
|
123
124
|
this._modules = new SortableSet(undefined, sortByIdentifier);
|
124
125
|
/** @type {string?} */
|
125
126
|
this.filenameTemplate = undefined;
|
126
|
-
|
127
|
-
/** @private */
|
128
|
-
this._groups = new SortableSet(undefined, sortChunkGroupById);
|
129
127
|
/** @private @type {SortableSet<ChunkGroup>} */
|
130
128
|
this._groups = new SortableSet(undefined, sortChunkGroupById);
|
131
129
|
/** @type {string[]} */
|
@@ -185,7 +183,11 @@ class Chunk {
|
|
185
183
|
hasRuntime() {
|
186
184
|
for (const chunkGroup of this._groups) {
|
187
185
|
// We only need to check the first one
|
188
|
-
return
|
186
|
+
return (
|
187
|
+
chunkGroup.isInitial() &&
|
188
|
+
chunkGroup instanceof Entrypoint &&
|
189
|
+
chunkGroup.getRuntimeChunk() === this
|
190
|
+
);
|
189
191
|
}
|
190
192
|
return false;
|
191
193
|
}
|
@@ -749,17 +751,37 @@ class Chunk {
|
|
749
751
|
// TODO remove in webpack 5
|
750
752
|
Object.defineProperty(Chunk.prototype, "forEachModule", {
|
751
753
|
configurable: false,
|
752
|
-
value: util.deprecate(
|
753
|
-
|
754
|
-
|
754
|
+
value: util.deprecate(
|
755
|
+
/**
|
756
|
+
* @deprecated
|
757
|
+
* @this {Chunk}
|
758
|
+
* @typedef {function(any, any, Set<any>): void} ForEachModuleCallback
|
759
|
+
* @param {ForEachModuleCallback} fn Callback function
|
760
|
+
* @returns {void}
|
761
|
+
*/
|
762
|
+
function(fn) {
|
763
|
+
this._modules.forEach(fn);
|
764
|
+
},
|
765
|
+
"Chunk.forEachModule: Use for(const module of chunk.modulesIterable) instead"
|
766
|
+
)
|
755
767
|
});
|
756
768
|
|
757
769
|
// TODO remove in webpack 5
|
758
770
|
Object.defineProperty(Chunk.prototype, "mapModules", {
|
759
771
|
configurable: false,
|
760
|
-
value: util.deprecate(
|
761
|
-
|
762
|
-
|
772
|
+
value: util.deprecate(
|
773
|
+
/**
|
774
|
+
* @deprecated
|
775
|
+
* @this {Chunk}
|
776
|
+
* @typedef {function(any, number): any} MapModulesCallback
|
777
|
+
* @param {MapModulesCallback} fn Callback function
|
778
|
+
* @returns {TODO[]} result of mapped modules
|
779
|
+
*/
|
780
|
+
function(fn) {
|
781
|
+
return Array.from(this._modules, fn);
|
782
|
+
},
|
783
|
+
"Chunk.mapModules: Use Array.from(chunk.modulesIterable, fn) instead"
|
784
|
+
)
|
763
785
|
});
|
764
786
|
|
765
787
|
// TODO remove in webpack 5
|
package/lib/ChunkGroup.js
CHANGED
@@ -11,7 +11,6 @@ const compareLocations = require("./compareLocations");
|
|
11
11
|
/** @typedef {import("./Module")} Module */
|
12
12
|
/** @typedef {import("./ModuleReason")} ModuleReason */
|
13
13
|
|
14
|
-
/** @typedef {{id: number}} HasId */
|
15
14
|
/** @typedef {{module: Module, loc: TODO, request: string}} OriginRecord */
|
16
15
|
/** @typedef {string|{name: string}} ChunkGroupOptions */
|
17
16
|
|
@@ -26,8 +25,8 @@ const getArray = set => Array.from(set);
|
|
26
25
|
|
27
26
|
/**
|
28
27
|
* A convenience method used to sort chunks based on their id's
|
29
|
-
* @param {
|
30
|
-
* @param {
|
28
|
+
* @param {ChunkGroup} a first sorting comparator
|
29
|
+
* @param {ChunkGroup} b second sorting comparator
|
31
30
|
* @returns {1|0|-1} a sorting index to determine order
|
32
31
|
*/
|
33
32
|
const sortById = (a, b) => {
|
@@ -63,6 +62,7 @@ class ChunkGroup {
|
|
63
62
|
/** @type {number} */
|
64
63
|
this.groupDebugId = debugId++;
|
65
64
|
this.options = options;
|
65
|
+
/** @type {SortableSet<ChunkGroup>} */
|
66
66
|
this._children = new SortableSet(undefined, sortById);
|
67
67
|
this._parents = new SortableSet(undefined, sortById);
|
68
68
|
this._blocks = new SortableSet();
|
package/lib/Compilation.js
CHANGED
@@ -1025,6 +1025,7 @@ class Compilation extends Tapable {
|
|
1025
1025
|
addEntry(context, entry, name, callback) {
|
1026
1026
|
const slot = {
|
1027
1027
|
name: name,
|
1028
|
+
// TODO webpack 5 remove `request`
|
1028
1029
|
request: null,
|
1029
1030
|
module: null
|
1030
1031
|
};
|
@@ -1033,7 +1034,14 @@ class Compilation extends Tapable {
|
|
1033
1034
|
slot.request = entry.request;
|
1034
1035
|
}
|
1035
1036
|
|
1036
|
-
|
1037
|
+
// TODO webpack 5: merge modules instead when multiple entry modules are supported
|
1038
|
+
const idx = this._preparedEntrypoints.findIndex(slot => slot.name === name);
|
1039
|
+
if (idx >= 0) {
|
1040
|
+
// Overwrite existing entrypoint
|
1041
|
+
this._preparedEntrypoints[idx] = slot;
|
1042
|
+
} else {
|
1043
|
+
this._preparedEntrypoints.push(slot);
|
1044
|
+
}
|
1037
1045
|
this._addModuleChain(
|
1038
1046
|
context,
|
1039
1047
|
entry,
|
@@ -1049,7 +1057,9 @@ class Compilation extends Tapable {
|
|
1049
1057
|
slot.module = module;
|
1050
1058
|
} else {
|
1051
1059
|
const idx = this._preparedEntrypoints.indexOf(slot);
|
1052
|
-
|
1060
|
+
if (idx >= 0) {
|
1061
|
+
this._preparedEntrypoints.splice(idx, 1);
|
1062
|
+
}
|
1053
1063
|
}
|
1054
1064
|
return callback(null, module);
|
1055
1065
|
}
|
@@ -1572,6 +1582,9 @@ class Compilation extends Tapable {
|
|
1572
1582
|
/** @type {Map<DependenciesBlock, ChunkGroup>} */
|
1573
1583
|
const blockChunkGroups = new Map();
|
1574
1584
|
|
1585
|
+
/** @type {Set<DependenciesBlock>} */
|
1586
|
+
const blocksWithNestedBlocks = new Set();
|
1587
|
+
|
1575
1588
|
const ADD_AND_ENTER_MODULE = 0;
|
1576
1589
|
const ENTER_MODULE = 1;
|
1577
1590
|
const PROCESS_BLOCK = 2;
|
@@ -1731,6 +1744,10 @@ class Compilation extends Tapable {
|
|
1731
1744
|
|
1732
1745
|
// Traverse all Blocks
|
1733
1746
|
iterationOfArrayCallback(blockInfo.blocks, iteratorBlock);
|
1747
|
+
|
1748
|
+
if (blockInfo.blocks.length > 0 && module !== block) {
|
1749
|
+
blocksWithNestedBlocks.add(block);
|
1750
|
+
}
|
1734
1751
|
break;
|
1735
1752
|
}
|
1736
1753
|
case LEAVE_MODULE: {
|
@@ -1792,6 +1809,7 @@ class Compilation extends Tapable {
|
|
1792
1809
|
*/
|
1793
1810
|
const filterFn = dep => {
|
1794
1811
|
const depChunkGroup = dep.chunkGroup;
|
1812
|
+
if (blocksWithNestedBlocks.has(dep.block)) return true;
|
1795
1813
|
if (areModulesAvailable(depChunkGroup, newAvailableModules)) return false; // break all modules are already available
|
1796
1814
|
return true;
|
1797
1815
|
};
|
@@ -2442,21 +2460,48 @@ class Compilation extends Tapable {
|
|
2442
2460
|
}
|
2443
2461
|
|
2444
2462
|
// TODO remove in webpack 5
|
2445
|
-
Compilation.prototype.applyPlugins = util.deprecate(
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2463
|
+
Compilation.prototype.applyPlugins = util.deprecate(
|
2464
|
+
/**
|
2465
|
+
* @deprecated
|
2466
|
+
* @param {string} name Name
|
2467
|
+
* @param {any[]} args Other arguments
|
2468
|
+
* @returns {void}
|
2469
|
+
* @this {Compilation}
|
2470
|
+
*/
|
2471
|
+
function(name, ...args) {
|
2472
|
+
this.hooks[
|
2473
|
+
name.replace(/[- ]([a-z])/g, match => match[1].toUpperCase())
|
2474
|
+
].call(...args);
|
2475
|
+
},
|
2476
|
+
"Compilation.applyPlugins is deprecated. Use new API on `.hooks` instead"
|
2477
|
+
);
|
2450
2478
|
|
2451
2479
|
// TODO remove in webpack 5
|
2452
2480
|
Object.defineProperty(Compilation.prototype, "moduleTemplate", {
|
2453
2481
|
configurable: false,
|
2454
|
-
get: util.deprecate(
|
2455
|
-
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2482
|
+
get: util.deprecate(
|
2483
|
+
/**
|
2484
|
+
* @deprecated
|
2485
|
+
* @this {Compilation}
|
2486
|
+
* @returns {TODO} module template
|
2487
|
+
*/
|
2488
|
+
function() {
|
2489
|
+
return this.moduleTemplates.javascript;
|
2490
|
+
},
|
2491
|
+
"Compilation.moduleTemplate: Use Compilation.moduleTemplates.javascript instead"
|
2492
|
+
),
|
2493
|
+
set: util.deprecate(
|
2494
|
+
/**
|
2495
|
+
* @deprecated
|
2496
|
+
* @param {ModuleTemplate} value Template value
|
2497
|
+
* @this {Compilation}
|
2498
|
+
* @returns {void}
|
2499
|
+
*/
|
2500
|
+
function(value) {
|
2501
|
+
this.moduleTemplates.javascript = value;
|
2502
|
+
},
|
2503
|
+
"Compilation.moduleTemplate: Use Compilation.moduleTemplates.javascript instead."
|
2504
|
+
)
|
2460
2505
|
});
|
2461
2506
|
|
2462
2507
|
module.exports = Compilation;
|
@@ -1,10 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
/** @typedef {import("./Compiler")} Compiler */
|
4
|
+
/** @typedef {import("./ContextModuleFactory")} ContextModuleFactory */
|
5
|
+
|
3
6
|
class ContextExclusionPlugin {
|
7
|
+
/**
|
8
|
+
* @param {RegExp} negativeMatcher Matcher regular expression
|
9
|
+
*/
|
4
10
|
constructor(negativeMatcher) {
|
5
11
|
this.negativeMatcher = negativeMatcher;
|
6
12
|
}
|
7
13
|
|
14
|
+
/**
|
15
|
+
* Apply the plugin
|
16
|
+
* @param {Compiler} compiler Webpack Compiler
|
17
|
+
* @returns {void}
|
18
|
+
*/
|
8
19
|
apply(compiler) {
|
9
20
|
compiler.hooks.contextModuleFactory.tap("ContextExclusionPlugin", cmf => {
|
10
21
|
cmf.hooks.contextModuleFiles.tap("ContextExclusionPlugin", files => {
|
package/lib/ContextModule.js
CHANGED
@@ -10,6 +10,7 @@ const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
|
|
10
10
|
const Template = require("./Template");
|
11
11
|
const contextify = require("./util/identifier").contextify;
|
12
12
|
|
13
|
+
/** @typedef {"sync" | "eager" | "weak" | "async-weak" | "lazy" | "lazy-once"} ContextMode Context mode */
|
13
14
|
/** @typedef {import("./dependencies/ContextElementDependency")} ContextElementDependency */
|
14
15
|
|
15
16
|
/**
|
@@ -703,56 +704,141 @@ webpackEmptyAsyncContext.id = ${JSON.stringify(id)};`;
|
|
703
704
|
// TODO remove in webpack 5
|
704
705
|
Object.defineProperty(ContextModule.prototype, "recursive", {
|
705
706
|
configurable: false,
|
706
|
-
get: util.deprecate(
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
707
|
+
get: util.deprecate(
|
708
|
+
/**
|
709
|
+
* @deprecated
|
710
|
+
* @this {ContextModule}
|
711
|
+
* @returns {boolean} is recursive
|
712
|
+
*/
|
713
|
+
function() {
|
714
|
+
return this.options.recursive;
|
715
|
+
},
|
716
|
+
"ContextModule.recursive has been moved to ContextModule.options.recursive"
|
717
|
+
),
|
718
|
+
set: util.deprecate(
|
719
|
+
/**
|
720
|
+
* @deprecated
|
721
|
+
* @this {ContextModule}
|
722
|
+
* @param {boolean} value is recursive
|
723
|
+
* @returns {void}
|
724
|
+
*/
|
725
|
+
function(value) {
|
726
|
+
this.options.recursive = value;
|
727
|
+
},
|
728
|
+
"ContextModule.recursive has been moved to ContextModule.options.recursive"
|
729
|
+
)
|
712
730
|
});
|
713
731
|
|
714
732
|
// TODO remove in webpack 5
|
715
733
|
Object.defineProperty(ContextModule.prototype, "regExp", {
|
716
734
|
configurable: false,
|
717
|
-
get: util.deprecate(
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
735
|
+
get: util.deprecate(
|
736
|
+
/**
|
737
|
+
* @deprecated
|
738
|
+
* @this {ContextModule}
|
739
|
+
* @returns {RegExp} regular expression
|
740
|
+
*/
|
741
|
+
function() {
|
742
|
+
return this.options.regExp;
|
743
|
+
},
|
744
|
+
"ContextModule.regExp has been moved to ContextModule.options.regExp"
|
745
|
+
),
|
746
|
+
set: util.deprecate(
|
747
|
+
/**
|
748
|
+
* @deprecated
|
749
|
+
* @this {ContextModule}
|
750
|
+
* @param {RegExp} value Regular expression
|
751
|
+
* @returns {void}
|
752
|
+
*/
|
753
|
+
function(value) {
|
754
|
+
this.options.regExp = value;
|
755
|
+
},
|
756
|
+
"ContextModule.regExp has been moved to ContextModule.options.regExp"
|
757
|
+
)
|
723
758
|
});
|
724
759
|
|
725
760
|
// TODO remove in webpack 5
|
726
761
|
Object.defineProperty(ContextModule.prototype, "addon", {
|
727
762
|
configurable: false,
|
728
|
-
get: util.deprecate(
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
763
|
+
get: util.deprecate(
|
764
|
+
/**
|
765
|
+
* @deprecated
|
766
|
+
* @this {ContextModule}
|
767
|
+
* @returns {string} addon
|
768
|
+
*/
|
769
|
+
function() {
|
770
|
+
return this.options.addon;
|
771
|
+
},
|
772
|
+
"ContextModule.addon has been moved to ContextModule.options.addon"
|
773
|
+
),
|
774
|
+
set: util.deprecate(
|
775
|
+
/**
|
776
|
+
* @deprecated
|
777
|
+
* @this {ContextModule}
|
778
|
+
* @param {string} value addon
|
779
|
+
* @returns {void}
|
780
|
+
*/
|
781
|
+
function(value) {
|
782
|
+
this.options.addon = value;
|
783
|
+
},
|
784
|
+
"ContextModule.addon has been moved to ContextModule.options.addon"
|
785
|
+
)
|
734
786
|
});
|
735
787
|
|
736
788
|
// TODO remove in webpack 5
|
737
789
|
Object.defineProperty(ContextModule.prototype, "async", {
|
738
790
|
configurable: false,
|
739
|
-
get: util.deprecate(
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
791
|
+
get: util.deprecate(
|
792
|
+
/**
|
793
|
+
* @deprecated
|
794
|
+
* @this {ContextModule}
|
795
|
+
* @returns {boolean} is async
|
796
|
+
*/
|
797
|
+
function() {
|
798
|
+
return this.options.mode;
|
799
|
+
},
|
800
|
+
"ContextModule.async has been moved to ContextModule.options.mode"
|
801
|
+
),
|
802
|
+
set: util.deprecate(
|
803
|
+
/**
|
804
|
+
* @deprecated
|
805
|
+
* @this {ContextModule}
|
806
|
+
* @param {ContextMode} value Context mode
|
807
|
+
* @returns {void}
|
808
|
+
*/
|
809
|
+
function(value) {
|
810
|
+
this.options.mode = value;
|
811
|
+
},
|
812
|
+
"ContextModule.async has been moved to ContextModule.options.mode"
|
813
|
+
)
|
745
814
|
});
|
746
815
|
|
747
816
|
// TODO remove in webpack 5
|
748
817
|
Object.defineProperty(ContextModule.prototype, "chunkName", {
|
749
818
|
configurable: false,
|
750
|
-
get: util.deprecate(
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
819
|
+
get: util.deprecate(
|
820
|
+
/**
|
821
|
+
* @deprecated
|
822
|
+
* @this {ContextModule}
|
823
|
+
* @returns {string} chunk name
|
824
|
+
*/
|
825
|
+
function() {
|
826
|
+
return this.options.chunkName;
|
827
|
+
},
|
828
|
+
"ContextModule.chunkName has been moved to ContextModule.options.chunkName"
|
829
|
+
),
|
830
|
+
set: util.deprecate(
|
831
|
+
/**
|
832
|
+
* @deprecated
|
833
|
+
* @this {ContextModule}
|
834
|
+
* @param {string} value chunk name
|
835
|
+
* @returns {void}
|
836
|
+
*/
|
837
|
+
function(value) {
|
838
|
+
this.options.chunkName = value;
|
839
|
+
},
|
840
|
+
"ContextModule.chunkName has been moved to ContextModule.options.chunkName"
|
841
|
+
)
|
756
842
|
});
|
757
843
|
|
758
844
|
module.exports = ContextModule;
|
@@ -15,15 +15,21 @@ const {
|
|
15
15
|
const ContextModule = require("./ContextModule");
|
16
16
|
const ContextElementDependency = require("./dependencies/ContextElementDependency");
|
17
17
|
|
18
|
+
/** @typedef {import("./Module")} Module */
|
19
|
+
|
18
20
|
const EMPTY_RESOLVE_OPTIONS = {};
|
19
21
|
|
20
22
|
module.exports = class ContextModuleFactory extends Tapable {
|
21
23
|
constructor(resolverFactory) {
|
22
24
|
super();
|
23
25
|
this.hooks = {
|
26
|
+
/** @type {AsyncSeriesWaterfallHook<TODO>} */
|
24
27
|
beforeResolve: new AsyncSeriesWaterfallHook(["data"]),
|
28
|
+
/** @type {AsyncSeriesWaterfallHook<TODO>} */
|
25
29
|
afterResolve: new AsyncSeriesWaterfallHook(["data"]),
|
30
|
+
/** @type {SyncWaterfallHook<string[]>} */
|
26
31
|
contextModuleFiles: new SyncWaterfallHook(["files"]),
|
32
|
+
/** @type {SyncWaterfallHook<TODO[]>} */
|
27
33
|
alternatives: new AsyncSeriesWaterfallHook(["modules"])
|
28
34
|
};
|
29
35
|
this._pluginCompat.tap("ContextModuleFactory", options => {
|
package/lib/DelegatedModule.js
CHANGED
@@ -12,6 +12,7 @@ const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDepende
|
|
12
12
|
const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
|
13
13
|
|
14
14
|
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
15
|
+
/** @typedef {import("./util/createHash").Hash} Hash */
|
15
16
|
|
16
17
|
class DelegatedModule extends Module {
|
17
18
|
constructor(sourceRequest, data, type, userRequest, originalRequest) {
|
@@ -99,6 +100,10 @@ class DelegatedModule extends Module {
|
|
99
100
|
return 42;
|
100
101
|
}
|
101
102
|
|
103
|
+
/**
|
104
|
+
* @param {Hash} hash the hash used to track dependencies
|
105
|
+
* @returns {void}
|
106
|
+
*/
|
102
107
|
updateHash(hash) {
|
103
108
|
hash.update(this.type);
|
104
109
|
hash.update(JSON.stringify(this.request));
|
package/lib/DependenciesBlock.js
CHANGED
package/lib/DllModule.js
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
const { RawSource } = require("webpack-sources");
|
8
8
|
const Module = require("./Module");
|
9
9
|
|
10
|
+
/** @typedef {import("./util/createHash").Hash} Hash */
|
11
|
+
|
10
12
|
class DllModule extends Module {
|
11
13
|
constructor(context, dependencies, name, type) {
|
12
14
|
super("javascript/dynamic", context);
|
@@ -44,6 +46,10 @@ class DllModule extends Module {
|
|
44
46
|
return 12;
|
45
47
|
}
|
46
48
|
|
49
|
+
/**
|
50
|
+
* @param {Hash} hash the hash used to track dependencies
|
51
|
+
* @returns {void}
|
52
|
+
*/
|
47
53
|
updateHash(hash) {
|
48
54
|
hash.update("dll module");
|
49
55
|
hash.update(this.name || "");
|
@@ -10,6 +10,8 @@ const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
|
|
10
10
|
const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
|
11
11
|
const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDependency");
|
12
12
|
const NullFactory = require("./NullFactory");
|
13
|
+
const makePathsRelative = require("./util/identifier").makePathsRelative;
|
14
|
+
const WebpackError = require("./WebpackError");
|
13
15
|
|
14
16
|
const validateOptions = require("schema-utils");
|
15
17
|
const schema = require("../schemas/plugins/DllReferencePlugin.json");
|
@@ -43,9 +45,23 @@ class DllReferencePlugin {
|
|
43
45
|
params.compilationDependencies.add(manifest);
|
44
46
|
compiler.inputFileSystem.readFile(manifest, (err, result) => {
|
45
47
|
if (err) return callback(err);
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
// Catch errors parsing the manifest so that blank
|
49
|
+
// or malformed manifest files don't kill the process.
|
50
|
+
try {
|
51
|
+
params["dll reference " + manifest] = parseJson(
|
52
|
+
result.toString("utf-8")
|
53
|
+
);
|
54
|
+
} catch (e) {
|
55
|
+
// Store the error in the params so that it can
|
56
|
+
// be added as a compilation error later on.
|
57
|
+
const manifestPath = makePathsRelative(
|
58
|
+
compiler.options.context,
|
59
|
+
manifest
|
60
|
+
);
|
61
|
+
params[
|
62
|
+
"dll reference parse error " + manifest
|
63
|
+
] = new DllManifestError(manifestPath, e.message);
|
64
|
+
}
|
49
65
|
return callback();
|
50
66
|
});
|
51
67
|
} else {
|
@@ -57,6 +73,12 @@ class DllReferencePlugin {
|
|
57
73
|
compiler.hooks.compile.tap("DllReferencePlugin", params => {
|
58
74
|
let manifest = this.options.manifest;
|
59
75
|
if (typeof manifest === "string") {
|
76
|
+
// If there was an error parsing the manifest
|
77
|
+
// file, exit now because the error will be added
|
78
|
+
// as a compilation error in the "compilation" hook.
|
79
|
+
if (params["dll reference parse error " + manifest]) {
|
80
|
+
return;
|
81
|
+
}
|
60
82
|
manifest = params["dll reference " + manifest];
|
61
83
|
}
|
62
84
|
const name = this.options.name || manifest.name;
|
@@ -78,6 +100,32 @@ class DllReferencePlugin {
|
|
78
100
|
extensions: this.options.extensions
|
79
101
|
}).apply(normalModuleFactory);
|
80
102
|
});
|
103
|
+
|
104
|
+
compiler.hooks.compilation.tap(
|
105
|
+
"DllReferencePlugin",
|
106
|
+
(compilation, params) => {
|
107
|
+
let manifest = this.options.manifest;
|
108
|
+
if (typeof manifest === "string") {
|
109
|
+
// If there was an error parsing the manifest file, add the
|
110
|
+
// error as a compilation error to make the compilation fail.
|
111
|
+
let e = params["dll reference parse error " + manifest];
|
112
|
+
if (e) {
|
113
|
+
compilation.errors.push(e);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
class DllManifestError extends WebpackError {
|
122
|
+
constructor(filename, message) {
|
123
|
+
super();
|
124
|
+
|
125
|
+
this.name = "DllManifestError";
|
126
|
+
this.message = `Dll manifest ${filename}\n${message}`;
|
127
|
+
|
128
|
+
Error.captureStackTrace(this, this.constructor);
|
81
129
|
}
|
82
130
|
}
|
83
131
|
|
package/lib/ExternalModule.js
CHANGED
@@ -9,6 +9,8 @@ const Module = require("./Module");
|
|
9
9
|
const WebpackMissingModule = require("./dependencies/WebpackMissingModule");
|
10
10
|
const Template = require("./Template");
|
11
11
|
|
12
|
+
/** @typedef {import("./util/createHash").Hash} Hash */
|
13
|
+
|
12
14
|
class ExternalModule extends Module {
|
13
15
|
constructor(request, type, userRequest) {
|
14
16
|
super("javascript/dynamic", null);
|
@@ -148,6 +150,10 @@ class ExternalModule extends Module {
|
|
148
150
|
return 42;
|
149
151
|
}
|
150
152
|
|
153
|
+
/**
|
154
|
+
* @param {Hash} hash the hash used to track dependencies
|
155
|
+
* @returns {void}
|
156
|
+
*/
|
151
157
|
updateHash(hash) {
|
152
158
|
hash.update(this.externalType);
|
153
159
|
hash.update(JSON.stringify(this.request));
|
package/lib/Generator.js
CHANGED
@@ -4,9 +4,10 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
/** @typedef {import("./
|
7
|
+
/** @typedef {import("./NormalModule")} NormalModule */
|
8
8
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
9
9
|
/** @typedef {import("webpack-sources").Source} Source */
|
10
|
+
/** @typedef {import("./Dependency").DependencyTemplate} DependencyTemplate */
|
10
11
|
|
11
12
|
/**
|
12
13
|
*
|
@@ -18,8 +19,8 @@ class Generator {
|
|
18
19
|
|
19
20
|
/**
|
20
21
|
* @abstract
|
21
|
-
* @param {
|
22
|
-
* @param {Map<Function,
|
22
|
+
* @param {NormalModule} module module for which the code should be generated
|
23
|
+
* @param {Map<Function, DependencyTemplate>} dependencyTemplates mapping from dependencies to templates
|
23
24
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
24
25
|
* @param {string} type which kind of code should be generated
|
25
26
|
* @returns {Source} generated code
|
@@ -35,6 +36,13 @@ class ByTypeGenerator extends Generator {
|
|
35
36
|
this.map = map;
|
36
37
|
}
|
37
38
|
|
39
|
+
/**
|
40
|
+
* @param {NormalModule} module module for which the code should be generated
|
41
|
+
* @param {Map<Function, DependencyTemplate>} dependencyTemplates mapping from dependencies to templates
|
42
|
+
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
43
|
+
* @param {string} type which kind of code should be generated
|
44
|
+
* @returns {Source} generated code
|
45
|
+
*/
|
38
46
|
generate(module, dependencyTemplates, runtimeTemplate, type) {
|
39
47
|
const generator = this.map[type];
|
40
48
|
if (!generator) {
|
@@ -285,11 +285,7 @@ module.exports = class HotModuleReplacementPlugin {
|
|
285
285
|
compilation.assets[filename] = source;
|
286
286
|
hotUpdateMainContent.c[chunkId] = true;
|
287
287
|
currentChunk.files.push(filename);
|
288
|
-
compilation.hooks.chunkAsset.call(
|
289
|
-
"HotModuleReplacementPlugin",
|
290
|
-
currentChunk,
|
291
|
-
filename
|
292
|
-
);
|
288
|
+
compilation.hooks.chunkAsset.call(currentChunk, filename);
|
293
289
|
}
|
294
290
|
} else {
|
295
291
|
hotUpdateMainContent.c[chunkId] = false;
|