webpack 2.1.0-beta.21 → 2.1.0-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/bin/config-yargs.js +6 -5
  2. package/bin/convert-argv.js +59 -31
  3. package/bin/webpack.js +30 -2
  4. package/lib/APIPlugin.js +19 -16
  5. package/lib/Chunk.js +1 -1
  6. package/lib/CommonJsHarmonyMainTemplatePlugin.js +21 -0
  7. package/lib/CompatibilityPlugin.js +24 -17
  8. package/lib/Compilation.js +36 -15
  9. package/lib/Compiler.js +48 -15
  10. package/lib/ConstPlugin.js +40 -37
  11. package/lib/DefinePlugin.js +107 -103
  12. package/lib/DelegatedModule.js +1 -2
  13. package/lib/Dependency.js +5 -0
  14. package/lib/DllReferencePlugin.js +41 -15
  15. package/lib/ExtendedAPIPlugin.js +14 -11
  16. package/lib/FlagDependencyExportsPlugin.js +102 -0
  17. package/lib/FlagInitialModulesAsUsedPlugin.js +23 -23
  18. package/lib/FunctionModuleTemplatePlugin.js +4 -0
  19. package/lib/HotModuleReplacement.runtime.js +1 -1
  20. package/lib/HotModuleReplacementPlugin.js +71 -68
  21. package/lib/LibManifestPlugin.js +1 -2
  22. package/lib/LibraryTemplatePlugin.js +4 -0
  23. package/lib/MainTemplate.js +12 -13
  24. package/lib/Module.js +10 -1
  25. package/lib/MovedToPluginWarningPlugin.js +3 -1
  26. package/lib/MultiCompiler.js +81 -7
  27. package/lib/NodeStuffPlugin.js +97 -86
  28. package/lib/NormalModule.js +6 -0
  29. package/lib/NormalModuleFactory.js +87 -34
  30. package/lib/Parser.js +13 -4
  31. package/lib/ProvidePlugin.js +30 -27
  32. package/lib/RequireJsStuffPlugin.js +27 -21
  33. package/lib/RuleSet.js +369 -0
  34. package/lib/Stats.js +74 -90
  35. package/lib/UseStrictPlugin.js +12 -8
  36. package/lib/WebpackOptionsApply.js +3 -13
  37. package/lib/WebpackOptionsDefaulter.js +0 -1
  38. package/lib/WebpackOptionsValidationError.js +186 -0
  39. package/lib/dependencies/AMDPlugin.js +64 -55
  40. package/lib/dependencies/CommonJsPlugin.js +55 -45
  41. package/lib/dependencies/HarmonyExportExpressionDependency.js +6 -0
  42. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +76 -16
  43. package/lib/dependencies/HarmonyExportSpecifierDependency.js +12 -4
  44. package/lib/dependencies/HarmonyImportSpecifierDependency.js +6 -4
  45. package/lib/dependencies/HarmonyModulesHelpers.js +0 -29
  46. package/lib/dependencies/HarmonyModulesPlugin.js +11 -4
  47. package/lib/dependencies/RequireContextPlugin.js +12 -5
  48. package/lib/dependencies/RequireEnsurePlugin.js +17 -10
  49. package/lib/dependencies/RequireIncludePlugin.js +18 -10
  50. package/lib/dependencies/SystemPlugin.js +48 -29
  51. package/lib/node/NodeMainTemplate.runtime.js +2 -2
  52. package/lib/node/NodeMainTemplateAsync.runtime.js +2 -2
  53. package/lib/node/NodeSourcePlugin.js +84 -71
  54. package/lib/optimize/ChunkModuleIdRangePlugin.js +52 -0
  55. package/lib/optimize/EnsureChunkConditionsPlugin.js +7 -2
  56. package/lib/validateWebpackOptions.js +63 -0
  57. package/lib/webpack.js +9 -6
  58. package/lib/webworker/WebWorkerMainTemplate.runtime.js +35 -33
  59. package/package.json +13 -8
  60. package/schemas/webpackOptionsSchema.json +802 -0
  61. package/README.md +0 -315
  62. package/lib/LoadersList.js +0 -110
  63. package/lib/dependencies/LabeledExportsDependency.js +0 -21
  64. package/lib/dependencies/LabeledModuleDependency.js +0 -36
  65. package/lib/dependencies/LabeledModuleDependencyParserPlugin.js +0 -78
  66. package/lib/dependencies/LabeledModulesPlugin.js +0 -26
