webpack 2.6.1 → 2.7.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.
@@ -10,7 +10,7 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
10
10
  class EvalSourceMapDevToolModuleTemplatePlugin {
11
11
  constructor(compilation, options) {
12
12
  this.compilation = compilation;
13
- this.sourceMapComment = options.append || "//# sourceMappingURL=[url]";
13
+ this.sourceMapComment = options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]";
14
14
  this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack:///[resource-path]?[hash]";
15
15
  this.options = options;
16
16
  }
@@ -61,13 +61,14 @@ class EvalSourceMapDevToolModuleTemplatePlugin {
61
61
  sourceMap.sourceRoot = options.sourceRoot || "";
62
62
  sourceMap.file = `${module.id}.js`;
63
63
 
64
- const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")}`); //eslint-disable-line
64
+ const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")}`) + //eslint-disable-line
65
+ `\n//# sourceURL=webpack-internal:///${module.id}\n`; // workaround for chrome bug
65
66
  source.__EvalSourceMapDevToolData = new RawSource(`eval(${JSON.stringify(content + footer)});`);
66
67
  return source.__EvalSourceMapDevToolData;
67
68
  });
68
69
  moduleTemplate.plugin("hash", function(hash) {
69
70
  hash.update("eval-source-map");
70
- hash.update("1");
71
+ hash.update("2");
71
72
  });
72
73
  }
73
74
  }
@@ -5,6 +5,7 @@
5
5
  "use strict";
6
6
 
7
7
  const path = require("path");
8
+ const crypto = require("crypto");
8
9
  const RequestShortener = require("./RequestShortener");
9
10
  const ConcatSource = require("webpack-sources").ConcatSource;
10
11
  const RawSource = require("webpack-sources").RawSource;
