webpack 1.13.0 → 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.
@@ -57,7 +57,7 @@ EvalSourceMapDevToolModuleTemplatePlugin.prototype.apply = function(moduleTempla
57
57
  }
58
58
  sourceMap.sourceRoot = "";
59
59
  sourceMap.file = module.id + ".js";
60
- var footer = self.sourceMapComment.replace(/\[url\]/g, "data:application/json;base64," + new Buffer(JSON.stringify(sourceMap)).toString("base64"));
60
+ var footer = self.sourceMapComment.replace(/\[url\]/g, "data:application/json;charset=utf-8;base64," + new Buffer(JSON.stringify(sourceMap)).toString("base64"));
61
61
  source.__EvalSourceMapDevToolData = new RawSource("eval(" + JSON.stringify(content + footer) + ");");
62
62
  return source.__EvalSourceMapDevToolData;
63
63
  });
@@ -96,20 +96,18 @@ ModuleFilenameHelpers.createFooter = function createFooter(module, requestShorte
96
96
  if(!module) module = "";
97
97
  if(typeof module === "string") {
98
98
  return [
99
- "/** WEBPACK FOOTER **",
100
- " ** " + requestShortener.shorten(module),
101
- " **/"
99
+ "// WEBPACK FOOTER //",
100
+ "// " + requestShortener.shorten(module)
102
101
  ].join("\n");
103
102
  } else {
104
103
  return [
105
- "/*****************",
106
- " ** WEBPACK FOOTER",
107
- " ** " + module.readableIdentifier(requestShortener),
108
- " ** module id = " + module.id,
109
- " ** module chunks = " + module.chunks.map(function(c) {
104
+ "//////////////////",
105
+ "// WEBPACK FOOTER",
106
+ "// " + module.readableIdentifier(requestShortener),
107
+ "// module id = " + module.id,
108
+ "// module chunks = " + module.chunks.map(function(c) {
110
109
  return c.id;
111
- }).join(" "),
112
- " **/"
110
+ }).join(" ")
113
111
  ].join("\n");
114
112
  }
115
113
  };
@@ -152,7 +152,7 @@ SourceMapDevToolPlugin.prototype.apply = function(compiler) {
152
152
  return JSON.stringify(sourceMap);
153
153
  })
154
154
  .replace(/\[url\]/g, function() {
155
- return "data:application/json;base64," +
155
+ return "data:application/json;charset=utf-8;base64," +
156
156
  new Buffer(JSON.stringify(sourceMap)).toString("base64");
157
157
  })
158
158
  );
@@ -25,11 +25,11 @@ DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, reque
25
25
  "if(--__WEBPACK_REMAINING_CHUNKS__ < 1) (",
26
26
 
27
27
  "(__webpack_require__));" +
28
- "};" +
28
+ "}.bind(this);" +
29
29
  chunks.map(function(chunk) {
30
30
  return "__webpack_require__.e(" + chunk.id + ", __WEBPACK_CALLBACK__);";
31
31
  }).join("") +
32
- "}())"
32
+ "}).call(this)"
33
33
  ];
34
34
  }
35
35
  }
@@ -5,12 +5,31 @@
5
5
  var ModuleAliasPlugin = require("enhanced-resolve/lib/ModuleAliasPlugin");
6
6
  var ModuleParserHelpers = require("../ModuleParserHelpers");
7
7
  var nodeLibsBrowser = require("node-libs-browser");
8
+ var path = require("path");
8
9
 
9
10
  function NodeSourcePlugin(options) {
10
11
  this.options = options;
11
12
  }
12
13
  module.exports = NodeSourcePlugin;
