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/LibManifestPlugin.js
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var path = require("path");
|
6
|
-
var async = require("async");
|
7
|
-
|
8
|
-
function LibManifestPlugin(options) {
|
9
|
-
this.options = options;
|
10
|
-
}
|
11
|
-
module.exports = LibManifestPlugin;
|
12
|
-
LibManifestPlugin.prototype.apply = function(compiler) {
|
13
|
-
compiler.plugin("emit", function(compilation, callback) {
|
14
|
-
async.forEach(compilation.chunks, function(chunk, callback) {
|
15
|
-
if(!chunk.initial) {
|
16
|
-
callback();
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
var targetPath = compilation.getPath(this.options.path, {
|
20
|
-
hash: compilation.hash,
|
21
|
-
chunk: chunk
|
22
|
-
});
|
23
|
-
var name = compilation.getPath(this.options.name, {
|
24
|
-
hash: compilation.hash,
|
25
|
-
chunk: chunk
|
26
|
-
});
|
27
|
-
var manifest = {
|
28
|
-
name: name,
|
29
|
-
type: this.options.type,
|
30
|
-
content: chunk.modules.reduce(function(obj, module) {
|
31
|
-
if(module.libIdent) {
|
32
|
-
var ident = module.libIdent({
|
33
|
-
context: this.options.context || compiler.options.context
|
34
|
-
});
|
35
|
-
if(ident) {
|
36
|
-
obj[ident] = module.id;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
return obj;
|
40
|
-
}.bind(this), {})
|
41
|
-
};
|
42
|
-
var content = new Buffer(JSON.stringify(manifest, null, 2), "utf-8");
|
43
|
-
compiler.outputFileSystem.mkdirp(path.dirname(targetPath), function(err) {
|
44
|
-
if(err) return callback(err);
|
45
|
-
compiler.outputFileSystem.writeFile(targetPath, content, callback);
|
46
|
-
});
|
47
|
-
}.bind(this), callback);
|
48
|
-
}.bind(this));
|
49
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var path = require("path");
|
6
|
+
var async = require("async");
|
7
|
+
|
8
|
+
function LibManifestPlugin(options) {
|
9
|
+
this.options = options;
|
10
|
+
}
|
11
|
+
module.exports = LibManifestPlugin;
|
12
|
+
LibManifestPlugin.prototype.apply = function(compiler) {
|
13
|
+
compiler.plugin("emit", function(compilation, callback) {
|
14
|
+
async.forEach(compilation.chunks, function(chunk, callback) {
|
15
|
+
if(!chunk.initial) {
|
16
|
+
callback();
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
var targetPath = compilation.getPath(this.options.path, {
|
20
|
+
hash: compilation.hash,
|
21
|
+
chunk: chunk
|
22
|
+
});
|
23
|
+
var name = compilation.getPath(this.options.name, {
|
24
|
+
hash: compilation.hash,
|
25
|
+
chunk: chunk
|
26
|
+
});
|
27
|
+
var manifest = {
|
28
|
+
name: name,
|
29
|
+
type: this.options.type,
|
30
|
+
content: chunk.modules.reduce(function(obj, module) {
|
31
|
+
if(module.libIdent) {
|
32
|
+
var ident = module.libIdent({
|
33
|
+
context: this.options.context || compiler.options.context
|
34
|
+
});
|
35
|
+
if(ident) {
|
36
|
+
obj[ident] = module.id;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
return obj;
|
40
|
+
}.bind(this), {})
|
41
|
+
};
|
42
|
+
var content = new Buffer(JSON.stringify(manifest, null, 2), "utf-8");
|
43
|
+
compiler.outputFileSystem.mkdirp(path.dirname(targetPath), function(err) {
|
44
|
+
if(err) return callback(err);
|
45
|
+
compiler.outputFileSystem.writeFile(targetPath, content, callback);
|
46
|
+
});
|
47
|
+
}.bind(this), callback);
|
48
|
+
}.bind(this));
|
49
|
+
};
|
@@ -1,77 +1,77 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var SetVarMainTemplatePlugin = require("./SetVarMainTemplatePlugin");
|
6
|
-
|
7
|
-
function accessorToObjectAccess(accessor) {
|
8
|
-
return accessor.map(function(a) {
|
9
|
-
return "[" + JSON.stringify(a) + "]";
|
10
|
-
}).join("");
|
11
|
-
}
|
12
|
-
|
13
|
-
function accessorAccess(base, accessor, joinWith) {
|
14
|
-
accessor = [].concat(accessor);
|
15
|
-
return accessor.map(function(a, idx) {
|
16
|
-
a = base ?
|
17
|
-
base + accessorToObjectAccess(accessor.slice(0, idx + 1)) :
|
18
|
-
accessor[0] + accessorToObjectAccess(accessor.slice(1, idx + 1));
|
19
|
-
if(idx === accessor.length - 1) return a;
|
20
|
-
if(idx === 0 && typeof base === "undefined") return a + " = typeof " + a + " === \"object\" ? " + a + " : {}";
|
21
|
-
return a + " = " + a + " || {}";
|
22
|
-
}).join(joinWith || "; ");
|
23
|
-
}
|
24
|
-
|
25
|
-
function LibraryTemplatePlugin(name, target, umdNamedDefine) {
|
26
|
-
this.name = name;
|
27
|
-
this.target = target;
|
28
|
-
this.umdNamedDefine = umdNamedDefine;
|
29
|
-
}
|
30
|
-
module.exports = LibraryTemplatePlugin;
|
31
|
-
LibraryTemplatePlugin.prototype.apply = function(compiler) {
|
32
|
-
compiler.plugin("this-compilation", function(compilation) {
|
33
|
-
switch(this.target) {
|
34
|
-
case "var":
|
35
|
-
compilation.apply(new SetVarMainTemplatePlugin("var " + accessorAccess(false, this.name)));
|
36
|
-
break;
|
37
|
-
case "assign":
|
38
|
-
compilation.apply(new SetVarMainTemplatePlugin(accessorAccess(undefined, this.name)));
|
39
|
-
break;
|
40
|
-
case "this":
|
41
|
-
case "window":
|
42
|
-
case "global":
|
43
|
-
if(this.name)
|
44
|
-
compilation.apply(new SetVarMainTemplatePlugin(accessorAccess(this.target, this.name)));
|
45
|
-
else
|
46
|
-
compilation.apply(new SetVarMainTemplatePlugin(this.target, true));
|
47
|
-
break;
|
48
|
-
case "commonjs":
|
49
|
-
if(this.name)
|
50
|
-
compilation.apply(new SetVarMainTemplatePlugin(accessorAccess("exports", this.name)));
|
51
|
-
else
|
52
|
-
compilation.apply(new SetVarMainTemplatePlugin("exports", true));
|
53
|
-
break;
|
54
|
-
case "commonjs2":
|
55
|
-
compilation.apply(new SetVarMainTemplatePlugin("module.exports"));
|
56
|
-
break;
|
57
|
-
case "amd":
|
58
|
-
var AmdMainTemplatePlugin = require("./AmdMainTemplatePlugin");
|
59
|
-
compilation.apply(new AmdMainTemplatePlugin(this.name));
|
60
|
-
break;
|
61
|
-
case "umd":
|
62
|
-
case "umd2":
|
63
|
-
var UmdMainTemplatePlugin = require("./UmdMainTemplatePlugin");
|
64
|
-
compilation.apply(new UmdMainTemplatePlugin(this.name, {
|
65
|
-
optionalAmdExternalAsGlobal: this.target === "umd2",
|
66
|
-
namedDefine: this.umdNamedDefine
|
67
|
-
}));
|
68
|
-
break;
|
69
|
-
case "jsonp":
|
70
|
-
var JsonpExportMainTemplatePlugin = require("./JsonpExportMainTemplatePlugin");
|
71
|
-
compilation.apply(new JsonpExportMainTemplatePlugin(this.name));
|
72
|
-
break;
|
73
|
-
default:
|
74
|
-
throw new Error(this.target + " is not a valid Library target");
|
75
|
-
}
|
76
|
-
}.bind(this));
|
77
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var SetVarMainTemplatePlugin = require("./SetVarMainTemplatePlugin");
|
6
|
+
|
7
|
+
function accessorToObjectAccess(accessor) {
|
8
|
+
return accessor.map(function(a) {
|
9
|
+
return "[" + JSON.stringify(a) + "]";
|
10
|
+
}).join("");
|
11
|
+
}
|
12
|
+
|
13
|
+
function accessorAccess(base, accessor, joinWith) {
|
14
|
+
accessor = [].concat(accessor);
|
15
|
+
return accessor.map(function(a, idx) {
|
16
|
+
a = base ?
|
17
|
+
base + accessorToObjectAccess(accessor.slice(0, idx + 1)) :
|
18
|
+
accessor[0] + accessorToObjectAccess(accessor.slice(1, idx + 1));
|
19
|
+
if(idx === accessor.length - 1) return a;
|
20
|
+
if(idx === 0 && typeof base === "undefined") return a + " = typeof " + a + " === \"object\" ? " + a + " : {}";
|
21
|
+
return a + " = " + a + " || {}";
|
22
|
+
}).join(joinWith || "; ");
|
23
|
+
}
|
24
|
+
|
25
|
+
function LibraryTemplatePlugin(name, target, umdNamedDefine) {
|
26
|
+
this.name = name;
|
27
|
+
this.target = target;
|
28
|
+
this.umdNamedDefine = umdNamedDefine;
|
29
|
+
}
|
30
|
+
module.exports = LibraryTemplatePlugin;
|
31
|
+
LibraryTemplatePlugin.prototype.apply = function(compiler) {
|
32
|
+
compiler.plugin("this-compilation", function(compilation) {
|
33
|
+
switch(this.target) {
|
34
|
+
case "var":
|
35
|
+
compilation.apply(new SetVarMainTemplatePlugin("var " + accessorAccess(false, this.name)));
|
36
|
+
break;
|
37
|
+
case "assign":
|
38
|
+
compilation.apply(new SetVarMainTemplatePlugin(accessorAccess(undefined, this.name)));
|
39
|
+
break;
|
40
|
+
case "this":
|
41
|
+
case "window":
|
42
|
+
case "global":
|
43
|
+
if(this.name)
|
44
|
+
compilation.apply(new SetVarMainTemplatePlugin(accessorAccess(this.target, this.name)));
|
45
|
+
else
|
46
|
+
compilation.apply(new SetVarMainTemplatePlugin(this.target, true));
|
47
|
+
break;
|
48
|
+
case "commonjs":
|
49
|
+
if(this.name)
|
50
|
+
compilation.apply(new SetVarMainTemplatePlugin(accessorAccess("exports", this.name)));
|
51
|
+
else
|
52
|
+
compilation.apply(new SetVarMainTemplatePlugin("exports", true));
|
53
|
+
break;
|
54
|
+
case "commonjs2":
|
55
|
+
compilation.apply(new SetVarMainTemplatePlugin("module.exports"));
|
56
|
+
break;
|
57
|
+
case "amd":
|
58
|
+
var AmdMainTemplatePlugin = require("./AmdMainTemplatePlugin");
|
59
|
+
compilation.apply(new AmdMainTemplatePlugin(this.name));
|
60
|
+
break;
|
61
|
+
case "umd":
|
62
|
+
case "umd2":
|
63
|
+
var UmdMainTemplatePlugin = require("./UmdMainTemplatePlugin");
|
64
|
+
compilation.apply(new UmdMainTemplatePlugin(this.name, {
|
65
|
+
optionalAmdExternalAsGlobal: this.target === "umd2",
|
66
|
+
namedDefine: this.umdNamedDefine
|
67
|
+
}));
|
68
|
+
break;
|
69
|
+
case "jsonp":
|
70
|
+
var JsonpExportMainTemplatePlugin = require("./JsonpExportMainTemplatePlugin");
|
71
|
+
compilation.apply(new JsonpExportMainTemplatePlugin(this.name));
|
72
|
+
break;
|
73
|
+
default:
|
74
|
+
throw new Error(this.target + " is not a valid Library target");
|
75
|
+
}
|
76
|
+
}.bind(this));
|
77
|
+
};
|
@@ -1,16 +1,16 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
function LoaderTargetPlugin(target) {
|
6
|
-
this.target = target;
|
7
|
-
}
|
8
|
-
module.exports = LoaderTargetPlugin;
|
9
|
-
LoaderTargetPlugin.prototype.apply = function(compiler) {
|
10
|
-
var target = this.target;
|
11
|
-
compiler.plugin("compilation", function(compilation) {
|
12
|
-
compilation.plugin("normal-module-loader", function(loaderContext) {
|
13
|
-
loaderContext.target = target;
|
14
|
-
});
|
15
|
-
});
|
16
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
function LoaderTargetPlugin(target) {
|
6
|
+
this.target = target;
|
7
|
+
}
|
8
|
+
module.exports = LoaderTargetPlugin;
|
9
|
+
LoaderTargetPlugin.prototype.apply = function(compiler) {
|
10
|
+
var target = this.target;
|
11
|
+
compiler.plugin("compilation", function(compilation) {
|
12
|
+
compilation.plugin("normal-module-loader", function(loaderContext) {
|
13
|
+
loaderContext.target = target;
|
14
|
+
});
|
15
|
+
});
|
16
|
+
};
|
package/lib/MainTemplate.js
CHANGED
@@ -1,169 +1,169 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
var ConcatSource = require("webpack-core/lib/ConcatSource");
|
6
|
-
var OriginalSource = require("webpack-core/lib/OriginalSource");
|
7
|
-
var PrefixSource = require("webpack-core/lib/PrefixSource");
|
8
|
-
var Template = require("./Template");
|
9
|
-
|
10
|
-
function MainTemplate(outputOptions) {
|
11
|
-
Template.call(this, outputOptions);
|
12
|
-
this.plugin("startup", function(source, chunk, hash) {
|
13
|
-
var buf = [];
|
14
|
-
if(chunk.modules.some(function(m) {
|
15
|
-
return m.id === 0;
|
16
|
-
})) {
|
17
|
-
buf.push("");
|
18
|
-
buf.push("// Load entry module and return exports");
|
19
|
-
buf.push("return " + this.renderRequireFunctionForModule(hash, chunk, "0") + "(0);");
|
20
|
-
}
|
21
|
-
return this.asString(buf);
|
22
|
-
});
|
23
|
-
this.plugin("render", function(bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) {
|
24
|
-
var source = new ConcatSource();
|
25
|
-
source.add("/******/ (function(modules) { // webpackBootstrap\n");
|
26
|
-
source.add(new PrefixSource("/******/", bootstrapSource));
|
27
|
-
source.add("/******/ })\n");
|
28
|
-
source.add("/************************************************************************/\n");
|
29
|
-
source.add("/******/ (");
|
30
|
-
var modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ ");
|
31
|
-
source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates));
|
32
|
-
source.add(")");
|
33
|
-
return source;
|
34
|
-
});
|
35
|
-
this.plugin("local-vars", function(source /*, chunk, hash*/ ) {
|
36
|
-
return this.asString([
|
37
|
-
source,
|
38
|
-
"// The module cache",
|
39
|
-
"var installedModules = {};"
|
40
|
-
]);
|
41
|
-
});
|
42
|
-
this.plugin("require", function(source, chunk, hash) {
|
43
|
-
return this.asString([
|
44
|
-
source,
|
45
|
-
"// Check if module is in cache",
|
46
|
-
"if(installedModules[moduleId])",
|
47
|
-
this.indent("return installedModules[moduleId].exports;"),
|
48
|
-
"",
|
49
|
-
"// Create a new module (and put it into the cache)",
|
50
|
-
"var module = installedModules[moduleId] = {",
|
51
|
-
this.indent(this.applyPluginsWaterfall("module-obj", "", chunk, hash, "moduleId")),
|
52
|
-
"};",
|
53
|
-
"",
|
54
|
-
"// Execute the module function",
|
55
|
-
"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
|
56
|
-
"",
|
57
|
-
"// Flag the module as loaded",
|
58
|
-
"module.loaded = true;",
|
59
|
-
"",
|
60
|
-
"// Return the exports of the module",
|
61
|
-
"return module.exports;"
|
62
|
-
]);
|
63
|
-
});
|
64
|
-
this.plugin("module-obj", function( /*source, chunk, hash, varModuleId*/ ) {
|
65
|
-
return this.asString([
|
66
|
-
"exports: {},",
|
67
|
-
"id: moduleId,",
|
68
|
-
"loaded: false"
|
69
|
-
]);
|
70
|
-
});
|
71
|
-
this.plugin("require-extensions", function(source, chunk, hash) {
|
72
|
-
var buf = [];
|
73
|
-
if(chunk.chunks.length > 0) {
|
74
|
-
buf.push("// This file contains only the entry chunk.");
|
75
|
-
buf.push("// The chunk loading function for additional chunks");
|
76
|
-
buf.push(this.requireFn + ".e = function requireEnsure(chunkId, callback) {");
|
77
|
-
buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId")));
|
78
|
-
buf.push("};");
|
79
|
-
}
|
80
|
-
buf.push("");
|
81
|
-
buf.push("// expose the modules object (__webpack_modules__)");
|
82
|
-
buf.push(this.requireFn + ".m = modules;");
|
83
|
-
|
84
|
-
buf.push("");
|
85
|
-
buf.push("// expose the module cache");
|
86
|
-
buf.push(this.requireFn + ".c = installedModules;");
|
87
|
-
|
88
|
-
var publicPath = this.getPublicPath({
|
89
|
-
hash: hash
|
90
|
-
});
|
91
|
-
buf.push("");
|
92
|
-
buf.push("// __webpack_public_path__");
|
93
|
-
buf.push(this.requireFn + ".p = " + JSON.stringify(publicPath) + ";");
|
94
|
-
return this.asString(buf);
|
95
|
-
});
|
96
|
-
}
|
97
|
-
module.exports = MainTemplate;
|
98
|
-
|
99
|
-
MainTemplate.prototype = Object.create(Template.prototype);
|
100
|
-
MainTemplate.prototype.requireFn = "__webpack_require__";
|
101
|
-
MainTemplate.prototype.render = function(hash, chunk, moduleTemplate, dependencyTemplates) {
|
102
|
-
var buf = [];
|
103
|
-
buf.push(this.applyPluginsWaterfall("bootstrap", "", chunk, hash, moduleTemplate, dependencyTemplates));
|
104
|
-
buf.push(this.applyPluginsWaterfall("local-vars", "", chunk, hash));
|
105
|
-
buf.push("");
|
106
|
-
buf.push("// The require function");
|
107
|
-
buf.push("function " + this.requireFn + "(moduleId) {");
|
108
|
-
buf.push(this.indent(this.applyPluginsWaterfall("require", "", chunk, hash)));
|
109
|
-
buf.push("}");
|
110
|
-
buf.push("");
|
111
|
-
buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
|
112
|
-
buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
|
113
|
-
var source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", "webpack/bootstrap " + hash), chunk, hash, moduleTemplate, dependencyTemplates);
|
114
|
-
if(chunk.modules.some(function(module) {
|
115
|
-
return module.id === 0;
|
116
|
-
})) {
|
117
|
-
source = this.applyPluginsWaterfall("render-with-entry", source, chunk, hash);
|
118
|
-
}
|
119
|
-
if(!source) throw new Error("Compiler error: MainTemplate plugin 'render' should return something");
|
120
|
-
chunk.rendered = true;
|
121
|
-
return new ConcatSource(source, ";");
|
122
|
-
};
|
123
|
-
|
124
|
-
MainTemplate.prototype.renderRequireFunctionForModule = function(hash, chunk, varModuleId) {
|
125
|
-
return this.applyPluginsWaterfall("module-require", this.requireFn, chunk, hash, varModuleId);
|
126
|
-
};
|
127
|
-
|
128
|
-
MainTemplate.prototype.renderAddModule = function(hash, chunk, varModuleId, varModule) {
|
129
|
-
return this.applyPluginsWaterfall("add-module", "modules[" + varModuleId + "] = " + varModule + ";", chunk, hash, varModuleId, varModule);
|
130
|
-
};
|
131
|
-
|
132
|
-
MainTemplate.prototype.renderCurrentHashCode = function(hash, length) {
|
133
|
-
length = length || Infinity;
|
134
|
-
return this.applyPluginsWaterfall("current-hash", JSON.stringify(hash.substr(0, length)), length);
|
135
|
-
};
|
136
|
-
|
137
|
-
MainTemplate.prototype.entryPointInChildren = function(chunk) {
|
138
|
-
function checkChildren(chunk, alreadyCheckedChunks) {
|
139
|
-
return chunk.chunks.some(function(child) {
|
140
|
-
if(alreadyCheckedChunks.indexOf(child) >= 0) return;
|
141
|
-
alreadyCheckedChunks.push(child);
|
142
|
-
return child.modules.some(function(module) {
|
143
|
-
return module.id === 0;
|
144
|
-
}) || checkChildren(child, alreadyCheckedChunks);
|
145
|
-
});
|
146
|
-
}
|
147
|
-
return checkChildren(chunk, []);
|
148
|
-
};
|
149
|
-
|
150
|
-
MainTemplate.prototype.getPublicPath = function(options) {
|
151
|
-
return this.applyPluginsWaterfall("asset-path", this.outputOptions.publicPath || "", options);
|
152
|
-
};
|
153
|
-
|
154
|
-
MainTemplate.prototype.updateHash = function(hash) {
|
155
|
-
hash.update("maintemplate");
|
156
|
-
hash.update("3");
|
157
|
-
hash.update(this.outputOptions.publicPath + "");
|
158
|
-
this.applyPlugins("hash", hash);
|
159
|
-
};
|
160
|
-
|
161
|
-
MainTemplate.prototype.updateHashForChunk = function(hash, chunk) {
|
162
|
-
this.updateHash(hash);
|
163
|
-
this.applyPlugins("hash-for-chunk", hash, chunk);
|
164
|
-
};
|
165
|
-
|
166
|
-
MainTemplate.prototype.useChunkHash = function(chunk) {
|
167
|
-
var paths = this.applyPluginsWaterfall("global-hash-paths", []);
|
168
|
-
return !this.applyPluginsBailResult("global-hash", chunk, paths);
|
169
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
var ConcatSource = require("webpack-core/lib/ConcatSource");
|
6
|
+
var OriginalSource = require("webpack-core/lib/OriginalSource");
|
7
|
+
var PrefixSource = require("webpack-core/lib/PrefixSource");
|
8
|
+
var Template = require("./Template");
|
9
|
+
|
10
|
+
function MainTemplate(outputOptions) {
|
11
|
+
Template.call(this, outputOptions);
|
12
|
+
this.plugin("startup", function(source, chunk, hash) {
|
13
|
+
var buf = [];
|
14
|
+
if(chunk.modules.some(function(m) {
|
15
|
+
return m.id === 0;
|
16
|
+
})) {
|
17
|
+
buf.push("");
|
18
|
+
buf.push("// Load entry module and return exports");
|
19
|
+
buf.push("return " + this.renderRequireFunctionForModule(hash, chunk, "0") + "(0);");
|
20
|
+
}
|
21
|
+
return this.asString(buf);
|
22
|
+
});
|
23
|
+
this.plugin("render", function(bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) {
|
24
|
+
var source = new ConcatSource();
|
25
|
+
source.add("/******/ (function(modules) { // webpackBootstrap\n");
|
26
|
+
source.add(new PrefixSource("/******/", bootstrapSource));
|
27
|
+
source.add("/******/ })\n");
|
28
|
+
source.add("/************************************************************************/\n");
|
29
|
+
source.add("/******/ (");
|
30
|
+
var modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ ");
|
31
|
+
source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates));
|
32
|
+
source.add(")");
|
33
|
+
return source;
|
34
|
+
});
|
35
|
+
this.plugin("local-vars", function(source /*, chunk, hash*/ ) {
|
36
|
+
return this.asString([
|
37
|
+
source,
|
38
|
+
"// The module cache",
|
39
|
+
"var installedModules = {};"
|
40
|
+
]);
|
41
|
+
});
|
42
|
+
this.plugin("require", function(source, chunk, hash) {
|
43
|
+
return this.asString([
|
44
|
+
source,
|
45
|
+
"// Check if module is in cache",
|
46
|
+
"if(installedModules[moduleId])",
|
47
|
+
this.indent("return installedModules[moduleId].exports;"),
|
48
|
+
"",
|
49
|
+
"// Create a new module (and put it into the cache)",
|
50
|
+
"var module = installedModules[moduleId] = {",
|
51
|
+
this.indent(this.applyPluginsWaterfall("module-obj", "", chunk, hash, "moduleId")),
|
52
|
+
"};",
|
53
|
+
"",
|
54
|
+
"// Execute the module function",
|
55
|
+
"modules[moduleId].call(module.exports, module, module.exports, " + this.renderRequireFunctionForModule(hash, chunk, "moduleId") + ");",
|
56
|
+
"",
|
57
|
+
"// Flag the module as loaded",
|
58
|
+
"module.loaded = true;",
|
59
|
+
"",
|
60
|
+
"// Return the exports of the module",
|
61
|
+
"return module.exports;"
|
62
|
+
]);
|
63
|
+
});
|
64
|
+
this.plugin("module-obj", function( /*source, chunk, hash, varModuleId*/ ) {
|
65
|
+
return this.asString([
|
66
|
+
"exports: {},",
|
67
|
+
"id: moduleId,",
|
68
|
+
"loaded: false"
|
69
|
+
]);
|
70
|
+
});
|
71
|
+
this.plugin("require-extensions", function(source, chunk, hash) {
|
72
|
+
var buf = [];
|
73
|
+
if(chunk.chunks.length > 0) {
|
74
|
+
buf.push("// This file contains only the entry chunk.");
|
75
|
+
buf.push("// The chunk loading function for additional chunks");
|
76
|
+
buf.push(this.requireFn + ".e = function requireEnsure(chunkId, callback) {");
|
77
|
+
buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId")));
|
78
|
+
buf.push("};");
|
79
|
+
}
|
80
|
+
buf.push("");
|
81
|
+
buf.push("// expose the modules object (__webpack_modules__)");
|
82
|
+
buf.push(this.requireFn + ".m = modules;");
|
83
|
+
|
84
|
+
buf.push("");
|
85
|
+
buf.push("// expose the module cache");
|
86
|
+
buf.push(this.requireFn + ".c = installedModules;");
|
87
|
+
|
88
|
+
var publicPath = this.getPublicPath({
|
89
|
+
hash: hash
|
90
|
+
});
|
91
|
+
buf.push("");
|
92
|
+
buf.push("// __webpack_public_path__");
|
93
|
+
buf.push(this.requireFn + ".p = " + JSON.stringify(publicPath) + ";");
|
94
|
+
return this.asString(buf);
|
95
|
+
});
|
96
|
+
}
|
97
|
+
module.exports = MainTemplate;
|
98
|
+
|
99
|
+
MainTemplate.prototype = Object.create(Template.prototype);
|
100
|
+
MainTemplate.prototype.requireFn = "__webpack_require__";
|
101
|
+
MainTemplate.prototype.render = function(hash, chunk, moduleTemplate, dependencyTemplates) {
|
102
|
+
var buf = [];
|
103
|
+
buf.push(this.applyPluginsWaterfall("bootstrap", "", chunk, hash, moduleTemplate, dependencyTemplates));
|
104
|
+
buf.push(this.applyPluginsWaterfall("local-vars", "", chunk, hash));
|
105
|
+
buf.push("");
|
106
|
+
buf.push("// The require function");
|
107
|
+
buf.push("function " + this.requireFn + "(moduleId) {");
|
108
|
+
buf.push(this.indent(this.applyPluginsWaterfall("require", "", chunk, hash)));
|
109
|
+
buf.push("}");
|
110
|
+
buf.push("");
|
111
|
+
buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
|
112
|
+
buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
|
113
|
+
var source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", "webpack/bootstrap " + hash), chunk, hash, moduleTemplate, dependencyTemplates);
|
114
|
+
if(chunk.modules.some(function(module) {
|
115
|
+
return module.id === 0;
|
116
|
+
})) {
|
117
|
+
source = this.applyPluginsWaterfall("render-with-entry", source, chunk, hash);
|
118
|
+
}
|
119
|
+
if(!source) throw new Error("Compiler error: MainTemplate plugin 'render' should return something");
|
120
|
+
chunk.rendered = true;
|
121
|
+
return new ConcatSource(source, ";");
|
122
|
+
};
|
123
|
+
|
124
|
+
MainTemplate.prototype.renderRequireFunctionForModule = function(hash, chunk, varModuleId) {
|
125
|
+
return this.applyPluginsWaterfall("module-require", this.requireFn, chunk, hash, varModuleId);
|
126
|
+
};
|
127
|
+
|
128
|
+
MainTemplate.prototype.renderAddModule = function(hash, chunk, varModuleId, varModule) {
|
129
|
+
return this.applyPluginsWaterfall("add-module", "modules[" + varModuleId + "] = " + varModule + ";", chunk, hash, varModuleId, varModule);
|
130
|
+
};
|
131
|
+
|
132
|
+
MainTemplate.prototype.renderCurrentHashCode = function(hash, length) {
|
133
|
+
length = length || Infinity;
|
134
|
+
return this.applyPluginsWaterfall("current-hash", JSON.stringify(hash.substr(0, length)), length);
|
135
|
+
};
|
136
|
+
|
137
|
+
MainTemplate.prototype.entryPointInChildren = function(chunk) {
|
138
|
+
function checkChildren(chunk, alreadyCheckedChunks) {
|
139
|
+
return chunk.chunks.some(function(child) {
|
140
|
+
if(alreadyCheckedChunks.indexOf(child) >= 0) return;
|
141
|
+
alreadyCheckedChunks.push(child);
|
142
|
+
return child.modules.some(function(module) {
|
143
|
+
return module.id === 0;
|
144
|
+
}) || checkChildren(child, alreadyCheckedChunks);
|
145
|
+
});
|
146
|
+
}
|
147
|
+
return checkChildren(chunk, []);
|
148
|
+
};
|
149
|
+
|
150
|
+
MainTemplate.prototype.getPublicPath = function(options) {
|
151
|
+
return this.applyPluginsWaterfall("asset-path", this.outputOptions.publicPath || "", options);
|
152
|
+
};
|
153
|
+
|
154
|
+
MainTemplate.prototype.updateHash = function(hash) {
|
155
|
+
hash.update("maintemplate");
|
156
|
+
hash.update("3");
|
157
|
+
hash.update(this.outputOptions.publicPath + "");
|
158
|
+
this.applyPlugins("hash", hash);
|
159
|
+
};
|
160
|
+
|
161
|
+
MainTemplate.prototype.updateHashForChunk = function(hash, chunk) {
|
162
|
+
this.updateHash(hash);
|
163
|
+
this.applyPlugins("hash-for-chunk", hash, chunk);
|
164
|
+
};
|
165
|
+
|
166
|
+
MainTemplate.prototype.useChunkHash = function(chunk) {
|
167
|
+
var paths = this.applyPluginsWaterfall("global-hash-paths", []);
|
168
|
+
return !this.applyPluginsBailResult("global-hash", chunk, paths);
|
169
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
module.exports = require("memory-fs");
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
module.exports = require("memory-fs");
|