@@ -131,6 +132,7 @@ class SourceMapDevToolPlugin {
131
132
  if(currentSourceMappingURLComment !== false && /\.css($|\?)/i.test(file)) {
132
133
  currentSourceMappingURLComment = currentSourceMappingURLComment.replace(/^\n\/\/(.*)$/, "\n/*$1*/");
133
134
  }
135
+ const sourceMapString = JSON.stringify(sourceMap);
134
136
  if(sourceMapFilename) {
135
137
  let filename = file;
136
138
  let query = "";
@@ -139,22 +141,25 @@ class SourceMapDevToolPlugin {
139
141
  query = filename.substr(idx);
140
142
  filename = filename.substr(0, idx);
141
143
  }
142
- const sourceMapFile = compilation.getPath(sourceMapFilename, {
144
+ let sourceMapFile = compilation.getPath(sourceMapFilename, {
143
145
  chunk,
144
146
  filename,
145
147
  query,
146
148
  basename: basename(filename)
147
149
  });
150
+ if(sourceMapFile.indexOf("[contenthash]") !== -1) {
151
+ sourceMapFile = sourceMapFile.replace(/\[contenthash\]/g, crypto.createHash("md5").update(sourceMapString).digest("hex"));
152
+ }
148
153
  const sourceMapUrl = path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/");
149
154
  if(currentSourceMappingURLComment !== false) {
150
155
  asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment.replace(/\[url\]/g, sourceMapUrl));
151
156
  }
152
- asset.__SourceMapDevToolData[sourceMapFile] = compilation.assets[sourceMapFile] = new RawSource(JSON.stringify(sourceMap));
157
+ asset.__SourceMapDevToolData[sourceMapFile] = compilation.assets[sourceMapFile] = new RawSource(sourceMapString);
153
158
  chunk.files.push(sourceMapFile);
154
159
  } else {
155
160
  asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment
156
- .replace(/\[map\]/g, () => JSON.stringify(sourceMap))
157
- .replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf-8").toString("base64")}`) // eslint-disable-line
161
+ .replace(/\[map\]/g, () => sourceMapString)
162
+ .replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${new Buffer(sourceMapString, "utf-8").toString("base64")}`) // eslint-disable-line
158
163
  );
159
164
  }
160
165
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "2.6.1",
3
+ "version": "2.7.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, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "dependencies": {
@@ -9,7 +9,7 @@
9
9
  "ajv": "^4.7.0",
10
10
  "ajv-keywords": "^1.1.1",
11
11
  "async": "^2.1.2",
12
- "enhanced-resolve": "^3.0.0",
12
+ "enhanced-resolve": "^3.3.0",
13
13
  "interpret": "^1.0.0",
14
14
  "json-loader": "^0.5.4",
15
15
  "json5": "^0.5.1",
@@ -23,7 +23,7 @@
23
23
  "tapable": "~0.2.5",
24
24
  "uglify-js": "^2.8.27",
25
25
  "watchpack": "^1.3.1",
26
- "webpack-sources": "^0.2.3",
26
+ "webpack-sources": "^1.0.1",
27
27
  "yargs": "^6.0.0"
28
28
  },
29
29
  "license": "MIT",
@@ -88,13 +88,13 @@
88
88
  "schemas/"
89
89
  ],
90
90
  "scripts": {
91
- "test": "mocha test/*.test.js --harmony --check-leaks",
91
+ "test": "mocha test/*.test.js --max_old_space_size=4096 --harmony --check-leaks",
92
92
  "travis:test": "npm run cover:min",
93
93
  "travis:lint": "npm run lint-files && npm run nsp",
94
94
  "travis:benchmark": "npm run benchmark",
95
- "appveyor:test": "node --max_old_space_size=4096 node_modules\\mocha\\bin\\mocha --harmony test/*.test.js",
95
+ "appveyor:test": "node node_modules\\mocha\\bin\\mocha --max_old_space_size=4096 --harmony test/*.test.js",
96
96
  "appveyor:benchmark": "npm run benchmark",
97
- "circleci:test": "node --max_old_space_size=4096 node_modules/mocha/bin/mocha --harmony test/*.test.js",
97
+ "circleci:test": "node node_modules/mocha/bin/mocha --max_old_space_size=4096 --harmony test/*.test.js",
98
98
  "circleci:lint": "npm run lint-files && npm run nsp",
99
99
  "build:examples": "cd examples && node buildAll.js",
100
100
  "pretest": "npm run lint-files",
@@ -102,9 +102,9 @@
102
102
  "lint": "eslint lib bin hot buildin \"test/**/webpack.config.js\" \"test/binCases/**/test.js\" \"examples/**/webpack.config.js\"",
103
103
  "beautify-lint": "beautify-lint \"lib/**/*.js\" \"hot/**/*.js\" \"bin/**/*.js\" \"benchmark/*.js\" \"test/*.js\"",
104
104
  "nsp": "nsp check --output summary",
105
- "benchmark": "mocha test/*.benchmark.js --harmony -R spec",
106
- "cover": "node --harmony ./node_modules/istanbul/lib/cli.js cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha -- test/*.test.js",
107
- "cover:min": "node --harmony ./node_modules/.bin/istanbul cover -x '**/*.runtime.js' --report lcovonly node_modules/mocha/bin/_mocha -- test/*.test.js",
105
+ "benchmark": "mocha --max_old_space_size=4096 --harmony test/*.benchmark.js -R spec",
106
+ "cover": "node --max_old_space_size=4096 --harmony ./node_modules/istanbul/lib/cli.js cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha -- test/*.test.js",
107
+ "cover:min": "node --max_old_space_size=4096 --harmony ./node_modules/.bin/istanbul cover -x '**/*.runtime.js' --report lcovonly node_modules/mocha/bin/_mocha -- test/*.test.js",
108
108
  "publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish"
109
109
  }
110
110
  }
@@ -459,6 +459,9 @@
459
459
  "cachePredicate": {
460
460
  "instanceof": "Function"
461
461
  },
462
+ "cacheWithContext": {
463
+ "type": "boolean"
464
+ },
462
465
  "descriptionFiles": {
463
466
  "$ref": "#/definitions/common.arrayOfStringValues"
464
467
  },