13
14
  NodeSourcePlugin.prototype.apply = function(compiler) {
15
+ var parser = compiler.parser;
16
+
17
+ function buildExpression(context, pathToModule) {
18
+ var moduleJsPath = path.relative(context, pathToModule);
19
+ if(!/^[A-Z]:/i.test(moduleJsPath)) {
20
+ moduleJsPath = "./" + moduleJsPath.replace(/\\/g, "/");
21
+ }
22
+ return "require(" + JSON.stringify(moduleJsPath) + ")";
23
+ }
24
+
25
+ function addExpression(parser, name, module, type, suffix) {
26
+ suffix = suffix || "";
27
+ parser.plugin("expression " + name, function() {
28
+ if(this.state.module && this.state.module.resource === getPathToModule(module, type)) return;
29
+ return ModuleParserHelpers.addParsedVariable(this, name, buildExpression(this.state.module.context, getPathToModule(module, type)) + suffix);
30
+ });
31
+ }
32
+
14
33
  function getPathToModule(module, type) {
15
34
  if(type === true || (type === undefined && nodeLibsBrowser[module])) {
16
35
  if(!nodeLibsBrowser[module]) throw new Error("No browser version for node.js core module '" + module + "' available");
@@ -21,23 +40,20 @@ NodeSourcePlugin.prototype.apply = function(compiler) {
21
40
  return require.resolve("node-libs-browser/mock/empty");
22
41
  } else return module;
23
42
  }
24
- if(this.options.process) {
25
- var processType = this.options.process;
26
- compiler.parser.plugin("expression process", function() {
27
- return ModuleParserHelpers.addParsedVariable(this, "process", "require(" + JSON.stringify(getPathToModule("process", processType)) + ")");
28
- });
29
- }
43
+
30
44
  if(this.options.global) {
31
45
  compiler.parser.plugin("expression global", function() {
32
46
  this.state.module.addVariable("global", "(function() { return this; }())");
33
47
  return true;
34
48
  });
35
49
  }
50
+ if(this.options.process) {
51
+ var processType = this.options.process;
52
+ addExpression(parser, "process", "process", processType);
53
+ }
36
54
  if(this.options.console) {
37
55
  var consoleType = this.options.console;
38
- compiler.parser.plugin("expression console", function() {
39
- return ModuleParserHelpers.addParsedVariable(this, "console", "require(" + JSON.stringify(getPathToModule("console", consoleType)) + ")");
40
- });
56
+ addExpression(parser, "console", "console", consoleType);
41
57
  }
42
58
  var bufferType = this.options.Buffer;
43
59
  if(typeof bufferType === "undefined") {
@@ -46,18 +62,12 @@ NodeSourcePlugin.prototype.apply = function(compiler) {
46
62
  bufferType = true;
47
63
  }
48
64
  if(bufferType) {
49
- compiler.parser.plugin("expression Buffer", function() {
50
- return ModuleParserHelpers.addParsedVariable(this, "Buffer", "require(" + JSON.stringify(getPathToModule("buffer", bufferType)) + ").Buffer");
51
- });
65
+ addExpression(parser, "Buffer", "buffer", bufferType, ".Buffer");
52
66
  }
53
67
  if(this.options.setImmediate) {
54
68
  var setImmediateType = this.options.setImmediate;
55
- compiler.parser.plugin("expression setImmediate", function() {
56
- return ModuleParserHelpers.addParsedVariable(this, "setImmediate", "require(" + JSON.stringify(getPathToModule("timers", setImmediateType)) + ").setImmediate");
57
- });
58
- compiler.parser.plugin("expression clearImmediate", function() {
59
- return ModuleParserHelpers.addParsedVariable(this, "clearImmediate", "require(" + JSON.stringify(getPathToModule("timers", setImmediateType)) + ").clearImmediate");
60
- });
69
+ addExpression(parser, "setImmediate", "timers", setImmediateType, ".setImmediate");
70
+ addExpression(parser, "clearImmediate", "timers", setImmediateType, ".clearImmediate");
61
71
  }
62
72
  var options = this.options;
63
73
  compiler.plugin("after-resolvers", function(compiler) {
package/lib/webpack.js CHANGED
@@ -28,7 +28,10 @@ function webpack(options, callback) {
28
28
  }
29
29
  if(callback) {
30
30
  if(typeof callback !== "function") throw new Error("Invalid argument: callback");
31
- if(options.watch === true) {
31
+ if(options.watch === true || (Array.isArray(options) &&
32
+ options.some(function(o) {
33
+ return o.watch;
34
+ }))) {
32
35
  var watchOptions = (!Array.isArray(options) ? options : options[0]).watchOptions || {};
33
36
  // TODO remove this in next major version
34
37
  var watchDelay = (!Array.isArray(options) ? options : options[0]).watchDelay;
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
6
6
  "dependencies": {
7
+ "acorn": "^3.0.0",
7
8
  "async": "^1.3.0",
8
9
  "clone": "^1.0.2",
9
10
  "enhanced-resolve": "~0.9.0",
10
- "acorn": "^3.0.0",
11
11
  "interpret": "^0.6.4",
12
12
  "loader-utils": "^0.2.11",
13
13
  "memory-fs": "~0.3.0",
14
14
  "mkdirp": "~0.5.0",
15
- "node-libs-browser": ">= 0.4.0 <=0.6.0",
15
+ "node-libs-browser": "^0.7.0",
16
16
  "optimist": "~0.6.0",
17
17
  "supports-color": "^3.1.0",
18
18
  "tapable": "~0.1.8",
19
- "uglify-js": "~2.6.0",
19
+ "uglify-js": "~2.7.3",
20
20
  "watchpack": "^0.2.1",
21
- "webpack-core": "~0.6.0"
21
+ "webpack-core": "~0.6.9"
22
22
  },
23
23
  "license": "MIT",
24
24
  "devDependencies": {
@@ -83,7 +83,7 @@
83
83
  "beautify-lint": "node ./scripts/beautify-check",
84
84
  "beautify": "node ./scripts/beautify-rewrite",
85
85
  "precover": "npm run lint && npm run beautify-lint",
86
- "cover": "istanbul cover -x *.runtime.js node_modules/mocha/bin/_mocha",
86
+ "cover": "istanbul cover -x **/*.runtime.js node_modules/mocha/bin/_mocha",
87
87
  "publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish"
88
88
  }
89
89
  }