From 9c1ab27c044d5854e00bd8eb6383d02ebb42b8ff Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 1 Jun 2017 11:16:12 +0200 Subject: [PATCH 01/12] more memory for the tests --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1e0ca0ea21c..a2deb4f5e70 100644 --- a/package.json +++ b/package.json @@ -88,13 +88,13 @@ "schemas/" ], "scripts": { - "test": "mocha test/*.test.js --harmony --check-leaks", + "test": "mocha test/*.test.js --max_old_space_size=4096 --harmony --check-leaks", "travis:test": "npm run cover:min", "travis:lint": "npm run lint-files && npm run nsp", "travis:benchmark": "npm run benchmark", - "appveyor:test": "node --max_old_space_size=4096 node_modules\\mocha\\bin\\mocha --harmony test/*.test.js", + "appveyor:test": "node node_modules\\mocha\\bin\\mocha --max_old_space_size=4096 --harmony test/*.test.js", "appveyor:benchmark": "npm run benchmark", - "circleci:test": "node --max_old_space_size=4096 node_modules/mocha/bin/mocha --harmony test/*.test.js", + "circleci:test": "node node_modules/mocha/bin/mocha --max_old_space_size=4096 --harmony test/*.test.js", "circleci:lint": "npm run lint-files && npm run nsp", "build:examples": "cd examples && node buildAll.js", "pretest": "npm run lint-files", @@ -102,9 +102,9 @@ "lint": "eslint lib bin hot buildin \"test/**/webpack.config.js\" \"test/binCases/**/test.js\" \"examples/**/webpack.config.js\"", "beautify-lint": "beautify-lint \"lib/**/*.js\" \"hot/**/*.js\" \"bin/**/*.js\" \"benchmark/*.js\" \"test/*.js\"", "nsp": "nsp check --output summary", - "benchmark": "mocha test/*.benchmark.js --harmony -R spec", - "cover": "node --harmony ./node_modules/istanbul/lib/cli.js cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha -- test/*.test.js", - "cover:min": "node --harmony ./node_modules/.bin/istanbul cover -x '**/*.runtime.js' --report lcovonly node_modules/mocha/bin/_mocha -- test/*.test.js", + "benchmark": "mocha --max_old_space_size=4096 --harmony test/*.benchmark.js -R spec", + "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", + "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", "publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish" } } From 6752a9cb7eb846ab7340d2ac8f9469974ea9303e Mon Sep 17 00:00:00 2001 From: Rafael De Leon Date: Fri, 2 Jun 2017 09:05:25 -0700 Subject: [PATCH 02/12] Enable use of sourceMapFilename: "[file].map?[contenthash]" as a useful workaround for this bug in chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=508270 --- lib/SourceMapDevToolPlugin.js | 6 +++++- .../source-map-filename-contenthash/index.js | 6 ++++++ .../webpack.config.js | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/configCases/source-map/source-map-filename-contenthash/index.js create mode 100644 test/configCases/source-map/source-map-filename-contenthash/webpack.config.js diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index ba16715a7fb..e375110fabe 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -5,6 +5,7 @@ "use strict"; const path = require("path"); +const crypto = require("crypto"); const RequestShortener = require("./RequestShortener"); const ConcatSource = require("webpack-sources").ConcatSource; const RawSource = require("webpack-sources").RawSource; @@ -145,7 +146,10 @@ class SourceMapDevToolPlugin { query, basename: basename(filename) }); - const sourceMapUrl = path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/"); + let sourceMapUrl = path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/"); + if(sourceMapUrl.indexOf("[contenthash]") !== -1) { + sourceMapUrl = sourceMapUrl.replace(/\[contenthash\]/g, crypto.createHash("md5").update(source).digest("hex")); + } if(currentSourceMappingURLComment !== false) { asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment.replace(/\[url\]/g, sourceMapUrl)); } diff --git a/test/configCases/source-map/source-map-filename-contenthash/index.js b/test/configCases/source-map/source-map-filename-contenthash/index.js new file mode 100644 index 00000000000..455b624c9f2 --- /dev/null +++ b/test/configCases/source-map/source-map-filename-contenthash/index.js @@ -0,0 +1,6 @@ +it("should contain contenthash as query parameter and path", function() { + var fs = require("fs"); + var source = fs.readFileSync(__filename, "utf-8"); + var match = /sourceMappingURL\s*=.*-([A-Fa-f0-9]{32})\.map\?([A-Fa-f0-9]{32})-([A-Fa-f0-9]{32})/.exec(source); + match.length.should.be.eql(4); +}); diff --git a/test/configCases/source-map/source-map-filename-contenthash/webpack.config.js b/test/configCases/source-map/source-map-filename-contenthash/webpack.config.js new file mode 100644 index 00000000000..9671d5a8c90 --- /dev/null +++ b/test/configCases/source-map/source-map-filename-contenthash/webpack.config.js @@ -0,0 +1,16 @@ +var webpack = require("../../../../"); +module.exports = { + node: { + __dirname: false, + __filename: false + }, + devtool: "source-map", + output: { + sourceMapFilename: "[file]-[contenthash].map?[contenthash]-[contenthash]", + }, + plugins: [ + new webpack.optimize.UglifyJsPlugin({ + sourceMap: true + }) + ] +}; From 0af1b7a265d42c8e98a15d036573044d2494b15d Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 5 Jun 2017 08:49:09 +0200 Subject: [PATCH 03/12] fixup for source-map contenthash --- lib/SourceMapDevToolPlugin.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index e375110fabe..2aec14de0dc 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -132,6 +132,7 @@ class SourceMapDevToolPlugin { if(currentSourceMappingURLComment !== false && /\.css($|\?)/i.test(file)) { currentSourceMappingURLComment = currentSourceMappingURLComment.replace(/^\n\/\/(.*)$/, "\n/*$1*/"); } + const sourceMapString = JSON.stringify(sourceMap); if(sourceMapFilename) { let filename = file; let query = ""; @@ -140,25 +141,25 @@ class SourceMapDevToolPlugin { query = filename.substr(idx); filename = filename.substr(0, idx); } - const sourceMapFile = compilation.getPath(sourceMapFilename, { + let sourceMapFile = compilation.getPath(sourceMapFilename, { chunk, filename, query, basename: basename(filename) }); - let sourceMapUrl = path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/"); - if(sourceMapUrl.indexOf("[contenthash]") !== -1) { - sourceMapUrl = sourceMapUrl.replace(/\[contenthash\]/g, crypto.createHash("md5").update(source).digest("hex")); + if(sourceMapFile.indexOf("[contenthash]") !== -1) { + sourceMapFile = sourceMapFile.replace(/\[contenthash\]/g, crypto.createHash("md5").update(sourceMapString).digest("hex")); } + const sourceMapUrl = path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/"); if(currentSourceMappingURLComment !== false) { asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment.replace(/\[url\]/g, sourceMapUrl)); } - asset.__SourceMapDevToolData[sourceMapFile] = compilation.assets[sourceMapFile] = new RawSource(JSON.stringify(sourceMap)); + asset.__SourceMapDevToolData[sourceMapFile] = compilation.assets[sourceMapFile] = new RawSource(sourceMapString); chunk.files.push(sourceMapFile); } else { asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment - .replace(/\[map\]/g, () => JSON.stringify(sourceMap)) - .replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf-8").toString("base64")}`) // eslint-disable-line + .replace(/\[map\]/g, () => sourceMapString) + .replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${new Buffer(sourceMapString, "utf-8").toString("base64")}`) // eslint-disable-line ); } }); From 2b26cbb148c9de02f18e5b4fb75710d73ea28e1c Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 9 Jun 2017 08:52:44 +0200 Subject: [PATCH 04/12] Delete input.js --- input.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 input.js diff --git a/input.js b/input.js deleted file mode 100644 index eaa9cc4a247..00000000000 --- a/input.js +++ /dev/null @@ -1 +0,0 @@ -invalid javascript From ab9f6ee304fff838c3a1a3ed1687eef76d372a9d Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 9 Jun 2017 16:31:11 +0200 Subject: [PATCH 05/12] chrome workaround for eval-source-maps breakpoints now work fine --- lib/EvalSourceMapDevToolModuleTemplatePlugin.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js index 88b4520ba51..31ecfe0584e 100644 --- a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +++ b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js @@ -10,7 +10,7 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers"); class EvalSourceMapDevToolModuleTemplatePlugin { constructor(compilation, options) { this.compilation = compilation; - this.sourceMapComment = options.append || "//# sourceMappingURL=[url]"; + this.sourceMapComment = options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]"; this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack:///[resource-path]?[hash]"; this.options = options; } @@ -61,13 +61,14 @@ class EvalSourceMapDevToolModuleTemplatePlugin { sourceMap.sourceRoot = options.sourceRoot || ""; sourceMap.file = `${module.id}.js`; - 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 + 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 + `\n//# sourceURL=webpack-internal:///${module.id}\n`; // workaround for chrome bug source.__EvalSourceMapDevToolData = new RawSource(`eval(${JSON.stringify(content + footer)});`); return source.__EvalSourceMapDevToolData; }); moduleTemplate.plugin("hash", function(hash) { hash.update("eval-source-map"); - hash.update("1"); + hash.update("2"); }); } } From 8bd9211beb933987333f75aac5c98934a8c4ac4f Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Wed, 28 Jun 2017 08:37:58 -0400 Subject: [PATCH 06/12] add cacheWithContext to schema --- schemas/webpackOptionsSchema.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/schemas/webpackOptionsSchema.json b/schemas/webpackOptionsSchema.json index 81a971d259f..5391e6f1a92 100644 --- a/schemas/webpackOptionsSchema.json +++ b/schemas/webpackOptionsSchema.json @@ -459,6 +459,9 @@ "cachePredicate": { "instanceof": "Function" }, + "cacheWithContext": { + "type": "boolean" + }, "descriptionFiles": { "$ref": "#/definitions/common.arrayOfStringValues" }, From 20d7f7008faac8f954a4d059e4502dbebf8925dd Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sat, 1 Jul 2017 11:25:59 -0400 Subject: [PATCH 07/12] Bump enhanced-resolve --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a2deb4f5e70..2d84582523b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "ajv": "^4.7.0", "ajv-keywords": "^1.1.1", "async": "^2.1.2", - "enhanced-resolve": "^3.0.0", + "enhanced-resolve": "^3.3.0", "interpret": "^1.0.0", "json-loader": "^0.5.4", "json5": "^0.5.1", From 884fe4eead39bec9484df1e7b1475d99edbf3490 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sat, 1 Jul 2017 18:56:58 +0200 Subject: [PATCH 08/12] update yarn.lock --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index db83f7f12a7..c638f99e395 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1086,9 +1086,9 @@ encoding@^0.1.11: dependencies: iconv-lite "~0.4.13" -enhanced-resolve@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.1.0.tgz#9f4b626f577245edcf4b2ad83d86e17f4f421dec" +enhanced-resolve@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.3.0.tgz#950964ecc7f0332a42321b673b38dc8ff15535b3" dependencies: graceful-fs "^4.1.2" memory-fs "^0.4.0" From d0b0cada6f2cd6f79300e078a3b2393ab8f05983 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 31 May 2017 16:55:56 +0200 Subject: [PATCH 09/12] node 8 --- .travis.yml | 4 ++-- appveyor.yml | 2 +- circle.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 90e4f1ef5be..c0a808d031c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,10 @@ cache: matrix: include: - os: linux - node_js: "7" + node_js: "8" env: NO_WATCH_TESTS=1 JOB_PART=lint - os: linux - node_js: "7" + node_js: "8" env: NO_WATCH_TESTS=1 JOB_PART=test - os: linux node_js: "6" diff --git a/appveyor.yml b/appveyor.yml index 7375f52f8fb..2f9b71158f7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,7 @@ clone_depth: 50 # what combinations to test environment: matrix: - - nodejs_version: 7 + - nodejs_version: 8 job_part: test - nodejs_version: 6 job_part: test diff --git a/circle.yml b/circle.yml index 1ecf877e445..10c07fe89a4 100644 --- a/circle.yml +++ b/circle.yml @@ -8,7 +8,7 @@ machine: dependencies: pre: - - case $CIRCLE_NODE_INDEX in 0) NODE_VERSION=4 ;; 1) NODE_VERSION=7 ;; esac; nvm install $NODE_VERSION && nvm alias default $NODE_VERSION + - case $CIRCLE_NODE_INDEX in 0) NODE_VERSION=4 ;; 1) NODE_VERSION=8 ;; esac; nvm install $NODE_VERSION && nvm alias default $NODE_VERSION override: - yarn - yarn link || true && yarn link webpack From f6dd7a5bca2c6dd54694de0b120e0f5a3c9d5a22 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sun, 28 May 2017 23:23:42 +0200 Subject: [PATCH 10/12] use frozen lockfile to fail on outdated yarn.lock --- appveyor.yml | 6 +++--- ci/travis-install.sh | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2f9b71158f7..1f53b2ff4b5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,9 +21,9 @@ environment: install: - ps: Install-Product node $env:nodejs_version x64 - npm install yarn -g - - yarn install - - yarn link || yarn link - - yarn link webpack + - yarn install --frozen-lockfile + - yarn link --frozen-lockfile || yarn link --frozen-lockfile + - yarn link webpack --frozen-lockfile build: off diff --git a/ci/travis-install.sh b/ci/travis-install.sh index 0ef895e3cdc..cb62471a2b0 100755 --- a/ci/travis-install.sh +++ b/ci/travis-install.sh @@ -1,5 +1,7 @@ #!/bin/bash set -ev -yarn link || true && yarn link webpack; +yarn link --frozen-lockfile || true && yarn link webpack --frozen-lockfile; + +yarn --frozen-lockfile From 9562be3a2d76f4e7f1774ea618a658b745c1d23c Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sat, 3 Jun 2017 14:27:04 +0200 Subject: [PATCH 11/12] update webpack-sources --- package.json | 2 +- yarn.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 2d84582523b..cfde7588036 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "tapable": "~0.2.5", "uglify-js": "^2.8.27", "watchpack": "^1.3.1", - "webpack-sources": "^0.2.3", + "webpack-sources": "^1.0.1", "yargs": "^6.0.0" }, "license": "MIT", diff --git a/yarn.lock b/yarn.lock index c638f99e395..4df75e9d39f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3689,9 +3689,9 @@ source-list-map@^0.1.4, source-list-map@~0.1.7: version "0.1.8" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-0.1.8.tgz#c550b2ab5427f6b3f21f5afead88c4f5587b2106" -source-list-map@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-1.1.2.tgz#9889019d1024cce55cdc069498337ef6186a11a1" +source-list-map@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.0.tgz#aaa47403f7b245a92fbc97ea08f250d6087ed085" source-map@0.4.x, source-map@^0.4.4: version "0.4.4" @@ -4158,11 +4158,11 @@ webpack-sources@^0.1.0: source-list-map "~0.1.7" source-map "~0.5.3" -webpack-sources@^0.2.3: - version "0.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-0.2.3.tgz#17c62bfaf13c707f9d02c479e0dcdde8380697fb" +webpack-sources@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" dependencies: - source-list-map "^1.1.1" + source-list-map "^2.0.0" source-map "~0.5.3" whatwg-fetch@>=0.10.0: From a333f36e724534d7d957089b06048d921a0d25ab Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 12 Jul 2017 08:25:49 +0200 Subject: [PATCH 12/12] test webpack-2 branch too --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c0a808d031c..d7994514612 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ language: node_js branches: only: - master + - webpack-2 cache: directories: diff --git a/appveyor.yml b/appveyor.yml index 1f53b2ff4b5..063911bfde9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,7 @@ branches: only: - master + - webpack-2 init: - git config --global core.autocrlf input