mirror of https://github.com/webpack/webpack.git
parent
e7c13d75e4
commit
9bb19e69f5
|
@ -17,7 +17,7 @@ var displayReasons = global.NO_REASONS ? "" : " --display-reasons --display-used
|
|||
if (error !== null && remainingTimes === 1)
|
||||
console.log(error);
|
||||
try {
|
||||
var readme = tc(fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8"), process.cwd(), stdout.replace(/[\r\n]*$/, ""), "min");
|
||||
var readme = tc.replaceResults(fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8"), process.cwd(), stdout.replace(/[\r\n]*$/, ""), "min");
|
||||
} catch(e) {
|
||||
console.log(stderr);
|
||||
throw e;
|
||||
|
@ -29,8 +29,8 @@ var displayReasons = global.NO_REASONS ? "" : " --display-reasons --display-used
|
|||
console.log(stderr);
|
||||
if (error !== null && remainingTimes === 1)
|
||||
console.log(error);
|
||||
readme = tc(readme, process.cwd(), stdout.replace(/[\r\n]*$/, ""));
|
||||
readme = readme.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
||||
readme = tc.replaceResults(readme, process.cwd(), stdout.replace(/[\r\n]*$/, ""));
|
||||
readme = tc.replaceBase(readme);
|
||||
fs.writeFile("README.md", readme, "utf-8", function() {});
|
||||
if(remainingTimes > 1)
|
||||
doIt(remainingTimes - 1);
|
||||
|
|
|
@ -36,7 +36,7 @@ module.exports = {
|
|||
},
|
||||
output: {
|
||||
path: path.join(__dirname, "js"),
|
||||
filename: "[name].chunkhash.js",
|
||||
filename: "[name].[chunkhash].js",
|
||||
chunkFilename: "[chunkhash].js"
|
||||
},
|
||||
plugins: [
|
||||
|
@ -144,15 +144,15 @@ __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! .
|
|||
|
||||
```
|
||||
Hash: ea635224271deb1b32d9
|
||||
Version: webpack 2.3.2
|
||||
Version: webpack 2.3.3
|
||||
Asset Size Chunks Chunk Names
|
||||
d1359b519c10df30787b.js 237 bytes 0 [emitted]
|
||||
06459c375ec851b0e2ae.js 243 bytes 1 [emitted]
|
||||
common.chunkhash.js 747 bytes 2 [emitted] common
|
||||
main.chunkhash.js 654 bytes 3 [emitted] main
|
||||
manifest.chunkhash.js 5.88 kB 4 [emitted] manifest
|
||||
Entrypoint main = manifest.chunkhash.js common.chunkhash.js main.chunkhash.js
|
||||
Entrypoint common = manifest.chunkhash.js common.chunkhash.js
|
||||
common.[chunkhash].js 747 bytes 2 [emitted] common
|
||||
main.[chunkhash].js 654 bytes 3 [emitted] main
|
||||
manifest.[chunkhash].js 5.88 kB 4 [emitted] manifest
|
||||
Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js
|
||||
Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js
|
||||
chunk {0} d1359b519c10df30787b.js 29 bytes {3} [rendered]
|
||||
> [3] ./example.js 4:0-18
|
||||
[2] ./async2.js 29 bytes {0} [built]
|
||||
|
@ -161,32 +161,32 @@ chunk {1} 06459c375ec851b0e2ae.js 29 bytes {3} [rendered]
|
|||
> [3] ./example.js 3:0-18
|
||||
[1] ./async1.js 29 bytes {1} [built]
|
||||
import() ./async1 [3] ./example.js 3:0-18
|
||||
chunk {2} common.chunkhash.js (common) 97 bytes {4} [initial] [rendered]
|
||||
chunk {2} common.[chunkhash].js (common) 97 bytes {4} [initial] [rendered]
|
||||
> common [4] multi ./vendor
|
||||
[0] ./vendor.js 69 bytes {2} [built]
|
||||
[exports: default]
|
||||
harmony import ./vendor [3] ./example.js 1:0-30
|
||||
single entry ./vendor [4] multi ./vendor common:100000
|
||||
[4] multi ./vendor 28 bytes {2} [built]
|
||||
chunk {3} main.chunkhash.js (main) 90 bytes {2} [initial] [rendered]
|
||||
chunk {3} main.[chunkhash].js (main) 90 bytes {2} [initial] [rendered]
|
||||
> main [3] ./example.js
|
||||
[3] ./example.js 90 bytes {3} [built]
|
||||
chunk {4} manifest.chunkhash.js (manifest) 0 bytes [entry] [rendered]
|
||||
chunk {4} manifest.[chunkhash].js (manifest) 0 bytes [entry] [rendered]
|
||||
```
|
||||
|
||||
## Minimized (uglify-js, no zip)
|
||||
|
||||
```
|
||||
Hash: ea635224271deb1b32d9
|
||||
Version: webpack 2.3.2
|
||||
Version: webpack 2.3.3
|
||||
Asset Size Chunks Chunk Names
|
||||
d1359b519c10df30787b.js 38 bytes 0 [emitted]
|
||||
06459c375ec851b0e2ae.js 37 bytes 1 [emitted]
|
||||
common.chunkhash.js 152 bytes 2 [emitted] common
|
||||
main.chunkhash.js 166 bytes 3 [emitted] main
|
||||
manifest.chunkhash.js 1.48 kB 4 [emitted] manifest
|
||||
Entrypoint main = manifest.chunkhash.js common.chunkhash.js main.chunkhash.js
|
||||
Entrypoint common = manifest.chunkhash.js common.chunkhash.js
|
||||
common.[chunkhash].js 152 bytes 2 [emitted] common
|
||||
main.[chunkhash].js 166 bytes 3 [emitted] main
|
||||
manifest.[chunkhash].js 1.48 kB 4 [emitted] manifest
|
||||
Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js
|
||||
Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js
|
||||
chunk {0} d1359b519c10df30787b.js 29 bytes {3} [rendered]
|
||||
> [3] ./example.js 4:0-18
|
||||
[2] ./async2.js 29 bytes {0} [built]
|
||||
|
@ -195,15 +195,15 @@ chunk {1} 06459c375ec851b0e2ae.js 29 bytes {3} [rendered]
|
|||
> [3] ./example.js 3:0-18
|
||||
[1] ./async1.js 29 bytes {1} [built]
|
||||
import() ./async1 [3] ./example.js 3:0-18
|
||||
chunk {2} common.chunkhash.js (common) 97 bytes {4} [initial] [rendered]
|
||||
chunk {2} common.[chunkhash].js (common) 97 bytes {4} [initial] [rendered]
|
||||
> common [4] multi ./vendor
|
||||
[0] ./vendor.js 69 bytes {2} [built]
|
||||
[exports: default]
|
||||
harmony import ./vendor [3] ./example.js 1:0-30
|
||||
single entry ./vendor [4] multi ./vendor common:100000
|
||||
[4] multi ./vendor 28 bytes {2} [built]
|
||||
chunk {3} main.chunkhash.js (main) 90 bytes {2} [initial] [rendered]
|
||||
chunk {3} main.[chunkhash].js (main) 90 bytes {2} [initial] [rendered]
|
||||
> main [3] ./example.js
|
||||
[3] ./example.js 90 bytes {3} [built]
|
||||
chunk {4} manifest.chunkhash.js (manifest) 0 bytes [entry] [rendered]
|
||||
chunk {4} manifest.[chunkhash].js (manifest) 0 bytes [entry] [rendered]
|
||||
```
|
|
@ -2,8 +2,8 @@
|
|||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
function lessStrict(regExpStr) {
|
||||
regExpStr = regExpStr
|
||||
|
@ -12,15 +12,14 @@ function lessStrict(regExpStr) {
|
|||
return regExpStr;
|
||||
}
|
||||
|
||||
var runtimeRegexp = /(```\s*(?:js|javascript)\n)?(.*)(\/\*\*\*\*\*\*\/ \(function\(modules\) \{ \/\/ webpackBootstrap\n(?:.|\n)*?\n\/\*\*\*\*\*\*\/ \}\)\n\/\**\/\n)/;
|
||||
var timeRegexp = /\s*Time: \d+ms/g;
|
||||
const runtimeRegexp = /(```\s*(?:js|javascript)\n)?(.*)(\/\*\*\*\*\*\*\/ \(function\(modules\) \{ \/\/ webpackBootstrap\n(?:.|\n)*?\n\/\*\*\*\*\*\*\/ \}\)\n\/\**\/\n)/;
|
||||
const timeRegexp = /\s*Time: \d+ms/g;
|
||||
|
||||
module.exports = function(template, baseDir, stdout, prefix) {
|
||||
exports.replaceBase = function replaceBase(template) {
|
||||
|
||||
var regexp = new RegExp("\\{\\{" + (prefix ? prefix+":" : "") + "([^:\\}]+)\\}\\}", "g")
|
||||
var cwd = process.cwd();
|
||||
var webpack = path.join(__dirname, "..");
|
||||
var webpackParent = path.join(__dirname, "..", "..");
|
||||
let cwd = process.cwd();
|
||||
let webpack = path.join(__dirname, "..");
|
||||
let webpackParent = path.join(__dirname, "..", "..");
|
||||
cwd = lessStrict(cwd.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
|
||||
cwd = new RegExp(cwd, "g");
|
||||
webpack = lessStrict(webpack.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
|
||||
|
@ -28,22 +27,30 @@ module.exports = function(template, baseDir, stdout, prefix) {
|
|||
webpackParent = lessStrict(webpackParent.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
|
||||
webpackParent = new RegExp(webpackParent, "g");
|
||||
|
||||
return template
|
||||
.replace(/\r\n/g, "\n")
|
||||
.replace(/\r/g, "\n")
|
||||
.replace(cwd, ".")
|
||||
.replace(webpack, "(webpack)")
|
||||
.replace(webpackParent, "(webpack)/~")
|
||||
.replace(timeRegexp, "")
|
||||
.replace(/\.chunkhash\./g, ".[chunkhash].")
|
||||
.replace(runtimeRegexp, function(match) {
|
||||
match = runtimeRegexp.exec(match);
|
||||
const prefix = match[1] ? "" : "```\n";
|
||||
const inner = match[1] ? match[1] : "``` js\n";
|
||||
return prefix + "<details><summary><code>" + match[2] + "/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>\n\n" + inner + match[2] + match[3] + "```\n\n</details>\n\n" + inner;
|
||||
});
|
||||
}
|
||||
|
||||
exports.replaceResults = function replaceResults(template, baseDir, stdout, prefix) {
|
||||
const regexp = new RegExp("\\{\\{" + (prefix ? prefix+":" : "") + "([^:\\}]+)\\}\\}", "g")
|
||||
|
||||
return template.replace(regexp, function(match) {
|
||||
match = match.substr(2 + (prefix ? prefix.length+1 : 0), match.length - 4 - (prefix ? prefix.length+1 : 0));
|
||||
if(match === "stdout")
|
||||
return stdout;
|
||||
return fs.readFileSync(path.join(baseDir, match), "utf-8").replace(/[\r\n]*$/, "");
|
||||
})
|
||||
.replace(/\r\n/g, "\n")
|
||||
.replace(cwd, ".")
|
||||
.replace(webpack, "(webpack)")
|
||||
.replace(webpackParent, "(webpack)/~")
|
||||
.replace(timeRegexp, "")
|
||||
.replace(runtimeRegexp, function(match) {
|
||||
match = runtimeRegexp.exec(match);
|
||||
var prefix = match[1] ? "" : "```\n";
|
||||
var inner = match[1] ? match[1] : "``` js\n";
|
||||
return prefix + "<details><summary><code>" + match[2] + "/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>\n\n" + inner + match[2] + match[3] + "```\n\n</details>\n\n" + inner;
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue