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.
Files changed (212) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +310 -310
  3. package/buildin/amd-define.js +1 -1
  4. package/buildin/amd-options.js +1 -1
  5. package/buildin/module.js +10 -10
  6. package/hot/dev-server.js +63 -63
  7. package/hot/log-apply-result.js +25 -25
  8. package/hot/only-dev-server.js +77 -77
  9. package/hot/poll.js +37 -37
  10. package/hot/signal.js +65 -65
  11. package/lib/APIPlugin.js +49 -49
  12. package/lib/AbstractPlugin.js +22 -22
  13. package/lib/AmdMainTemplatePlugin.js +43 -43
  14. package/lib/ArrayMap.js +50 -50
  15. package/lib/AsyncDependenciesBlock.js +39 -39
  16. package/lib/AutomaticPrefetchPlugin.js +35 -35
  17. package/lib/BannerPlugin.js +34 -34
  18. package/lib/BasicEvaluatedExpression.js +140 -140
  19. package/lib/CachePlugin.js +43 -43
  20. package/lib/CaseSensitiveModulesWarning.js +16 -16
  21. package/lib/Chunk.js +252 -252
  22. package/lib/ChunkRenderError.js +17 -17
  23. package/lib/ChunkTemplate.js +37 -37
  24. package/lib/CompatibilityPlugin.js +42 -42
  25. package/lib/Compilation.js +891 -891
  26. package/lib/Compiler.js +407 -407
  27. package/lib/ConcatSource.js +5 -5
  28. package/lib/ConstPlugin.js +54 -54
  29. package/lib/ContextModule.js +130 -130
  30. package/lib/ContextModuleFactory.js +132 -132
  31. package/lib/ContextReplacementPlugin.js +93 -93
  32. package/lib/CriticalDependenciesWarning.js +24 -24
  33. package/lib/DefinePlugin.js +126 -126
  34. package/lib/DelegatedModule.js +69 -69
  35. package/lib/DelegatedModuleFactoryPlugin.js +51 -51
  36. package/lib/DelegatedPlugin.js +21 -21
  37. package/lib/DependenciesBlock.js +57 -57
  38. package/lib/DependenciesBlockVariable.js +41 -41
  39. package/lib/Dependency.js +54 -54
  40. package/lib/DllEntryPlugin.js +32 -32
  41. package/lib/DllModule.js +55 -55
  42. package/lib/DllModuleFactory.js +18 -18
  43. package/lib/DllPlugin.js +30 -30
  44. package/lib/DllReferencePlugin.js +26 -26
  45. package/lib/EntryModuleNotFoundError.js +15 -15
  46. package/lib/EntryOptionPlugin.js +28 -28
  47. package/lib/EnvironmentPlugin.js +28 -28
  48. package/lib/EvalDevToolModulePlugin.js +17 -17
  49. package/lib/EvalDevToolModuleTemplatePlugin.js +29 -29
  50. package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +68 -68
  51. package/lib/EvalSourceMapDevToolPlugin.js +25 -25
  52. package/lib/ExtendedAPIPlugin.js +45 -45
  53. package/lib/ExternalModule.js +89 -89
  54. package/lib/ExternalModuleFactoryPlugin.js +86 -86
  55. package/lib/ExternalsPlugin.js +16 -16
  56. package/lib/FunctionModulePlugin.js +18 -18
  57. package/lib/FunctionModuleTemplatePlugin.js +39 -39
  58. package/lib/HotModuleReplacement.runtime.js +486 -486
  59. package/lib/HotModuleReplacementPlugin.js +223 -223
  60. package/lib/HotUpdateChunkTemplate.js +28 -28
  61. package/lib/IgnorePlugin.js +32 -32
  62. package/lib/JsonpChunkTemplatePlugin.js +26 -26
  63. package/lib/JsonpExportMainTemplatePlugin.js +28 -28
  64. package/lib/JsonpHotUpdateChunkTemplatePlugin.js +26 -26
  65. package/lib/JsonpMainTemplate.runtime.js +56 -56
  66. package/lib/JsonpMainTemplatePlugin.js +162 -162
  67. package/lib/JsonpTemplatePlugin.js +17 -17
  68. package/lib/LibManifestPlugin.js +49 -49
  69. package/lib/LibraryTemplatePlugin.js +77 -77
  70. package/lib/LoaderTargetPlugin.js +16 -16
  71. package/lib/MainTemplate.js +169 -169
  72. package/lib/MemoryOutputFileSystem.js +5 -5
  73. package/lib/Module.js +116 -116
  74. package/lib/ModuleFilenameHelpers.js +157 -157
  75. package/lib/ModuleNotFoundError.js +17 -17
  76. package/lib/ModuleParseError.js +26 -26
  77. package/lib/ModuleParserHelpers.js +21 -21
  78. package/lib/ModuleReason.js +9 -9
  79. package/lib/ModuleTemplate.js +23 -23
  80. package/lib/MovedToPluginWarningPlugin.js +17 -17
  81. package/lib/MultiCompiler.js +166 -166
  82. package/lib/MultiEntryPlugin.js +31 -31
  83. package/lib/MultiModule.js +71 -71
  84. package/lib/MultiModuleFactory.js +18 -18
  85. package/lib/NamedModulesPlugin.js +21 -21
  86. package/lib/NewWatchingPlugin.js +12 -12
  87. package/lib/NoErrorsPlugin.js +18 -18
  88. package/lib/NodeStuffPlugin.js +99 -99
  89. package/lib/NormalModule.js +322 -322
  90. package/lib/NormalModuleFactory.js +171 -171
  91. package/lib/NormalModuleReplacementPlugin.js +40 -40
  92. package/lib/NullFactory.js +10 -10
  93. package/lib/OldWatchingPlugin.js +14 -14
  94. package/lib/OptionsApply.js +10 -10
  95. package/lib/OriginalSource.js +5 -5
  96. package/lib/Parser.js +938 -938
  97. package/lib/PrefetchPlugin.js +25 -25
  98. package/lib/ProgressPlugin.js +80 -80
  99. package/lib/ProvidePlugin.js +48 -48
  100. package/lib/RawModule.js +65 -65
  101. package/lib/RawSource.js +5 -5
  102. package/lib/RecordIdsPlugin.js +130 -130
  103. package/lib/RequestShortener.js +56 -56
  104. package/lib/RequireJsStuffPlugin.js +38 -38
  105. package/lib/ResolverPlugin.js +34 -34
  106. package/lib/SetVarMainTemplatePlugin.js +36 -36
  107. package/lib/SingleEntryPlugin.js +24 -24
  108. package/lib/Source.js +5 -5
  109. package/lib/SourceMapDevToolModuleOptionsPlugin.js +33 -33
  110. package/lib/SourceMapDevToolPlugin.js +168 -168
  111. package/lib/SourceMapSource.js +5 -5
  112. package/lib/Stats.js +732 -732
  113. package/lib/Template.js +119 -119
  114. package/lib/TemplatedPathPlugin.js +111 -111
  115. package/lib/UmdMainTemplatePlugin.js +146 -146
  116. package/lib/UnsupportedFeatureWarning.js +14 -14
  117. package/lib/WarnCaseSensitiveModulesPlugin.js +27 -27
  118. package/lib/WatchIgnorePlugin.js +45 -45
  119. package/lib/WebpackOptionsApply.js +376 -376
  120. package/lib/WebpackOptionsDefaulter.js +112 -112
  121. package/lib/dependencies/AMDDefineDependency.js +63 -63
  122. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +240 -240
  123. package/lib/dependencies/AMDPlugin.js +115 -115
  124. package/lib/dependencies/AMDRequireArrayDependency.js +34 -34
  125. package/lib/dependencies/AMDRequireContextDependency.js +18 -18
  126. package/lib/dependencies/AMDRequireDependenciesBlock.js +25 -25
  127. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +145 -145
  128. package/lib/dependencies/AMDRequireDependency.js +64 -64
  129. package/lib/dependencies/AMDRequireItemDependency.js +17 -17
  130. package/lib/dependencies/CommonJsPlugin.js +93 -93
  131. package/lib/dependencies/CommonJsRequireContextDependency.js +18 -18
  132. package/lib/dependencies/CommonJsRequireDependency.js +17 -17
  133. package/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +91 -91
  134. package/lib/dependencies/ConstDependency.js +29 -29
  135. package/lib/dependencies/ContextDependency.js +24 -24
  136. package/lib/dependencies/ContextDependencyHelpers.js +34 -34
  137. package/lib/dependencies/ContextDependencyTemplateAsId.js +22 -22
  138. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +31 -31
  139. package/lib/dependencies/ContextElementDependency.js +17 -17
  140. package/lib/dependencies/DelegatedSourceDependency.js +14 -14
  141. package/lib/dependencies/DepBlockHelpers.js +41 -41
  142. package/lib/dependencies/DllEntryDependency.js +17 -17
  143. package/lib/dependencies/LabeledExportsDependency.js +21 -21
  144. package/lib/dependencies/LabeledModuleDependency.js +36 -36
  145. package/lib/dependencies/LabeledModuleDependencyParserPlugin.js +76 -76
  146. package/lib/dependencies/LabeledModulesPlugin.js +26 -26
  147. package/lib/dependencies/LoaderDependency.js +14 -14
  148. package/lib/dependencies/LoaderPlugin.js +61 -61
  149. package/lib/dependencies/LocalModule.js +19 -19
  150. package/lib/dependencies/LocalModuleDependency.js +23 -23
  151. package/lib/dependencies/LocalModulesHelpers.js +43 -43
  152. package/lib/dependencies/ModuleDependency.js +20 -20
  153. package/lib/dependencies/ModuleDependencyTemplateAsId.js +22 -22
  154. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +22 -22
  155. package/lib/dependencies/ModuleHotAcceptDependency.js +18 -18
  156. package/lib/dependencies/ModuleHotDeclineDependency.js +18 -18
  157. package/lib/dependencies/MultiEntryDependency.js +16 -16
  158. package/lib/dependencies/NullDependency.js +17 -17
  159. package/lib/dependencies/NullDependencyTemplate.js +8 -8
  160. package/lib/dependencies/PrefetchDependency.js +14 -14
  161. package/lib/dependencies/RequireContextDependency.js +17 -17
  162. package/lib/dependencies/RequireContextDependencyParserPlugin.js +33 -33
  163. package/lib/dependencies/RequireContextPlugin.js +64 -64
  164. package/lib/dependencies/RequireEnsureDependenciesBlock.js +20 -20
  165. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +66 -66
  166. package/lib/dependencies/RequireEnsureDependency.js +29 -29
  167. package/lib/dependencies/RequireEnsureItemDependency.js +16 -16
  168. package/lib/dependencies/RequireEnsurePlugin.js +38 -38
  169. package/lib/dependencies/RequireHeaderDependency.js +25 -25
  170. package/lib/dependencies/RequireIncludeDependency.js +25 -25
  171. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +18 -18
  172. package/lib/dependencies/RequireIncludePlugin.js +31 -31
  173. package/lib/dependencies/RequireResolveContextDependency.js +18 -18
  174. package/lib/dependencies/RequireResolveDependency.js +17 -17
  175. package/lib/dependencies/RequireResolveDependencyParserPlugin.js +69 -69
  176. package/lib/dependencies/RequireResolveHeaderDependency.js +25 -25
  177. package/lib/dependencies/SingleEntryDependency.js +14 -14
  178. package/lib/dependencies/TemplateArgumentDependency.js +26 -26
  179. package/lib/dependencies/WebpackMissingModule.js +23 -23
  180. package/lib/dependencies/getFunctionExpression.js +43 -43
  181. package/lib/node/NodeChunkTemplatePlugin.js +22 -22
  182. package/lib/node/NodeEnvironmentPlugin.js +25 -25
  183. package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +24 -24
  184. package/lib/node/NodeMainTemplate.runtime.js +20 -20
  185. package/lib/node/NodeMainTemplateAsync.runtime.js +34 -34
  186. package/lib/node/NodeMainTemplatePlugin.js +164 -164
  187. package/lib/node/NodeOutputFileSystem.js +17 -17
  188. package/lib/node/NodeSourcePlugin.js +85 -75
  189. package/lib/node/NodeTargetPlugin.js +12 -12
  190. package/lib/node/NodeTemplatePlugin.js +21 -21
  191. package/lib/node/NodeWatchFileSystem.js +65 -65
  192. package/lib/node/OldNodeWatchFileSystem.js +265 -265
  193. package/lib/optimize/AggressiveMergingPlugin.js +115 -115
  194. package/lib/optimize/CommonsChunkPlugin.js +178 -178
  195. package/lib/optimize/DedupePlugin.js +227 -227
  196. package/lib/optimize/FlagIncludedChunksPlugin.js +24 -24
  197. package/lib/optimize/LimitChunkCountPlugin.js +55 -55
  198. package/lib/optimize/MergeDuplicateChunksPlugin.js +30 -30
  199. package/lib/optimize/MinChunkSizePlugin.js +61 -61
  200. package/lib/optimize/OccurenceOrderPlugin.js +5 -5
  201. package/lib/optimize/OccurrenceOrderPlugin.js +91 -91
  202. package/lib/optimize/RemoveEmptyChunksPlugin.js +19 -19
  203. package/lib/optimize/RemoveParentModulesPlugin.js +50 -50
  204. package/lib/optimize/UglifyJsPlugin.js +146 -146
  205. package/lib/removeAndDo.js +13 -13
  206. package/lib/web/WebEnvironmentPlugin.js +16 -16
  207. package/lib/webpack.js +113 -113
  208. package/lib/webpack.web.js +27 -27
  209. package/lib/webworker/WebWorkerChunkTemplatePlugin.js +26 -26
  210. package/lib/webworker/WebWorkerMainTemplatePlugin.js +78 -78
  211. package/lib/webworker/WebWorkerTemplatePlugin.js +15 -15
  212. package/package.json +4 -4
@@ -1,93 +1,93 @@
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 ContextElementDependency = require("./dependencies/ContextElementDependency");
7
-
8
- function ContextReplacementPlugin(resourceRegExp, newContentResource, newContentRecursive, newContentRegExp) {
9
- this.resourceRegExp = resourceRegExp;
10
- if(typeof newContentResource === "function") {
11
- this.newContentCallback = newContentResource;
12
- } else if(typeof newContentResource === "string" && typeof newContentRecursive === "object") {
13
- this.newContentResource = newContentResource;
14
- this.newContentCreateContextMap = function(fs, callback) {
15
- callback(null, newContentRecursive)
16
- };
17
- } else if(typeof newContentResource === "string" && typeof newContentRecursive === "function") {
18
- this.newContentResource = newContentResource;
19
- this.newContentCreateContextMap = newContentRecursive;
20
- } else {
21
- if(typeof newContentResource !== "string") {
22
- newContentRegExp = newContentRecursive;
23
- newContentRecursive = newContentResource;
24
- newContentResource = undefined;
25
- }
26
- if(typeof newContentRecursive !== "boolean") {
27
- newContentRegExp = newContentRecursive;
28
- newContentRecursive = undefined;
29
- }
30
- this.newContentResource = newContentResource;
31
- this.newContentRecursive = newContentRecursive;
32
- this.newContentRegExp = newContentRegExp;
33
- }
34
- }
35
- module.exports = ContextReplacementPlugin;
36
- ContextReplacementPlugin.prototype.apply = function(compiler) {
37
- var resourceRegExp = this.resourceRegExp;
38
- var newContentCallback = this.newContentCallback;
39
- var newContentResource = this.newContentResource;
40
- var newContentRecursive = this.newContentRecursive;
41
- var newContentRegExp = this.newContentRegExp;
42
- var newContentCreateContextMap = this.newContentCreateContextMap;
43
- compiler.plugin("context-module-factory", function(cmf) {
44
- cmf.plugin("before-resolve", function(result, callback) {
45
- if(!result) return callback();
46
- if(resourceRegExp.test(result.request)) {
47
- if(typeof newContentResource !== "undefined")
48
- result.request = newContentResource;
49
- if(typeof newContentRecursive !== "undefined")
50
- result.recursive = newContentRecursive;
51
- if(typeof newContentRegExp !== "undefined")
52
- result.regExp = newContentRegExp;
53
- if(typeof newContentCallback === "function") {
54
- newContentCallback(result);
55
- }
56
- }
57
- return callback(null, result);
58
- });
59
- cmf.plugin("after-resolve", function(result, callback) {
60
- if(!result) return callback();
61
- if(resourceRegExp.test(result.resource)) {
62
- if(typeof newContentResource !== "undefined")
63
- result.resource = path.resolve(result.resource, newContentResource);
64
- if(typeof newContentRecursive !== "undefined")
65
- result.recursive = newContentRecursive;
66
- if(typeof newContentRegExp !== "undefined")
67
- result.regExp = newContentRegExp;
68
- if(typeof newContentCreateContextMap === "function")
69
- result.resolveDependencies = createResolveDependenciesFromContextMap(newContentCreateContextMap);
70
- if(typeof newContentCallback === "function") {
71
- var origResource = result.resource;
72
- newContentCallback(result);
73
- if(result.resource !== origResource) {
74
- result.resource = path.resolve(origResource, result.resource);
75
- }
76
- }
77
- }
78
- return callback(null, result);
79
- });
80
- });
81
- };
82
-
83
- function createResolveDependenciesFromContextMap(createContextMap) {
84
- return function resolveDependenciesFromContextMap(fs, resource, recursive, regExp, callback) {
85
- createContextMap(fs, function(err, map) {
86
- if(err) return callback(err);
87
- var dependencies = Object.keys(map).map(function(key) {
88
- return new ContextElementDependency(map[key], key);
89
- });
90
- callback(null, dependencies);
91
- });
92
- }
93
- };
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 ContextElementDependency = require("./dependencies/ContextElementDependency");
7
+
8
+ function ContextReplacementPlugin(resourceRegExp, newContentResource, newContentRecursive, newContentRegExp) {
9
+ this.resourceRegExp = resourceRegExp;
10
+ if(typeof newContentResource === "function") {
11
+ this.newContentCallback = newContentResource;
12
+ } else if(typeof newContentResource === "string" && typeof newContentRecursive === "object") {
13
+ this.newContentResource = newContentResource;
14
+ this.newContentCreateContextMap = function(fs, callback) {
15
+ callback(null, newContentRecursive)
16
+ };
17
+ } else if(typeof newContentResource === "string" && typeof newContentRecursive === "function") {
18
+ this.newContentResource = newContentResource;
19
+ this.newContentCreateContextMap = newContentRecursive;
20
+ } else {
21
+ if(typeof newContentResource !== "string") {
22
+ newContentRegExp = newContentRecursive;
23
+ newContentRecursive = newContentResource;
24
+ newContentResource = undefined;
25
+ }
26
+ if(typeof newContentRecursive !== "boolean") {
27
+ newContentRegExp = newContentRecursive;
28
+ newContentRecursive = undefined;
29
+ }
30
+ this.newContentResource = newContentResource;
31
+ this.newContentRecursive = newContentRecursive;
32
+ this.newContentRegExp = newContentRegExp;
33
+ }
34
+ }
35
+ module.exports = ContextReplacementPlugin;
36
+ ContextReplacementPlugin.prototype.apply = function(compiler) {
37
+ var resourceRegExp = this.resourceRegExp;
38
+ var newContentCallback = this.newContentCallback;
39
+ var newContentResource = this.newContentResource;
40
+ var newContentRecursive = this.newContentRecursive;
41
+ var newContentRegExp = this.newContentRegExp;
42
+ var newContentCreateContextMap = this.newContentCreateContextMap;
43
+ compiler.plugin("context-module-factory", function(cmf) {
44
+ cmf.plugin("before-resolve", function(result, callback) {
45
+ if(!result) return callback();
46
+ if(resourceRegExp.test(result.request)) {
47
+ if(typeof newContentResource !== "undefined")
48
+ result.request = newContentResource;
49
+ if(typeof newContentRecursive !== "undefined")
50
+ result.recursive = newContentRecursive;
51
+ if(typeof newContentRegExp !== "undefined")
52
+ result.regExp = newContentRegExp;
53
+ if(typeof newContentCallback === "function") {
54
+ newContentCallback(result);
55
+ }
56
+ }
57
+ return callback(null, result);
58
+ });
59
+ cmf.plugin("after-resolve", function(result, callback) {
60
+ if(!result) return callback();
61
+ if(resourceRegExp.test(result.resource)) {
62
+ if(typeof newContentResource !== "undefined")
63
+ result.resource = path.resolve(result.resource, newContentResource);
64
+ if(typeof newContentRecursive !== "undefined")
65
+ result.recursive = newContentRecursive;
66
+ if(typeof newContentRegExp !== "undefined")
67
+ result.regExp = newContentRegExp;
68
+ if(typeof newContentCreateContextMap === "function")
69
+ result.resolveDependencies = createResolveDependenciesFromContextMap(newContentCreateContextMap);
70
+ if(typeof newContentCallback === "function") {
71
+ var origResource = result.resource;
72
+ newContentCallback(result);
73
+ if(result.resource !== origResource) {
74
+ result.resource = path.resolve(origResource, result.resource);
75
+ }
76
+ }
77
+ }
78
+ return callback(null, result);
79
+ });
80
+ });
81
+ };
82
+
83
+ function createResolveDependenciesFromContextMap(createContextMap) {
84
+ return function resolveDependenciesFromContextMap(fs, resource, recursive, regExp, callback) {
85
+ createContextMap(fs, function(err, map) {
86
+ if(err) return callback(err);
87
+ var dependencies = Object.keys(map).map(function(key) {
88
+ return new ContextElementDependency(map[key], key);
89
+ });
90
+ callback(null, dependencies);
91
+ });
92
+ }
93
+ };
@@ -1,24 +1,24 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
- function CriticalDependenciesWarning(module, dependencies) {
6
- Error.call(this);
7
- Error.captureStackTrace(this, CriticalDependenciesWarning);
8
- this.name = "CriticalDependenciesWarning";
9
- this.message = "Critical dependencies:";
10
- this.message += dependencies.filter(function(d) {
11
- return typeof d.critical === "string" || d.loc;
12
- }).map(function(dep) {
13
- var line = [];
14
- if(dep.loc) line.push(dep.loc.start.line + ":" + dep.loc.start.column + "-" +
15
- (dep.loc.start.line !== dep.loc.end.line ? dep.loc.end.line + ":" : "") + dep.loc.end.column);
16
- if(typeof dep.critical === "string") line.push(dep.critical);
17
- return "\n" + line.join(" ");
18
- }).join("");
19
- this.dependencies = dependencies;
20
- this.origin = this.module = module;
21
- }
22
- module.exports = CriticalDependenciesWarning;
23
-
24
- CriticalDependenciesWarning.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 CriticalDependenciesWarning(module, dependencies) {
6
+ Error.call(this);
7
+ Error.captureStackTrace(this, CriticalDependenciesWarning);
8
+ this.name = "CriticalDependenciesWarning";
9
+ this.message = "Critical dependencies:";
10
+ this.message += dependencies.filter(function(d) {
11
+ return typeof d.critical === "string" || d.loc;
12
+ }).map(function(dep) {
13
+ var line = [];
14
+ if(dep.loc) line.push(dep.loc.start.line + ":" + dep.loc.start.column + "-" +
15
+ (dep.loc.start.line !== dep.loc.end.line ? dep.loc.end.line + ":" : "") + dep.loc.end.column);
16
+ if(typeof dep.critical === "string") line.push(dep.critical);
17
+ return "\n" + line.join(" ");
18
+ }).join("");
19
+ this.dependencies = dependencies;
20
+ this.origin = this.module = module;
21
+ }
22
+ module.exports = CriticalDependenciesWarning;
23
+
24
+ CriticalDependenciesWarning.prototype = Object.create(Error.prototype);
@@ -1,126 +1,126 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
- var ConstDependency = require("./dependencies/ConstDependency");
6
- var BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
7
-
8
- var NullFactory = require("./NullFactory");
9
-
10
- function DefinePlugin(definitions) {
11
- this.definitions = definitions;
12
- }
13
- module.exports = DefinePlugin;
14
- DefinePlugin.prototype.apply = function(compiler) {
15
- compiler.plugin("compilation", function(compilation) {
16
- compilation.dependencyFactories.set(ConstDependency, new NullFactory());
17
- 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
-
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
- }
38
-
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
- }
47
-
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
- }
57
-
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
- }
101
-
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;
124
- });
125
- }
126
- };
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ var ConstDependency = require("./dependencies/ConstDependency");
6
+ var BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
7
+
8
+ var NullFactory = require("./NullFactory");
9
+
10
+ function DefinePlugin(definitions) {
11
+ this.definitions = definitions;
12
+ }
13
+ module.exports = DefinePlugin;
14
+ DefinePlugin.prototype.apply = function(compiler) {
15
+ compiler.plugin("compilation", function(compilation) {
16
+ compilation.dependencyFactories.set(ConstDependency, new NullFactory());
17
+ 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
+
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
+ }
38
+
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
+ }
47
+
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
+ }
57
+
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
+ }
101
+
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;
124
+ });
125
+ }
126
+ };
@@ -1,69 +1,69 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
- var Module = require("./Module");
6
- var OriginalSource = require("webpack-core/lib/OriginalSource");
7
- var RawSource = require("webpack-core/lib/RawSource");
8
- var WebpackMissingModule = require("./dependencies/WebpackMissingModule");
9
- var DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
10
-
11
- function DelegatedModule(sourceRequest, request, type, userRequest) {
12
- Module.call(this);
13
- this.sourceRequest = sourceRequest;
14
- this.request = request;
15
- this.type = type;
16
- this.userRequest = userRequest;
17
- this.built = false;
18
- }
19
- module.exports = DelegatedModule;
20
-
21
- DelegatedModule.prototype = Object.create(Module.prototype);
22
-
23
- DelegatedModule.prototype.delegated = true;
24
-
25
- DelegatedModule.prototype.identifier = function() {
26
- return "delegated " + JSON.stringify(this.request) + " from " + this.sourceRequest;
27
- };
28
-
29
- DelegatedModule.prototype.readableIdentifier = function() {
30
- return "delegated " + this.userRequest + " from " + this.sourceRequest;
31
- };
32
-
33
- DelegatedModule.prototype.needRebuild = function() {
34
- return false;
35
- };
36
-
37
- DelegatedModule.prototype.build = function(options, compilation, resolver, fs, callback) {
38
- this.builtTime = new Date().getTime();
39
- this.dependencies.length = 0;
40
- this.addDependency(new DelegatedSourceDependency(this.sourceRequest));
41
- callback();
42
- };
43
-
44
- DelegatedModule.prototype.source = function() {
45
- var sourceModule = this.dependencies[0].module;
46
- var str;
47
- if(!sourceModule) {
48
- str = WebpackMissingModule.moduleCode(this.sourceRequest);
49
- } else {
50
- str = "module.exports = (__webpack_require__(" + sourceModule.id + "))";
51
- switch(this.type) {
52
- case "require":
53
- str += "(" + JSON.stringify(this.request) + ");";
54
- break;
55
- case "object":
56
- str += "[" + JSON.stringify(this.request) + "];";
57
- break;
58
- }
59
- }
60
- if(this.useSourceMap) {
61
- return new OriginalSource(str, this.identifier());
62
- } else {
63
- return new RawSource(str);
64
- }
65
- };
66
-
67
- DelegatedModule.prototype.size = function() {
68
- return 42;
69
- };
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ var Module = require("./Module");
6
+ var OriginalSource = require("webpack-core/lib/OriginalSource");
7
+ var RawSource = require("webpack-core/lib/RawSource");
8
+ var WebpackMissingModule = require("./dependencies/WebpackMissingModule");
9
+ var DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
10
+
11
+ function DelegatedModule(sourceRequest, request, type, userRequest) {
12
+ Module.call(this);
13
+ this.sourceRequest = sourceRequest;
14
+ this.request = request;
15
+ this.type = type;
16
+ this.userRequest = userRequest;
17
+ this.built = false;
18
+ }
19
+ module.exports = DelegatedModule;
20
+
21
+ DelegatedModule.prototype = Object.create(Module.prototype);
22
+
23
+ DelegatedModule.prototype.delegated = true;
24
+
25
+ DelegatedModule.prototype.identifier = function() {
26
+ return "delegated " + JSON.stringify(this.request) + " from " + this.sourceRequest;
27
+ };
28
+
29
+ DelegatedModule.prototype.readableIdentifier = function() {
30
+ return "delegated " + this.userRequest + " from " + this.sourceRequest;
31
+ };
32
+
33
+ DelegatedModule.prototype.needRebuild = function() {
34
+ return false;
35
+ };
36
+
37
+ DelegatedModule.prototype.build = function(options, compilation, resolver, fs, callback) {
38
+ this.builtTime = new Date().getTime();
39
+ this.dependencies.length = 0;
40
+ this.addDependency(new DelegatedSourceDependency(this.sourceRequest));
41
+ callback();
42
+ };
43
+
44
+ DelegatedModule.prototype.source = function() {
45
+ var sourceModule = this.dependencies[0].module;
46
+ var str;
47
+ if(!sourceModule) {
48
+ str = WebpackMissingModule.moduleCode(this.sourceRequest);
49
+ } else {
50
+ str = "module.exports = (__webpack_require__(" + sourceModule.id + "))";
51
+ switch(this.type) {
52
+ case "require":
53
+ str += "(" + JSON.stringify(this.request) + ");";
54
+ break;
55
+ case "object":
56
+ str += "[" + JSON.stringify(this.request) + "];";
57
+ break;
58
+ }
59
+ }
60
+ if(this.useSourceMap) {
61
+ return new OriginalSource(str, this.identifier());
62
+ } else {
63
+ return new RawSource(str);
64
+ }
65
+ };
66
+
67
+ DelegatedModule.prototype.size = function() {
68
+ return 42;
69
+ };