@@ -16,44 +16,47 @@ function ConstPlugin() {}
16
16
  module.exports = ConstPlugin;
17
17
 
18
18
  ConstPlugin.prototype.apply = function(compiler) {
19
- compiler.plugin("compilation", function(compilation) {
19
+ compiler.plugin("compilation", function(compilation, params) {
20
20
  compilation.dependencyFactories.set(ConstDependency, new NullFactory());
21
21
  compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
22
- });
23
- compiler.parser.plugin("statement if", function(statement) {
24
- var param = this.evaluateExpression(statement.test);
25
- var bool = param.asBool();
26
- if(typeof bool === "boolean") {
27
- if(statement.test.type !== "Literal") {
28
- var dep = new ConstDependency(bool + "", param.range);
29
- dep.loc = statement.loc;
30
- this.state.current.addDependency(dep);
31
- }
32
- return bool;
33
- }
34
- });
35
- compiler.parser.plugin("expression ?:", function(expression) {
36
- var param = this.evaluateExpression(expression.test);
37
- var bool = param.asBool();
38
- if(typeof bool === "boolean") {
39
- if(expression.test.type !== "Literal") {
40
- var dep = new ConstDependency(" " + bool + "", param.range);
41
- dep.loc = expression.loc;
42
- this.state.current.addDependency(dep);
43
- }
44
- return bool;
45
- }
46
- });
47
- compiler.parser.plugin("evaluate Identifier __resourceQuery", function(expr) {
48
- if(!this.state.module) return;
49
- var res = new BasicEvaluatedExpression();
50
- res.setString(getQuery(this.state.module.resource));
51
- res.setRange(expr.range);
52
- return res;
53
- });
54
- compiler.parser.plugin("expression __resourceQuery", function() {
55
- if(!this.state.module) return;
56
- this.state.current.addVariable("__resourceQuery", JSON.stringify(getQuery(this.state.module.resource)));
57
- return true;
22
+
23
+ params.normalModuleFactory.plugin("parser", function(parser) {
24
+ parser.plugin("statement if", function(statement) {
25
+ var param = this.evaluateExpression(statement.test);
26
+ var bool = param.asBool();
27
+ if(typeof bool === "boolean") {
28
+ if(statement.test.type !== "Literal") {
29
+ var dep = new ConstDependency(bool + "", param.range);
30
+ dep.loc = statement.loc;
31
+ this.state.current.addDependency(dep);
32
+ }
33
+ return bool;
34
+ }
35
+ });
36
+ parser.plugin("expression ?:", function(expression) {
37
+ var param = this.evaluateExpression(expression.test);
38
+ var bool = param.asBool();
39
+ if(typeof bool === "boolean") {
40
+ if(expression.test.type !== "Literal") {
41
+ var dep = new ConstDependency(" " + bool + "", param.range);
42
+ dep.loc = expression.loc;
43
+ this.state.current.addDependency(dep);
44
+ }
45
+ return bool;
46
+ }
47
+ });
48
+ parser.plugin("evaluate Identifier __resourceQuery", function(expr) {
49
+ if(!this.state.module) return;
50
+ var res = new BasicEvaluatedExpression();
51
+ res.setString(getQuery(this.state.module.resource));
52
+ res.setRange(expr.range);
53
+ return res;
54
+ });
55
+ parser.plugin("expression __resourceQuery", function() {
56
+ if(!this.state.module) return;
57
+ this.state.current.addVariable("__resourceQuery", JSON.stringify(getQuery(this.state.module.resource)));
58
+ return true;
59
+ });
60
+ });
58
61
  });
59
62
  };
@@ -12,115 +12,119 @@ function DefinePlugin(definitions) {
12
12
  }
13
13
  module.exports = DefinePlugin;
14
14
  DefinePlugin.prototype.apply = function(compiler) {
15
- compiler.plugin("compilation", function(compilation) {
15
+ var definitions = this.definitions;
16
+ compiler.plugin("compilation", function(compilation, params) {
16
17
  compilation.dependencyFactories.set(ConstDependency, new NullFactory());
17
18
  compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
18
- });
19
- (function walkDefinitions(definitions, prefix) {
20
- Object.keys(definitions).forEach(function(key) {
21
- var code = definitions[key];
22
- if(code && typeof code === "object" && !(code instanceof RegExp)) {
23
- walkDefinitions(code, prefix + key + ".");
24
- applyObjectDefine(prefix + key, code);
25
- return;
26
- }
27
- applyDefineKey(prefix, key);
28
- applyDefine(prefix + key, code);
29
- });
30
- }(this.definitions, ""));
31
19
 
32
- function stringifyObj(obj) {
33
- return "{" + Object.keys(obj).map(function(key) {
34
- var code = obj[key];
35
- return JSON.stringify(key) + ":" + toCode(code);
36
- }).join(",") + "}";
37
- }
20
+ params.normalModuleFactory.plugin("parser", function(parser) {
21
+ (function walkDefinitions(definitions, prefix) {
22
+ Object.keys(definitions).forEach(function(key) {
23
+ var code = definitions[key];
24
+ if(code && typeof code === "object" && !(code instanceof RegExp)) {
25
+ walkDefinitions(code, prefix + key + ".");
26
+ applyObjectDefine(prefix + key, code);
27
+ return;
28
+ }
29
+ applyDefineKey(prefix, key);
30
+ applyDefine(prefix + key, code);
31
+ });
32
+ }(definitions, ""));
38
33
 
39
- function toCode(code) {
40
- if(code === null) return "null";
41
- else if(code === undefined) return "undefined";
42
- else if(code instanceof RegExp && code.toString) return code.toString();
43
- else if(typeof code === "function" && code.toString) return "(" + code.toString() + ")";
44
- else if(typeof code === "object") return stringifyObj(code);
45
- else return code + "";
46
- }
34
+ function stringifyObj(obj) {
35
+ return "{" + Object.keys(obj).map(function(key) {
36
+ var code = obj[key];
37
+ return JSON.stringify(key) + ":" + toCode(code);
38
+ }).join(",") + "}";
39
+ }
47
40
 
48
- function applyDefineKey(prefix, key) {
49
- var splittedKey = key.split(".");
50
- splittedKey.slice(1).forEach(function(_, i) {
51
- var fullKey = prefix + splittedKey.slice(0, i + 1).join(".");
52
- compiler.parser.plugin("can-rename " + fullKey, function() {
53
- return true;
54
- });
55
- });
56
- }
41
+ function toCode(code) {
42
+ if(code === null) return "null";
43
+ else if(code === undefined) return "undefined";
44
+ else if(code instanceof RegExp && code.toString) return code.toString();
45
+ else if(typeof code === "function" && code.toString) return "(" + code.toString() + ")";
46
+ else if(typeof code === "object") return stringifyObj(code);
47
+ else return code + "";
48
+ }
57
49
 
58
- function applyDefine(key, code) {
59
- var isTypeof = /^typeof\s+/.test(key);
60
- if(isTypeof) key = key.replace(/^typeof\s+/, "");
61
- var recurse = false;
62
- var recurseTypeof = false;
63
- code = toCode(code);
64
- if(!isTypeof) {
65
- compiler.parser.plugin("can-rename " + key, function() {
66
- return true;
67
- });
68
- compiler.parser.plugin("evaluate Identifier " + key, function(expr) {
69
- if(recurse) return;
70
- recurse = true;
71
- var res = compiler.parser.evaluate(code);
72
- recurse = false;
73
- res.setRange(expr.range);
74
- return res;
75
- });
76
- compiler.parser.plugin("expression " + key, function(expr) {
77
- var dep = new ConstDependency(code, expr.range);
78
- dep.loc = expr.loc;
79
- this.state.current.addDependency(dep);
80
- return true;
81
- });
82
- }
83
- var typeofCode = isTypeof ? code : "typeof (" + code + ")";
84
- compiler.parser.plugin("evaluate typeof " + key, function(expr) {
85
- if(recurseTypeof) return;
86
- recurseTypeof = true;
87
- var res = compiler.parser.evaluate(typeofCode);
88
- recurseTypeof = false;
89
- res.setRange(expr.range);
90
- return res;
91
- });
92
- compiler.parser.plugin("typeof " + key, function(expr) {
93
- var res = compiler.parser.evaluate(typeofCode);
94
- if(!res.isString()) return;
95
- var dep = new ConstDependency(JSON.stringify(res.string), expr.range);
96
- dep.loc = expr.loc;
97
- this.state.current.addDependency(dep);
98
- return true;
99
- });
100
- }
50
+ function applyDefineKey(prefix, key) {
51
+ var splittedKey = key.split(".");
52
+ splittedKey.slice(1).forEach(function(_, i) {
53
+ var fullKey = prefix + splittedKey.slice(0, i + 1).join(".");
54
+ parser.plugin("can-rename " + fullKey, function() {
55
+ return true;
56
+ });
57
+ });
58
+ }
101
59
 
102
- function applyObjectDefine(key, obj) {
103
- var code = stringifyObj(obj);
104
- compiler.parser.plugin("can-rename " + key, function() {
105
- return true;
106
- });
107
- compiler.parser.plugin("evaluate Identifier " + key, function(expr) {
108
- return new BasicEvaluatedExpression().setRange(expr.range);
109
- });
110
- compiler.parser.plugin("evaluate typeof " + key, function(expr) {
111
- return new BasicEvaluatedExpression().setString("object").setRange(expr.range);
112
- });
113
- compiler.parser.plugin("expression " + key, function(expr) {
114
- var dep = new ConstDependency(code, expr.range);
115
- dep.loc = expr.loc;
116
- this.state.current.addDependency(dep);
117
- return true;
118
- });
119
- compiler.parser.plugin("typeof " + key, function(expr) {
120
- var dep = new ConstDependency("\"object\"", expr.range);
121
- dep.loc = expr.loc;
122
- this.state.current.addDependency(dep);
123
- return true;
60
+ function applyDefine(key, code) {
61
+ var isTypeof = /^typeof\s+/.test(key);
62
+ if(isTypeof) key = key.replace(/^typeof\s+/, "");
63
+ var recurse = false;
64
+ var recurseTypeof = false;
65
+ code = toCode(code);
66
+ if(!isTypeof) {
67
+ parser.plugin("can-rename " + key, function() {
68
+ return true;
69
+ });
70
+ parser.plugin("evaluate Identifier " + key, function(expr) {
71
+ if(recurse) return;
72
+ recurse = true;
73
+ var res = this.evaluate(code);
74
+ recurse = false;
75
+ res.setRange(expr.range);
76
+ return res;
77
+ });
78
+ parser.plugin("expression " + key, function(expr) {
79
+ var dep = new ConstDependency(code, expr.range);
80
+ dep.loc = expr.loc;
81
+ this.state.current.addDependency(dep);
82
+ return true;
83
+ });
84
+ }
85
+ var typeofCode = isTypeof ? code : "typeof (" + code + ")";
86
+ parser.plugin("evaluate typeof " + key, function(expr) {
87
+ if(recurseTypeof) return;
88
+ recurseTypeof = true;
89
+ var res = this.evaluate(typeofCode);
90
+ recurseTypeof = false;
91
+ res.setRange(expr.range);
92
+ return res;
93
+ });
94
+ parser.plugin("typeof " + key, function(expr) {
95
+ var res = this.evaluate(typeofCode);
96
+ if(!res.isString()) return;
97
+ var dep = new ConstDependency(JSON.stringify(res.string), expr.range);
98
+ dep.loc = expr.loc;
99
+ this.state.current.addDependency(dep);
100
+ return true;
101
+ });
102
+ }
103
+
104
+ function applyObjectDefine(key, obj) {
105
+ var code = stringifyObj(obj);
106
+ parser.plugin("can-rename " + key, function() {
107
+ return true;
108
+ });
109
+ parser.plugin("evaluate Identifier " + key, function(expr) {
110
+ return new BasicEvaluatedExpression().setRange(expr.range);
111
+ });
112
+ parser.plugin("evaluate typeof " + key, function(expr) {
113
+ return new BasicEvaluatedExpression().setString("object").setRange(expr.range);
114
+ });
115
+ parser.plugin("expression " + key, function(expr) {
116
+ var dep = new ConstDependency(code, expr.range);
117
+ dep.loc = expr.loc;
118
+ this.state.current.addDependency(dep);
119
+ return true;
120
+ });
121
+ parser.plugin("typeof " + key, function(expr) {
122
+ var dep = new ConstDependency("\"object\"", expr.range);
123
+ dep.loc = expr.loc;
124
+ this.state.current.addDependency(dep);
125
+ return true;
126
+ });
127
+ }
124
128
  });
125
- }
129
+ });
126
130
  };
@@ -17,8 +17,7 @@ function DelegatedModule(sourceRequest, data, type, userRequest) {
17
17
  this.userRequest = userRequest;
18
18
  this.built = false;
19
19
  this.usedExports = true;
20
- this.hasStarExport = data.hasStarExport;
21
- this.activeExports = data.activeExports;
20
+ this.providedExports = data.exports || true;
22
21
  }
23
22
  module.exports = DelegatedModule;
24
23
 
package/lib/Dependency.js CHANGED
@@ -20,6 +20,11 @@ Dependency.prototype.getReference = function() {
20
20
  }
21
21
  };
22
22
 
23
+ // Returns the exported names
24
+ Dependency.prototype.getExports = function() {
25
+ return null;
26
+ };
27
+
23
28
  Dependency.prototype.getWarnings = function() {
24
29
  return null;
25
30
  };
@@ -2,25 +2,51 @@
2
2
  MIT License http://www.opensource.org/licenses/mit-license.php
3
3
  Author Tobias Koppers @sokra
4
4
  */
5
- var DelegatedPlugin = require("./DelegatedPlugin");
6
- var ExternalsPlugin = require("./ExternalsPlugin");
5
+ var DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
6
+ var DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
7
+ var ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
7
8
 
8
9
  function DllReferencePlugin(options) {
9
10
  this.options = options;
10
11
  }
11
12
  module.exports = DllReferencePlugin;
12
13
  DllReferencePlugin.prototype.apply = function(compiler) {
13
- var name = this.options.name || this.options.manifest.name;
14
- var sourceType = this.options.sourceType || "var";
15
- var externals = {};
16
- var source = "dll-reference " + name;
17
- externals[source] = name;
18
- compiler.apply(new ExternalsPlugin(sourceType, externals));
19
- compiler.apply(new DelegatedPlugin({
20
- source: source,
21
- type: this.options.type,
22
- scope: this.options.scope,
23
- context: this.options.context,
24
- content: this.options.content || this.options.manifest.content
25
- }));
14
+ compiler.plugin("compilation", function(compilation, params) {
15
+ var normalModuleFactory = params.normalModuleFactory;
16
+
17
+ compilation.dependencyFactories.set(DelegatedSourceDependency, normalModuleFactory);
18
+ });
19
+ compiler.plugin("before-compile", function(params, callback) {
20
+ var manifest = this.options.manifest;
21
+ if(typeof manifest === "string") {
22
+ params.compilationDependencies.push(manifest);
23
+ compiler.inputFileSystem.readFile(manifest, function(err, result) {
24
+ if(err) return callback(err);
25
+ params["dll reference " + manifest] = JSON.parse(result.toString("utf-8"));
26
+ return callback();
27
+ });
28
+ } else {
29
+ return callback();
30
+ }
31
+ }.bind(this));
32
+ compiler.plugin("compile", function(params) {
33
+ var manifest = this.options.manifest;
34
+ if(typeof manifest === "string") {
35
+ manifest = params["dll reference " + manifest];
36
+ }
37
+ var name = this.options.name || manifest.name;
38
+ var sourceType = this.options.sourceType || "var";
39
+ var externals = {};
40
+ var source = "dll-reference " + name;
41
+ externals[source] = name;
42
+ params.normalModuleFactory.apply(new ExternalModuleFactoryPlugin(sourceType, externals));
43
+ params.normalModuleFactory.apply(new DelegatedModuleFactoryPlugin({
44
+ source: source,
45
+ type: this.options.type,
46
+ scope: this.options.scope,
47
+ context: this.options.context || compiler.options.context,
48
+ content: this.options.content || manifest.content,
49
+ extensions: this.options.extensions
50
+ }));
51
+ }.bind(this));
26
52
  };
@@ -17,7 +17,7 @@ var REPLACEMENT_TYPES = {
17
17
  __webpack_hash__: "string" // eslint-disable-line camelcase
18
18
  };
19
19
  ExtendedAPIPlugin.prototype.apply = function(compiler) {
20
- compiler.plugin("compilation", function(compilation) {
20
+ compiler.plugin("compilation", function(compilation, params) {
21
21
  compilation.dependencyFactories.set(ConstDependency, new NullFactory());
22
22
  compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
23
23
  compilation.mainTemplate.plugin("require-extensions", function(source, chunk, hash) {
@@ -30,16 +30,19 @@ ExtendedAPIPlugin.prototype.apply = function(compiler) {
30
30
  compilation.mainTemplate.plugin("global-hash", function() {
31
31
  return true;
32
32
  });
33
- });
34
- Object.keys(REPLACEMENTS).forEach(function(key) {
35
- compiler.parser.plugin("expression " + key, function(expr) {
36
- var dep = new ConstDependency(REPLACEMENTS[key], expr.range);
37
- dep.loc = expr.loc;
38
- this.state.current.addDependency(dep);
39
- return true;
40
- });
41
- compiler.parser.plugin("evaluate typeof " + key, function(expr) {
42
- return new BasicEvaluatedExpression().setString(REPLACEMENT_TYPES[key]).setRange(expr.range);
33
+
34
+ params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
35
+ Object.keys(REPLACEMENTS).forEach(function(key) {
36
+ parser.plugin("expression " + key, function(expr) {
37
+ var dep = new ConstDependency(REPLACEMENTS[key], expr.range);
38
+ dep.loc = expr.loc;
39
+ this.state.current.addDependency(dep);
40
+ return true;
41
+ });
42
+ parser.plugin("evaluate typeof " + key, function(expr) {
43
+ return new BasicEvaluatedExpression().setString(REPLACEMENT_TYPES[key]).setRange(expr.range);
44
+ });
45
+ });
43
46
  });
44
47
  });
45
48
  };
@@ -0,0 +1,102 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ function FlagDependencyExportsPlugin() {
6
+
7
+ }
8
+ module.exports = FlagDependencyExportsPlugin;
9
+
10
+ FlagDependencyExportsPlugin.prototype.apply = function(compiler) {
11
+ compiler.plugin("compilation", function(compilation) {
12
+ compilation.plugin("finish-modules", function(modules) {
13
+
14
+ var dependencies = {};
15
+
16
+ var module, moduleWithExports;
17
+ var queue = modules.filter(function(m) {
18
+ return !m.providedExports;
19
+ });
20
+ for(var i = 0; i < queue.length; i++) {
21
+ module = queue[i];
22
+
23
+ if(module.providedExports !== true) {
24
+ moduleWithExports = false;
25
+ processDependenciesBlock(module);
26
+ if(!moduleWithExports) {
27
+ module.providedExports = true;
28
+ notifyDependencies();
29
+ }
30
+ }
31
+ }
32
+
33
+ function processDependenciesBlock(depBlock) {
34
+ depBlock.dependencies.forEach(function(dep) {
35
+ processDependency(dep);
36
+ });
37
+ depBlock.variables.forEach(function(variable) {
38
+ variable.dependencies.forEach(function(dep) {
39
+ processDependency(dep);
40
+ });
41
+ });
42
+ depBlock.blocks.forEach(function(block) {
43
+ processDependenciesBlock(block);
44
+ });
45
+ }
46
+
47
+ function processDependency(dep, usedExports) {
48
+ var exportDesc = dep.getExports && dep.getExports();
49
+ if(!exportDesc) return;
50
+ moduleWithExports = true;
51
+ var exports = exportDesc.exports;
52
+ var exportDeps = exportDesc.dependencies;
53
+ if(exportDeps) {
54
+ exportDeps.forEach(function(dep) {
55
+ var depIdent = dep.identifier();
56
+ var array = dependencies["$" + depIdent];
57
+ if(!array) array = dependencies["$" + depIdent] = [];
58
+ if(array.indexOf(module) < 0)
59
+ array.push(module);
60
+ });
61
+ }
62
+ var changed = false;
63
+ if(module.providedExports !== true) {
64
+ if(exports === true) {
65
+ module.providedExports = true;
66
+ changed = true;
67
+ } else if(Array.isArray(exports)) {
68
+ if(Array.isArray(module.providedExports)) {
69
+ changed = addToSet(module.providedExports, exports);
70
+ } else {
71
+ module.providedExports = exports.slice();
72
+ changed = true;
73
+ }
74
+ };
75
+ }
76
+ if(changed) {
77
+ notifyDependencies();
78
+ }
79
+ }
80
+
81
+ function notifyDependencies() {
82
+ var deps = dependencies["$" + module.identifier()];
83
+ if(deps) {
84
+ deps.forEach(function(dep) {
85
+ queue.push(dep);
86
+ });
87
+ }
88
+ }
89
+ });
90
+
91
+ function addToSet(a, b) {
92
+ var changed = false;
93
+ b.forEach(function(item) {
94
+ if(a.indexOf(item) < 0) {
95
+ a.push(item);
96
+ changed = true;
97
+ }
98
+ });
99
+ return changed;
100
+ }
101
+ });
102
+ };
@@ -1,23 +1,23 @@
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 FlagInitialModulesAsUsedPlugin() {}
9
- module.exports = FlagInitialModulesAsUsedPlugin;
10
- FlagInitialModulesAsUsedPlugin.prototype.apply = function(compiler) {
11
- compiler.plugin("compilation", function(compilation) {
12
- compilation.plugin("after-optimize-chunks", function(chunks) {
13
- chunks.forEach(function(chunk) {
14
- if(!chunk.isInitial()) {
15
- return;
16
- }
17
- chunk.modules.forEach(function(module) {
18
- module.usedExports = true;
19
- });
20
- });
21
- });
22
- });
23
- };
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 FlagInitialModulesAsUsedPlugin() {}
9
+ module.exports = FlagInitialModulesAsUsedPlugin;
10
+ FlagInitialModulesAsUsedPlugin.prototype.apply = function(compiler) {
11
+ compiler.plugin("compilation", function(compilation) {
12
+ compilation.plugin("after-optimize-chunks", function(chunks) {
13
+ chunks.forEach(function(chunk) {
14
+ if(!chunk.isInitial()) {
15
+ return;
16
+ }
17
+ chunk.modules.forEach(function(module) {
18
+ module.usedExports = true;
19
+ });
20
+ });
21
+ });
22
+ });
23
+ };
@@ -25,6 +25,10 @@ FunctionModuleTemplatePlugin.prototype.apply = function(moduleTemplate) {
25
25
  if(this.outputOptions.pathinfo) {
26
26
  var source = new ConcatSource();
27
27
  var req = module.readableIdentifier(this.requestShortener);
28
+ if(Array.isArray(module.providedExports))
29
+ source.add("/* exports provided: " + module.providedExports.join(", ") + " */\n");
30
+ else if(module.providedExports)
31
+ source.add("/* unknown exports provided */\n");
28
32
  if(Array.isArray(module.usedExports))
29
33
  source.add("/* exports used: " + module.usedExports.join(", ") + " */\n");
30
34
  else if(module.usedExports)
@@ -2,7 +2,7 @@
2
2
  MIT License http://www.opensource.org/licenses/mit-license.php
3
3
  Author Tobias Koppers @sokra
4
4
  */
5
- /*global $hash$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk modules */
5
+ /*global $hash$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
6
6
  module.exports = function() {
7
7
 
8
8
  var hotApplyOnUpdate = true;