webpack 1.13.3 → 1.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.
- package/LICENSE +22 -22
- package/README.md +310 -310
- package/buildin/amd-define.js +1 -1
- package/buildin/amd-options.js +1 -1
- package/buildin/module.js +10 -10
- package/hot/dev-server.js +63 -63
- package/hot/log-apply-result.js +25 -25
- package/hot/only-dev-server.js +77 -77
- package/hot/poll.js +37 -37
- package/hot/signal.js +65 -65
- package/lib/APIPlugin.js +49 -49
- package/lib/AbstractPlugin.js +22 -22
- package/lib/AmdMainTemplatePlugin.js +43 -43
- package/lib/ArrayMap.js +50 -50
- package/lib/AsyncDependenciesBlock.js +39 -39
- package/lib/AutomaticPrefetchPlugin.js +35 -35
- package/lib/BannerPlugin.js +34 -34
- package/lib/BasicEvaluatedExpression.js +140 -140
- package/lib/CachePlugin.js +43 -43
- package/lib/CaseSensitiveModulesWarning.js +16 -16
- package/lib/Chunk.js +252 -252
- package/lib/ChunkRenderError.js +17 -17
- package/lib/ChunkTemplate.js +37 -37
- package/lib/CompatibilityPlugin.js +42 -42
- package/lib/Compilation.js +891 -891
- package/lib/Compiler.js +407 -407
- package/lib/ConcatSource.js +5 -5
- package/lib/ConstPlugin.js +54 -54
- package/lib/ContextModule.js +130 -130
- package/lib/ContextModuleFactory.js +132 -132
- package/lib/ContextReplacementPlugin.js +93 -93
- package/lib/CriticalDependenciesWarning.js +24 -24
- package/lib/DefinePlugin.js +126 -126
- package/lib/DelegatedModule.js +69 -69
- package/lib/DelegatedModuleFactoryPlugin.js +51 -51
- package/lib/DelegatedPlugin.js +21 -21
- package/lib/DependenciesBlock.js +57 -57
- package/lib/DependenciesBlockVariable.js +41 -41
- package/lib/Dependency.js +54 -54
- package/lib/DllEntryPlugin.js +32 -32
- package/lib/DllModule.js +55 -55
- package/lib/DllModuleFactory.js +18 -18
- package/lib/DllPlugin.js +30 -30
- package/lib/DllReferencePlugin.js +26 -26
- package/lib/EntryModuleNotFoundError.js +15 -15
- package/lib/EntryOptionPlugin.js +28 -28
- package/lib/EnvironmentPlugin.js +28 -28
- package/lib/EvalDevToolModulePlugin.js +17 -17
- package/lib/EvalDevToolModuleTemplatePlugin.js +29 -29
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +68 -68
- package/lib/EvalSourceMapDevToolPlugin.js +25 -25
- package/lib/ExtendedAPIPlugin.js +45 -45
- package/lib/ExternalModule.js +89 -89
- package/lib/ExternalModuleFactoryPlugin.js +86 -86
- package/lib/ExternalsPlugin.js +16 -16
- package/lib/FunctionModulePlugin.js +18 -18
- package/lib/FunctionModuleTemplatePlugin.js +39 -39
- package/lib/HotModuleReplacement.runtime.js +486 -486
- package/lib/HotModuleReplacementPlugin.js +223 -223
- package/lib/HotUpdateChunkTemplate.js +28 -28
- package/lib/IgnorePlugin.js +32 -32
- package/lib/JsonpChunkTemplatePlugin.js +26 -26
- package/lib/JsonpExportMainTemplatePlugin.js +28 -28
- package/lib/JsonpHotUpdateChunkTemplatePlugin.js +26 -26
- package/lib/JsonpMainTemplate.runtime.js +56 -56
- package/lib/JsonpMainTemplatePlugin.js +162 -162
- package/lib/JsonpTemplatePlugin.js +17 -17
- package/lib/LibManifestPlugin.js +49 -49
- package/lib/LibraryTemplatePlugin.js +77 -77
- package/lib/LoaderTargetPlugin.js +16 -16
- package/lib/MainTemplate.js +169 -169
- package/lib/MemoryOutputFileSystem.js +5 -5
- package/lib/Module.js +116 -116
- package/lib/ModuleFilenameHelpers.js +157 -157
- package/lib/ModuleNotFoundError.js +17 -17
- package/lib/ModuleParseError.js +26 -26
- package/lib/ModuleParserHelpers.js +21 -21
- package/lib/ModuleReason.js +9 -9
- package/lib/ModuleTemplate.js +23 -23
- package/lib/MovedToPluginWarningPlugin.js +17 -17
- package/lib/MultiCompiler.js +166 -166
- package/lib/MultiEntryPlugin.js +31 -31
- package/lib/MultiModule.js +71 -71
- package/lib/MultiModuleFactory.js +18 -18
- package/lib/NamedModulesPlugin.js +21 -21
- package/lib/NewWatchingPlugin.js +12 -12
- package/lib/NoErrorsPlugin.js +18 -18
- package/lib/NodeStuffPlugin.js +99 -99
- package/lib/NormalModule.js +322 -322
- package/lib/NormalModuleFactory.js +171 -171
- package/lib/NormalModuleReplacementPlugin.js +40 -40
- package/lib/NullFactory.js +10 -10
- package/lib/OldWatchingPlugin.js +14 -14
- package/lib/OptionsApply.js +10 -10
- package/lib/OriginalSource.js +5 -5
- package/lib/Parser.js +938 -938
- package/lib/PrefetchPlugin.js +25 -25
- package/lib/ProgressPlugin.js +80 -80
- package/lib/ProvidePlugin.js +48 -48
- package/lib/RawModule.js +65 -65
- package/lib/RawSource.js +5 -5
- package/lib/RecordIdsPlugin.js +130 -130
- package/lib/RequestShortener.js +56 -56
- package/lib/RequireJsStuffPlugin.js +38 -38
- package/lib/ResolverPlugin.js +34 -34
- package/lib/SetVarMainTemplatePlugin.js +36 -36
- package/lib/SingleEntryPlugin.js +24 -24
- package/lib/Source.js +5 -5
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +33 -33
- package/lib/SourceMapDevToolPlugin.js +168 -168
- package/lib/SourceMapSource.js +5 -5
- package/lib/Stats.js +732 -732
- package/lib/Template.js +119 -119
- package/lib/TemplatedPathPlugin.js +111 -111
- package/lib/UmdMainTemplatePlugin.js +146 -146
- package/lib/UnsupportedFeatureWarning.js +14 -14
- package/lib/WarnCaseSensitiveModulesPlugin.js +27 -27
- package/lib/WatchIgnorePlugin.js +45 -45
- package/lib/WebpackOptionsApply.js +376 -376
- package/lib/WebpackOptionsDefaulter.js +112 -112
- package/lib/dependencies/AMDDefineDependency.js +63 -63
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +240 -240
- package/lib/dependencies/AMDPlugin.js +115 -115
- package/lib/dependencies/AMDRequireArrayDependency.js +34 -34
- package/lib/dependencies/AMDRequireContextDependency.js +18 -18
- package/lib/dependencies/AMDRequireDependenciesBlock.js +25 -25
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +145 -145
- package/lib/dependencies/AMDRequireDependency.js +64 -64
- package/lib/dependencies/AMDRequireItemDependency.js +17 -17
- package/lib/dependencies/CommonJsPlugin.js +93 -93
- package/lib/dependencies/CommonJsRequireContextDependency.js +18 -18
- package/lib/dependencies/CommonJsRequireDependency.js +17 -17
- package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +91 -91
- package/lib/dependencies/ConstDependency.js +29 -29
- package/lib/dependencies/ContextDependency.js +24 -24
- package/lib/dependencies/ContextDependencyHelpers.js +34 -34
- package/lib/dependencies/ContextDependencyTemplateAsId.js +22 -22
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +31 -31
- package/lib/dependencies/ContextElementDependency.js +17 -17
- package/lib/dependencies/DelegatedSourceDependency.js +14 -14
- package/lib/dependencies/DepBlockHelpers.js +41 -41
- package/lib/dependencies/DllEntryDependency.js +17 -17
- package/lib/dependencies/LabeledExportsDependency.js +21 -21
- package/lib/dependencies/LabeledModuleDependency.js +36 -36
- package/lib/dependencies/LabeledModuleDependencyParserPlugin.js +76 -76
- package/lib/dependencies/LabeledModulesPlugin.js +26 -26
- package/lib/dependencies/LoaderDependency.js +14 -14
- package/lib/dependencies/LoaderPlugin.js +61 -61
- package/lib/dependencies/LocalModule.js +19 -19
- package/lib/dependencies/LocalModuleDependency.js +23 -23
- package/lib/dependencies/LocalModulesHelpers.js +43 -43
- package/lib/dependencies/ModuleDependency.js +20 -20
- package/lib/dependencies/ModuleDependencyTemplateAsId.js +22 -22
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +22 -22
- package/lib/dependencies/ModuleHotAcceptDependency.js +18 -18
- package/lib/dependencies/ModuleHotDeclineDependency.js +18 -18
- package/lib/dependencies/MultiEntryDependency.js +16 -16
- package/lib/dependencies/NullDependency.js +17 -17
- package/lib/dependencies/NullDependencyTemplate.js +8 -8
- package/lib/dependencies/PrefetchDependency.js +14 -14
- package/lib/dependencies/RequireContextDependency.js +17 -17
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +33 -33
- package/lib/dependencies/RequireContextPlugin.js +64 -64
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +20 -20
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +66 -66
- package/lib/dependencies/RequireEnsureDependency.js +29 -29
- package/lib/dependencies/RequireEnsureItemDependency.js +16 -16
- package/lib/dependencies/RequireEnsurePlugin.js +38 -38
- package/lib/dependencies/RequireHeaderDependency.js +25 -25
- package/lib/dependencies/RequireIncludeDependency.js +25 -25
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +18 -18
- package/lib/dependencies/RequireIncludePlugin.js +31 -31
- package/lib/dependencies/RequireResolveContextDependency.js +18 -18
- package/lib/dependencies/RequireResolveDependency.js +17 -17
- package/lib/dependencies/RequireResolveDependencyParserPlugin.js +69 -69
- package/lib/dependencies/RequireResolveHeaderDependency.js +25 -25
- package/lib/dependencies/SingleEntryDependency.js +14 -14
- package/lib/dependencies/TemplateArgumentDependency.js +26 -26
- package/lib/dependencies/WebpackMissingModule.js +23 -23
- package/lib/dependencies/getFunctionExpression.js +43 -43
- package/lib/node/NodeChunkTemplatePlugin.js +22 -22
- package/lib/node/NodeEnvironmentPlugin.js +25 -25
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +24 -24
- package/lib/node/NodeMainTemplate.runtime.js +20 -20
- package/lib/node/NodeMainTemplateAsync.runtime.js +34 -34
- package/lib/node/NodeMainTemplatePlugin.js +164 -164
- package/lib/node/NodeOutputFileSystem.js +17 -17
- package/lib/node/NodeSourcePlugin.js +85 -75
- package/lib/node/NodeTargetPlugin.js +12 -12
- package/lib/node/NodeTemplatePlugin.js +21 -21
- package/lib/node/NodeWatchFileSystem.js +65 -65
- package/lib/node/OldNodeWatchFileSystem.js +265 -265
- package/lib/optimize/AggressiveMergingPlugin.js +115 -115
- package/lib/optimize/CommonsChunkPlugin.js +178 -178
- package/lib/optimize/DedupePlugin.js +227 -227
- package/lib/optimize/FlagIncludedChunksPlugin.js +24 -24
- package/lib/optimize/LimitChunkCountPlugin.js +55 -55
- package/lib/optimize/MergeDuplicateChunksPlugin.js +30 -30
- package/lib/optimize/MinChunkSizePlugin.js +61 -61
- package/lib/optimize/OccurenceOrderPlugin.js +5 -5
- package/lib/optimize/OccurrenceOrderPlugin.js +91 -91
- package/lib/optimize/RemoveEmptyChunksPlugin.js +19 -19
- package/lib/optimize/RemoveParentModulesPlugin.js +50 -50
- package/lib/optimize/UglifyJsPlugin.js +146 -146
- package/lib/removeAndDo.js +13 -13
- package/lib/web/WebEnvironmentPlugin.js +16 -16
- package/lib/webpack.js +113 -113
- package/lib/webpack.web.js +27 -27
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +26 -26
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +78 -78
- package/lib/webworker/WebWorkerTemplatePlugin.js +15 -15
- package/package.json +4 -4
package/lib/Module.js
CHANGED
@@ -1,116 +1,116 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var DependenciesBlock = require("./DependenciesBlock");
|
6
|
-
var ModuleReason = require("./ModuleReason");
|
7
|
-
|
8
|
-
var debugId = 1000;
|
9
|
-
|
10
|
-
function Module() {
|
11
|
-
DependenciesBlock.call(this);
|
12
|
-
this.context = null;
|
13
|
-
this.reasons = [];
|
14
|
-
this.debugId = debugId++;
|
15
|
-
this.lastId = -1;
|
16
|
-
this.id = null;
|
17
|
-
this.index = null;
|
18
|
-
this.index2 = null;
|
19
|
-
this.chunks = [];
|
20
|
-
this.warnings = [];
|
21
|
-
this.dependenciesWarnings = [];
|
22
|
-
this.errors = [];
|
23
|
-
this.dependenciesErrors = [];
|
24
|
-
}
|
25
|
-
module.exports = Module;
|
26
|
-
|
27
|
-
Module.prototype = Object.create(DependenciesBlock.prototype);
|
28
|
-
|
29
|
-
Module.prototype.disconnect = function() {
|
30
|
-
this.reasons.length = 0;
|
31
|
-
this.lastId = this.id;
|
32
|
-
this.id = null;
|
33
|
-
this.index = null;
|
34
|
-
this.index2 = null;
|
35
|
-
this.chunks.length = 0;
|
36
|
-
DependenciesBlock.prototype.disconnect.call(this);
|
37
|
-
};
|
38
|
-
|
39
|
-
Module.prototype.addChunk = function(chunk) {
|
40
|
-
var idx = this.chunks.indexOf(chunk);
|
41
|
-
if(idx < 0)
|
42
|
-
this.chunks.push(chunk);
|
43
|
-
};
|
44
|
-
|
45
|
-
Module.prototype._removeAndDo = require("./removeAndDo");
|
46
|
-
|
47
|
-
Module.prototype.removeChunk = function(chunk) {
|
48
|
-
return this._removeAndDo("chunks", chunk, "removeModule");
|
49
|
-
};
|
50
|
-
|
51
|
-
Module.prototype.addReason = function(module, dependency) {
|
52
|
-
this.reasons.push(new ModuleReason(module, dependency));
|
53
|
-
};
|
54
|
-
|
55
|
-
Module.prototype.removeReason = function(module, dependency) {
|
56
|
-
for(var i = 0; i < this.reasons.length; i++) {
|
57
|
-
var r = this.reasons[i];
|
58
|
-
if(r.module === module && r.dependency === dependency) {
|
59
|
-
this.reasons.splice(i, 1);
|
60
|
-
return true;
|
61
|
-
}
|
62
|
-
}
|
63
|
-
return false;
|
64
|
-
};
|
65
|
-
|
66
|
-
Module.prototype.hasReasonForChunk = function(chunk) {
|
67
|
-
for(var i = 0; i < this.reasons.length; i++) {
|
68
|
-
var r = this.reasons[i];
|
69
|
-
if(r.chunks) {
|
70
|
-
if(r.chunks.indexOf(chunk) >= 0)
|
71
|
-
return true;
|
72
|
-
} else if(r.module.chunks.indexOf(chunk) >= 0)
|
73
|
-
return true;
|
74
|
-
}
|
75
|
-
return false;
|
76
|
-
};
|
77
|
-
|
78
|
-
function addToSet(set, items) {
|
79
|
-
items.forEach(function(item) {
|
80
|
-
if(set.indexOf(item) < 0)
|
81
|
-
set.push(item);
|
82
|
-
});
|
83
|
-
}
|
84
|
-
|
85
|
-
Module.prototype.rewriteChunkInReasons = function(oldChunk, newChunks) {
|
86
|
-
this.reasons.forEach(function(r) {
|
87
|
-
if(!r.chunks) {
|
88
|
-
if(r.module.chunks.indexOf(oldChunk) < 0)
|
89
|
-
return;
|
90
|
-
r.chunks = r.module.chunks;
|
91
|
-
}
|
92
|
-
r.chunks = r.chunks.reduce(function(arr, c) {
|
93
|
-
addToSet(arr, c !== oldChunk ? [c] : newChunks);
|
94
|
-
return arr;
|
95
|
-
}, []);
|
96
|
-
});
|
97
|
-
};
|
98
|
-
|
99
|
-
Module.prototype.toString = function() {
|
100
|
-
return "Module[" + (this.id || this.debugId) + "]";
|
101
|
-
};
|
102
|
-
|
103
|
-
Module.prototype.needRebuild = function( /* fileTimestamps, contextTimestamps */ ) {
|
104
|
-
return true;
|
105
|
-
};
|
106
|
-
|
107
|
-
Module.prototype.updateHash = function(hash) {
|
108
|
-
hash.update(this.id + "");
|
109
|
-
DependenciesBlock.prototype.updateHash.call(this, hash);
|
110
|
-
};
|
111
|
-
|
112
|
-
Module.prototype.identifier = null;
|
113
|
-
Module.prototype.readableIdentifier = null;
|
114
|
-
Module.prototype.build = null;
|
115
|
-
Module.prototype.source = null;
|
116
|
-
Module.prototype.size = null;
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var DependenciesBlock = require("./DependenciesBlock");
|
6
|
+
var ModuleReason = require("./ModuleReason");
|
7
|
+
|
8
|
+
var debugId = 1000;
|
9
|
+
|
10
|
+
function Module() {
|
11
|
+
DependenciesBlock.call(this);
|
12
|
+
this.context = null;
|
13
|
+
this.reasons = [];
|
14
|
+
this.debugId = debugId++;
|
15
|
+
this.lastId = -1;
|
16
|
+
this.id = null;
|
17
|
+
this.index = null;
|
18
|
+
this.index2 = null;
|
19
|
+
this.chunks = [];
|
20
|
+
this.warnings = [];
|
21
|
+
this.dependenciesWarnings = [];
|
22
|
+
this.errors = [];
|
23
|
+
this.dependenciesErrors = [];
|
24
|
+
}
|
25
|
+
module.exports = Module;
|
26
|
+
|
27
|
+
Module.prototype = Object.create(DependenciesBlock.prototype);
|
28
|
+
|
29
|
+
Module.prototype.disconnect = function() {
|
30
|
+
this.reasons.length = 0;
|
31
|
+
this.lastId = this.id;
|
32
|
+
this.id = null;
|
33
|
+
this.index = null;
|
34
|
+
this.index2 = null;
|
35
|
+
this.chunks.length = 0;
|
36
|
+
DependenciesBlock.prototype.disconnect.call(this);
|
37
|
+
};
|
38
|
+
|
39
|
+
Module.prototype.addChunk = function(chunk) {
|
40
|
+
var idx = this.chunks.indexOf(chunk);
|
41
|
+
if(idx < 0)
|
42
|
+
this.chunks.push(chunk);
|
43
|
+
};
|
44
|
+
|
45
|
+
Module.prototype._removeAndDo = require("./removeAndDo");
|
46
|
+
|
47
|
+
Module.prototype.removeChunk = function(chunk) {
|
48
|
+
return this._removeAndDo("chunks", chunk, "removeModule");
|
49
|
+
};
|
50
|
+
|
51
|
+
Module.prototype.addReason = function(module, dependency) {
|
52
|
+
this.reasons.push(new ModuleReason(module, dependency));
|
53
|
+
};
|
54
|
+
|
55
|
+
Module.prototype.removeReason = function(module, dependency) {
|
56
|
+
for(var i = 0; i < this.reasons.length; i++) {
|
57
|
+
var r = this.reasons[i];
|
58
|
+
if(r.module === module && r.dependency === dependency) {
|
59
|
+
this.reasons.splice(i, 1);
|
60
|
+
return true;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return false;
|
64
|
+
};
|
65
|
+
|
66
|
+
Module.prototype.hasReasonForChunk = function(chunk) {
|
67
|
+
for(var i = 0; i < this.reasons.length; i++) {
|
68
|
+
var r = this.reasons[i];
|
69
|
+
if(r.chunks) {
|
70
|
+
if(r.chunks.indexOf(chunk) >= 0)
|
71
|
+
return true;
|
72
|
+
} else if(r.module.chunks.indexOf(chunk) >= 0)
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
return false;
|
76
|
+
};
|
77
|
+
|
78
|
+
function addToSet(set, items) {
|
79
|
+
items.forEach(function(item) {
|
80
|
+
if(set.indexOf(item) < 0)
|
81
|
+
set.push(item);
|
82
|
+
});
|
83
|
+
}
|
84
|
+
|
85
|
+
Module.prototype.rewriteChunkInReasons = function(oldChunk, newChunks) {
|
86
|
+
this.reasons.forEach(function(r) {
|
87
|
+
if(!r.chunks) {
|
88
|
+
if(r.module.chunks.indexOf(oldChunk) < 0)
|
89
|
+
return;
|
90
|
+
r.chunks = r.module.chunks;
|
91
|
+
}
|
92
|
+
r.chunks = r.chunks.reduce(function(arr, c) {
|
93
|
+
addToSet(arr, c !== oldChunk ? [c] : newChunks);
|
94
|
+
return arr;
|
95
|
+
}, []);
|
96
|
+
});
|
97
|
+
};
|
98
|
+
|
99
|
+
Module.prototype.toString = function() {
|
100
|
+
return "Module[" + (this.id || this.debugId) + "]";
|
101
|
+
};
|
102
|
+
|
103
|
+
Module.prototype.needRebuild = function( /* fileTimestamps, contextTimestamps */ ) {
|
104
|
+
return true;
|
105
|
+
};
|
106
|
+
|
107
|
+
Module.prototype.updateHash = function(hash) {
|
108
|
+
hash.update(this.id + "");
|
109
|
+
DependenciesBlock.prototype.updateHash.call(this, hash);
|
110
|
+
};
|
111
|
+
|
112
|
+
Module.prototype.identifier = null;
|
113
|
+
Module.prototype.readableIdentifier = null;
|
114
|
+
Module.prototype.build = null;
|
115
|
+
Module.prototype.source = null;
|
116
|
+
Module.prototype.size = null;
|
@@ -1,157 +1,157 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var ModuleFilenameHelpers = exports;
|
6
|
-
|
7
|
-
ModuleFilenameHelpers.ALL_LOADERS_RESOURCE = "[all-loaders][resource]";
|
8
|
-
ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE = /\[all-?loaders\]\[resource\]/gi;
|
9
|
-
ModuleFilenameHelpers.LOADERS_RESOURCE = "[loaders][resource]";
|
10
|
-
ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE = /\[loaders\]\[resource\]/gi;
|
11
|
-
ModuleFilenameHelpers.RESOURCE = "[resource]";
|
12
|
-
ModuleFilenameHelpers.REGEXP_RESOURCE = /\[resource\]/gi;
|
13
|
-
ModuleFilenameHelpers.ABSOLUTE_RESOURCE_PATH = "[absolute-resource-path]";
|
14
|
-
ModuleFilenameHelpers.REGEXP_ABSOLUTE_RESOURCE_PATH = /\[abs(olute)?-?resource-?path\]/gi;
|
15
|
-
ModuleFilenameHelpers.RESOURCE_PATH = "[resource-path]";
|
16
|
-
ModuleFilenameHelpers.REGEXP_RESOURCE_PATH = /\[resource-?path\]/gi;
|
17
|
-
ModuleFilenameHelpers.ALL_LOADERS = "[all-loaders]";
|
18
|
-
ModuleFilenameHelpers.REGEXP_ALL_LOADERS = /\[all-?loaders\]/gi;
|
19
|
-
ModuleFilenameHelpers.LOADERS = "[loaders]";
|
20
|
-
ModuleFilenameHelpers.REGEXP_LOADERS = /\[loaders\]/gi;
|
21
|
-
ModuleFilenameHelpers.QUERY = "[query]";
|
22
|
-
ModuleFilenameHelpers.REGEXP_QUERY = /\[query\]/gi;
|
23
|
-
ModuleFilenameHelpers.ID = "[id]";
|
24
|
-
ModuleFilenameHelpers.REGEXP_ID = /\[id\]/gi;
|
25
|
-
ModuleFilenameHelpers.HASH = "[hash]";
|
26
|
-
ModuleFilenameHelpers.REGEXP_HASH = /\[hash\]/gi;
|
27
|
-
|
28
|
-
function getAfter(str, token) {
|
29
|
-
var idx = str.indexOf(token);
|
30
|
-
return idx < 0 ? "" : str.substr(idx);
|
31
|
-
}
|
32
|
-
|
33
|
-
function getBefore(str, token) {
|
34
|
-
var idx = str.lastIndexOf(token);
|
35
|
-
return idx < 0 ? "" : str.substr(0, idx);
|
36
|
-
}
|
37
|
-
|
38
|
-
function getHash(str) {
|
39
|
-
var hash = require("crypto").createHash("md5");
|
40
|
-
hash.update(str);
|
41
|
-
return hash.digest("hex").substr(0, 4);
|
42
|
-
}
|
43
|
-
|
44
|
-
function asRegExp(test) {
|
45
|
-
if(typeof test === "string") test = new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
|
46
|
-
return test;
|
47
|
-
}
|
48
|
-
|
49
|
-
ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFilenameTemplate, requestShortener) {
|
50
|
-
if(!module) module = "";
|
51
|
-
if(typeof module === "string") {
|
52
|
-
var shortIdentifier = requestShortener.shorten(module);
|
53
|
-
var identifier = shortIdentifier;
|
54
|
-
var moduleId = "";
|
55
|
-
var absoluteResourcePath = module.split("!").pop();
|
56
|
-
var hash = getHash(identifier);
|
57
|
-
} else {
|
58
|
-
var shortIdentifier = module.readableIdentifier(requestShortener);
|
59
|
-
var identifier = requestShortener.shorten(module.identifier());
|
60
|
-
var moduleId = module.id;
|
61
|
-
var absoluteResourcePath = module.resourcePath || module.identifier().split("!").pop();
|
62
|
-
var hash = getHash(identifier);
|
63
|
-
}
|
64
|
-
var resource = shortIdentifier.split("!").pop();
|
65
|
-
var loaders = getBefore(shortIdentifier, "!");
|
66
|
-
var allLoaders = getBefore(identifier, "!");
|
67
|
-
var query = getAfter(resource, "?");
|
68
|
-
var resourcePath = resource.substr(0, resource.length - query.length);
|
69
|
-
if(typeof moduleFilenameTemplate === "function") {
|
70
|
-
return moduleFilenameTemplate({
|
71
|
-
identifier: identifier,
|
72
|
-
shortIdentifier: shortIdentifier,
|
73
|
-
resource: resource,
|
74
|
-
resourcePath: resourcePath,
|
75
|
-
absoluteResourcePath: absoluteResourcePath,
|
76
|
-
allLoaders: allLoaders,
|
77
|
-
query: query,
|
78
|
-
moduleId: moduleId,
|
79
|
-
hash: hash
|
80
|
-
});
|
81
|
-
}
|
82
|
-
return moduleFilenameTemplate
|
83
|
-
.replace(ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE, identifier)
|
84
|
-
.replace(ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE, shortIdentifier)
|
85
|
-
.replace(ModuleFilenameHelpers.REGEXP_RESOURCE, resource)
|
86
|
-
.replace(ModuleFilenameHelpers.REGEXP_RESOURCE_PATH, resourcePath)
|
87
|
-
.replace(ModuleFilenameHelpers.REGEXP_ABSOLUTE_RESOURCE_PATH, absoluteResourcePath)
|
88
|
-
.replace(ModuleFilenameHelpers.REGEXP_ALL_LOADERS, allLoaders)
|
89
|
-
.replace(ModuleFilenameHelpers.REGEXP_LOADERS, loaders)
|
90
|
-
.replace(ModuleFilenameHelpers.REGEXP_QUERY, query)
|
91
|
-
.replace(ModuleFilenameHelpers.REGEXP_ID, moduleId)
|
92
|
-
.replace(ModuleFilenameHelpers.REGEXP_HASH, hash);
|
93
|
-
};
|
94
|
-
|
95
|
-
ModuleFilenameHelpers.createFooter = function createFooter(module, requestShortener) {
|
96
|
-
if(!module) module = "";
|
97
|
-
if(typeof module === "string") {
|
98
|
-
return [
|
99
|
-
"// WEBPACK FOOTER //",
|
100
|
-
"// " + requestShortener.shorten(module)
|
101
|
-
].join("\n");
|
102
|
-
} else {
|
103
|
-
return [
|
104
|
-
"//////////////////",
|
105
|
-
"// WEBPACK FOOTER",
|
106
|
-
"// " + module.readableIdentifier(requestShortener),
|
107
|
-
"// module id = " + module.id,
|
108
|
-
"// module chunks = " + module.chunks.map(function(c) {
|
109
|
-
return c.id;
|
110
|
-
}).join(" ")
|
111
|
-
].join("\n");
|
112
|
-
}
|
113
|
-
};
|
114
|
-
|
115
|
-
ModuleFilenameHelpers.replaceDuplicates = function replaceDuplicates(array, fn, comparator) {
|
116
|
-
var countMap = {};
|
117
|
-
var posMap = {};
|
118
|
-
array.forEach(function(item, idx) {
|
119
|
-
countMap[item] = (countMap[item] || []);
|
120
|
-
countMap[item].push(idx);
|
121
|
-
posMap[item] = 0;
|
122
|
-
});
|
123
|
-
if(comparator) {
|
124
|
-
Object.keys(countMap).forEach(function(item) {
|
125
|
-
countMap[item].sort(comparator);
|
126
|
-
});
|
127
|
-
}
|
128
|
-
return array.map(function(item, i) {
|
129
|
-
if(countMap[item].length > 1) {
|
130
|
-
if(comparator && countMap[item][0] === i)
|
131
|
-
return item;
|
132
|
-
return fn(item, i, posMap[item]++);
|
133
|
-
} else return item;
|
134
|
-
});
|
135
|
-
};
|
136
|
-
|
137
|
-
ModuleFilenameHelpers.matchPart = function matchPart(str, test) {
|
138
|
-
if(!test) return true;
|
139
|
-
test = asRegExp(test);
|
140
|
-
if(Array.isArray(test)) {
|
141
|
-
return test.map(asRegExp).filter(function(regExp) {
|
142
|
-
return regExp.test(str);
|
143
|
-
}).length > 0;
|
144
|
-
} else {
|
145
|
-
return test.test(str);
|
146
|
-
}
|
147
|
-
};
|
148
|
-
|
149
|
-
ModuleFilenameHelpers.matchObject = function matchObject(obj, str) {
|
150
|
-
if(obj.test)
|
151
|
-
if(!ModuleFilenameHelpers.matchPart(str, obj.test)) return false;
|
152
|
-
if(obj.include)
|
153
|
-
if(!ModuleFilenameHelpers.matchPart(str, obj.include)) return false;
|
154
|
-
if(obj.exclude)
|
155
|
-
if(ModuleFilenameHelpers.matchPart(str, obj.exclude)) return false;
|
156
|
-
return true;
|
157
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var ModuleFilenameHelpers = exports;
|
6
|
+
|
7
|
+
ModuleFilenameHelpers.ALL_LOADERS_RESOURCE = "[all-loaders][resource]";
|
8
|
+
ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE = /\[all-?loaders\]\[resource\]/gi;
|
9
|
+
ModuleFilenameHelpers.LOADERS_RESOURCE = "[loaders][resource]";
|
10
|
+
ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE = /\[loaders\]\[resource\]/gi;
|
11
|
+
ModuleFilenameHelpers.RESOURCE = "[resource]";
|
12
|
+
ModuleFilenameHelpers.REGEXP_RESOURCE = /\[resource\]/gi;
|
13
|
+
ModuleFilenameHelpers.ABSOLUTE_RESOURCE_PATH = "[absolute-resource-path]";
|
14
|
+
ModuleFilenameHelpers.REGEXP_ABSOLUTE_RESOURCE_PATH = /\[abs(olute)?-?resource-?path\]/gi;
|
15
|
+
ModuleFilenameHelpers.RESOURCE_PATH = "[resource-path]";
|
16
|
+
ModuleFilenameHelpers.REGEXP_RESOURCE_PATH = /\[resource-?path\]/gi;
|
17
|
+
ModuleFilenameHelpers.ALL_LOADERS = "[all-loaders]";
|
18
|
+
ModuleFilenameHelpers.REGEXP_ALL_LOADERS = /\[all-?loaders\]/gi;
|
19
|
+
ModuleFilenameHelpers.LOADERS = "[loaders]";
|
20
|
+
ModuleFilenameHelpers.REGEXP_LOADERS = /\[loaders\]/gi;
|
21
|
+
ModuleFilenameHelpers.QUERY = "[query]";
|
22
|
+
ModuleFilenameHelpers.REGEXP_QUERY = /\[query\]/gi;
|
23
|
+
ModuleFilenameHelpers.ID = "[id]";
|
24
|
+
ModuleFilenameHelpers.REGEXP_ID = /\[id\]/gi;
|
25
|
+
ModuleFilenameHelpers.HASH = "[hash]";
|
26
|
+
ModuleFilenameHelpers.REGEXP_HASH = /\[hash\]/gi;
|
27
|
+
|
28
|
+
function getAfter(str, token) {
|
29
|
+
var idx = str.indexOf(token);
|
30
|
+
return idx < 0 ? "" : str.substr(idx);
|
31
|
+
}
|
32
|
+
|
33
|
+
function getBefore(str, token) {
|
34
|
+
var idx = str.lastIndexOf(token);
|
35
|
+
return idx < 0 ? "" : str.substr(0, idx);
|
36
|
+
}
|
37
|
+
|
38
|
+
function getHash(str) {
|
39
|
+
var hash = require("crypto").createHash("md5");
|
40
|
+
hash.update(str);
|
41
|
+
return hash.digest("hex").substr(0, 4);
|
42
|
+
}
|
43
|
+
|
44
|
+
function asRegExp(test) {
|
45
|
+
if(typeof test === "string") test = new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
|
46
|
+
return test;
|
47
|
+
}
|
48
|
+
|
49
|
+
ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFilenameTemplate, requestShortener) {
|
50
|
+
if(!module) module = "";
|
51
|
+
if(typeof module === "string") {
|
52
|
+
var shortIdentifier = requestShortener.shorten(module);
|
53
|
+
var identifier = shortIdentifier;
|
54
|
+
var moduleId = "";
|
55
|
+
var absoluteResourcePath = module.split("!").pop();
|
56
|
+
var hash = getHash(identifier);
|
57
|
+
} else {
|
58
|
+
var shortIdentifier = module.readableIdentifier(requestShortener);
|
59
|
+
var identifier = requestShortener.shorten(module.identifier());
|
60
|
+
var moduleId = module.id;
|
61
|
+
var absoluteResourcePath = module.resourcePath || module.identifier().split("!").pop();
|
62
|
+
var hash = getHash(identifier);
|
63
|
+
}
|
64
|
+
var resource = shortIdentifier.split("!").pop();
|
65
|
+
var loaders = getBefore(shortIdentifier, "!");
|
66
|
+
var allLoaders = getBefore(identifier, "!");
|
67
|
+
var query = getAfter(resource, "?");
|
68
|
+
var resourcePath = resource.substr(0, resource.length - query.length);
|
69
|
+
if(typeof moduleFilenameTemplate === "function") {
|
70
|
+
return moduleFilenameTemplate({
|
71
|
+
identifier: identifier,
|
72
|
+
shortIdentifier: shortIdentifier,
|
73
|
+
resource: resource,
|
74
|
+
resourcePath: resourcePath,
|
75
|
+
absoluteResourcePath: absoluteResourcePath,
|
76
|
+
allLoaders: allLoaders,
|
77
|
+
query: query,
|
78
|
+
moduleId: moduleId,
|
79
|
+
hash: hash
|
80
|
+
});
|
81
|
+
}
|
82
|
+
return moduleFilenameTemplate
|
83
|
+
.replace(ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE, identifier)
|
84
|
+
.replace(ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE, shortIdentifier)
|
85
|
+
.replace(ModuleFilenameHelpers.REGEXP_RESOURCE, resource)
|
86
|
+
.replace(ModuleFilenameHelpers.REGEXP_RESOURCE_PATH, resourcePath)
|
87
|
+
.replace(ModuleFilenameHelpers.REGEXP_ABSOLUTE_RESOURCE_PATH, absoluteResourcePath)
|
88
|
+
.replace(ModuleFilenameHelpers.REGEXP_ALL_LOADERS, allLoaders)
|
89
|
+
.replace(ModuleFilenameHelpers.REGEXP_LOADERS, loaders)
|
90
|
+
.replace(ModuleFilenameHelpers.REGEXP_QUERY, query)
|
91
|
+
.replace(ModuleFilenameHelpers.REGEXP_ID, moduleId)
|
92
|
+
.replace(ModuleFilenameHelpers.REGEXP_HASH, hash);
|
93
|
+
};
|
94
|
+
|
95
|
+
ModuleFilenameHelpers.createFooter = function createFooter(module, requestShortener) {
|
96
|
+
if(!module) module = "";
|
97
|
+
if(typeof module === "string") {
|
98
|
+
return [
|
99
|
+
"// WEBPACK FOOTER //",
|
100
|
+
"// " + requestShortener.shorten(module)
|
101
|
+
].join("\n");
|
102
|
+
} else {
|
103
|
+
return [
|
104
|
+
"//////////////////",
|
105
|
+
"// WEBPACK FOOTER",
|
106
|
+
"// " + module.readableIdentifier(requestShortener),
|
107
|
+
"// module id = " + module.id,
|
108
|
+
"// module chunks = " + module.chunks.map(function(c) {
|
109
|
+
return c.id;
|
110
|
+
}).join(" ")
|
111
|
+
].join("\n");
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
ModuleFilenameHelpers.replaceDuplicates = function replaceDuplicates(array, fn, comparator) {
|
116
|
+
var countMap = {};
|
117
|
+
var posMap = {};
|
118
|
+
array.forEach(function(item, idx) {
|
119
|
+
countMap[item] = (countMap[item] || []);
|
120
|
+
countMap[item].push(idx);
|
121
|
+
posMap[item] = 0;
|
122
|
+
});
|
123
|
+
if(comparator) {
|
124
|
+
Object.keys(countMap).forEach(function(item) {
|
125
|
+
countMap[item].sort(comparator);
|
126
|
+
});
|
127
|
+
}
|
128
|
+
return array.map(function(item, i) {
|
129
|
+
if(countMap[item].length > 1) {
|
130
|
+
if(comparator && countMap[item][0] === i)
|
131
|
+
return item;
|
132
|
+
return fn(item, i, posMap[item]++);
|
133
|
+
} else return item;
|
134
|
+
});
|
135
|
+
};
|
136
|
+
|
137
|
+
ModuleFilenameHelpers.matchPart = function matchPart(str, test) {
|
138
|
+
if(!test) return true;
|
139
|
+
test = asRegExp(test);
|
140
|
+
if(Array.isArray(test)) {
|
141
|
+
return test.map(asRegExp).filter(function(regExp) {
|
142
|
+
return regExp.test(str);
|
143
|
+
}).length > 0;
|
144
|
+
} else {
|
145
|
+
return test.test(str);
|
146
|
+
}
|
147
|
+
};
|
148
|
+
|
149
|
+
ModuleFilenameHelpers.matchObject = function matchObject(obj, str) {
|
150
|
+
if(obj.test)
|
151
|
+
if(!ModuleFilenameHelpers.matchPart(str, obj.test)) return false;
|
152
|
+
if(obj.include)
|
153
|
+
if(!ModuleFilenameHelpers.matchPart(str, obj.include)) return false;
|
154
|
+
if(obj.exclude)
|
155
|
+
if(ModuleFilenameHelpers.matchPart(str, obj.exclude)) return false;
|
156
|
+
return true;
|
157
|
+
};
|
@@ -1,17 +1,17 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function ModuleNotFoundError(module, err) {
|
6
|
-
Error.call(this);
|
7
|
-
Error.captureStackTrace(this, ModuleNotFoundError);
|
8
|
-
this.name = "ModuleNotFoundError";
|
9
|
-
this.message = "Module not found: " + err;
|
10
|
-
this.details = err.details;
|
11
|
-
this.missing = err.missing;
|
12
|
-
this.module = module;
|
13
|
-
this.error = err;
|
14
|
-
}
|
15
|
-
module.exports = ModuleNotFoundError;
|
16
|
-
|
17
|
-
ModuleNotFoundError.prototype = Object.create(Error.prototype);
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function ModuleNotFoundError(module, err) {
|
6
|
+
Error.call(this);
|
7
|
+
Error.captureStackTrace(this, ModuleNotFoundError);
|
8
|
+
this.name = "ModuleNotFoundError";
|
9
|
+
this.message = "Module not found: " + err;
|
10
|
+
this.details = err.details;
|
11
|
+
this.missing = err.missing;
|
12
|
+
this.module = module;
|
13
|
+
this.error = err;
|
14
|
+
}
|
15
|
+
module.exports = ModuleNotFoundError;
|
16
|
+
|
17
|
+
ModuleNotFoundError.prototype = Object.create(Error.prototype);
|
package/lib/ModuleParseError.js
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function ModuleParseError(module, source, err) {
|
6
|
-
Error.call(this);
|
7
|
-
Error.captureStackTrace(this, ModuleParseError);
|
8
|
-
this.name = "ModuleParseError";
|
9
|
-
this.message = "Module parse failed: " + module.request + " " + err.message;
|
10
|
-
this.message += "\nYou may need an appropriate loader to handle this file type.";
|
11
|
-
if(typeof err.lineNumber === "number") {
|
12
|
-
if(/[\0\u0001\u0002\u0003\u0004\u0005\u0006\u0007]/.test(source)) { // binary file
|
13
|
-
this.message += "\n(Source code omitted for this binary file)";
|
14
|
-
} else {
|
15
|
-
source = source.split("\n");
|
16
|
-
this.message += "\n| " + source.slice(Math.max(0, err.lineNumber - 3), err.lineNumber + 2).join("\n| ");
|
17
|
-
}
|
18
|
-
} else {
|
19
|
-
this.message += "\n" + err.stack;
|
20
|
-
}
|
21
|
-
this.module = module;
|
22
|
-
this.error = err;
|
23
|
-
}
|
24
|
-
module.exports = ModuleParseError;
|
25
|
-
|
26
|
-
ModuleParseError.prototype = Object.create(Error.prototype);
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function ModuleParseError(module, source, err) {
|
6
|
+
Error.call(this);
|
7
|
+
Error.captureStackTrace(this, ModuleParseError);
|
8
|
+
this.name = "ModuleParseError";
|
9
|
+
this.message = "Module parse failed: " + module.request + " " + err.message;
|
10
|
+
this.message += "\nYou may need an appropriate loader to handle this file type.";
|
11
|
+
if(typeof err.lineNumber === "number") {
|
12
|
+
if(/[\0\u0001\u0002\u0003\u0004\u0005\u0006\u0007]/.test(source)) { // binary file
|
13
|
+
this.message += "\n(Source code omitted for this binary file)";
|
14
|
+
} else {
|
15
|
+
source = source.split("\n");
|
16
|
+
this.message += "\n| " + source.slice(Math.max(0, err.lineNumber - 3), err.lineNumber + 2).join("\n| ");
|
17
|
+
}
|
18
|
+
} else {
|
19
|
+
this.message += "\n" + err.stack;
|
20
|
+
}
|
21
|
+
this.module = module;
|
22
|
+
this.error = err;
|
23
|
+
}
|
24
|
+
module.exports = ModuleParseError;
|
25
|
+
|
26
|
+
ModuleParseError.prototype = Object.create(Error.prototype);
|