Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jun 5, 2017
1 parent 463eeb5 commit 3455d7b
Show file tree
Hide file tree
Showing 43 changed files with 3,270 additions and 3,389 deletions.
18 changes: 9 additions & 9 deletions examples/aggressive-merging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ module.exports = {

```
Hash: 75bcce350a8b5f748873
Version: webpack 2.6.0
Version: webpack 3.0.0-rc.0
Asset Size Chunks Chunk Names
0.chunk.js 5.76 kB 0 [emitted]
1.chunk.js 401 bytes 1 [emitted]
pageB.bundle.js 6.58 kB 2 [emitted] pageB
pageA.bundle.js 6.55 kB 3 [emitted] pageA
pageC.bundle.js 6.34 kB 4 [emitted] pageC
1.chunk.js 403 bytes 1 [emitted]
pageB.bundle.js 6.42 kB 2 [emitted] pageB
pageA.bundle.js 6.39 kB 3 [emitted] pageA
pageC.bundle.js 6.18 kB 4 [emitted] pageC
Entrypoint pageA = pageA.bundle.js
Entrypoint pageB = pageB.bundle.js
Entrypoint pageC = pageC.bundle.js
Expand Down Expand Up @@ -102,13 +102,13 @@ chunk {4} pageC.bundle.js (pageC) 70 bytes [entry] [rendered]

```
Hash: 75bcce350a8b5f748873
Version: webpack 2.6.0
Version: webpack 3.0.0-rc.0
Asset Size Chunks Chunk Names
0.chunk.js 75 bytes 0 [emitted]
1.chunk.js 78 bytes 1 [emitted]
pageB.bundle.js 1.49 kB 2 [emitted] pageB
pageA.bundle.js 1.49 kB 3 [emitted] pageA
pageC.bundle.js 1.47 kB 4 [emitted] pageC
pageB.bundle.js 1.46 kB 2 [emitted] pageB
pageA.bundle.js 1.46 kB 3 [emitted] pageA
pageC.bundle.js 1.44 kB 4 [emitted] pageC
Entrypoint pageA = pageA.bundle.js
Entrypoint pageB = pageB.bundle.js
Entrypoint pageC = pageC.bundle.js
Expand Down
43 changes: 19 additions & 24 deletions examples/build-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,25 @@ var extraArgs = "";

var targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js js/output.js";
var displayReasons = global.NO_REASONS ? "" : " --display-reasons --display-used-exports --display-provided-exports";
(function doIt(remainingTimes) {
cp.exec("node ../../bin/webpack.js" + displayReasons + " --display-chunks --display-modules --display-origins --display-entrypoints --output-public-path \"js/\" -p " + extraArgs + targetArgs, function (error, stdout, stderr) {
if(stderr && remainingTimes === 1)
cp.exec("node ../../bin/webpack.js" + displayReasons + " --display-chunks --display-modules --display-origins --display-entrypoints --output-public-path \"js/\" -p " + extraArgs + targetArgs, function(error, stdout, stderr) {
if(stderr)
console.log(stderr);
if(error !== null)
console.log(error);
try {
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;
}
cp.exec("node ../../bin/webpack.js" + displayReasons + " --display-chunks --display-modules --display-origins --display-entrypoints --output-public-path \"js/\" --output-pathinfo " + extraArgs + targetArgs, function(error, stdout, stderr) {
console.log(stdout);
if(stderr)
console.log(stderr);
if (error !== null && remainingTimes === 1)
if(error !== null)
console.log(error);
try {
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;
}
cp.exec("node ../../bin/webpack.js" + displayReasons + " --display-chunks --display-modules --display-origins --display-entrypoints --output-public-path \"js/\" --output-pathinfo " + extraArgs + targetArgs, function (error, stdout, stderr) {
if(remainingTimes === 1)
console.log(stdout);
if(stderr && remainingTimes === 1)
console.log(stderr);
if (error !== null && remainingTimes === 1)
console.log(error);
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);
});
readme = tc.replaceResults(readme, process.cwd(), stdout.replace(/[\r\n]*$/, ""));
readme = tc.replaceBase(readme);
fs.writeFile("README.md", readme, "utf-8", function() {});
});
}(3));
});
117 changes: 57 additions & 60 deletions examples/chunkhash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {

<!-- inlined minimized file "manifest.[chunkhash].js" -->
<script>
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,u){for(var i,a,f,s=0,l=[];s<t.length;s++)a=t[s],o[a]&&l.push(o[a][0]),o[a]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(e[i]=c[i]);for(r&&r(t,c,u);l.length;)l.shift()();if(u)for(s=0;s<u.length;s++)f=n(n.s=u[s]);return f};var t={},o={4:0},c=new Promise(function(e){e()});n.e=function(e){function r(){i.onerror=i.onload=null,clearTimeout(a);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}if(0===o[e])return c;if(o[e])return o[e][2];var t=new Promise(function(n,r){o[e]=[n,r]});o[e][2]=t;var u=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.charset="utf-8",i.async=!0,i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+""+{0:"d1359b519c10df30787b",1:"06459c375ec851b0e2ae",2:"4d752abc2fcf569f13fc",3:"8d8564a703e7631bff4b"}[e]+".js";var a=setTimeout(r,12e4);return i.onerror=i.onload=r,u.appendChild(i),t},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="js/",n.oe=function(e){throw console.error(e),e}}([]);
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var u,i,f,d=0,s=[];d<t.length;d++)i=t[d],o[i]&&s.push(o[i][0]),o[i]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(r&&r(t,c,a);s.length;)s.shift()();if(a)for(d=0;d<a.length;d++)f=n(n.s=a[d]);return f};var t={},o={4:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute("nonce",n.nc),u.src=n.p+""+{0:"3db3fdaf96bbdadce99a",1:"7c1138cf80dd374c367e",2:"543257d0ba12aefbc71b",3:"15bdf078724c793dc604"}[e]+".js";var i=setTimeout(r,12e4);return u.onerror=u.onload=r,a.appendChild(u),c},n.m=e,n.c=t,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="js/",n.oe=function(e){throw console.error(e),e}}([]);
</script>

<!-- optional when using the CommonChunkPlugin for vendor modules -->
Expand All @@ -79,11 +79,11 @@ module.exports = {
``` javascript
webpackJsonp([2],[
/* 0 */
/* exports provided: default */
/* all exports used */
/*!*******************!*\
!*** ./vendor.js ***!
\*******************/
/*! exports provided: default */
/*! all exports used */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Expand All @@ -94,116 +94,113 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });

/***/ }),
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
/* unknown exports provided */
/* all exports used */
/* 2 */
/*!**********************!*\
!*** multi ./vendor ***!
\**********************/
/*! no static exports found */
/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(/*! ./vendor */0);


/***/ })
],[4]);
],[2]);
```

# js/main.[chunkhash].js

``` javascript
webpackJsonp([3],{

/***/ 3:
/* unknown exports provided */
/* all exports used */
webpackJsonp([3],[
/* 0 */,
/* 1 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
/*! all exports used */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__vendor__ = __webpack_require__(/*! ./vendor */ 0);

// some module
__webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./async1 */ 1));
__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async2 */ 2));
__webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./async1 */ 3));
__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async2 */ 4));


/***/ })

},[3]);
],[1]);
```

# Info

## Uncompressed

```
Hash: ea635224271deb1b32d9
Version: webpack 2.6.0
Hash: 49023fec553882c3285c
Version: webpack 3.0.0-rc.0
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 6.05 kB 4 [emitted] manifest
3db3fdaf96bbdadce99a.js 238 bytes 0 [emitted]
7c1138cf80dd374c367e.js 238 bytes 1 [emitted]
common.[chunkhash].js 732 bytes 2 [emitted] common
main.[chunkhash].js 661 bytes 3 [emitted] main
manifest.[chunkhash].js 5.89 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]
import() ./async2 [3] ./example.js 4:0-18
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 {0} 3db3fdaf96bbdadce99a.js 29 bytes {3} [rendered]
> [1] ./example.js 4:0-18
[4] ./async2.js 29 bytes {0} [built]
import() ./async2 [1] ./example.js 4:0-18
chunk {1} 7c1138cf80dd374c367e.js 29 bytes {3} [rendered]
> [1] ./example.js 3:0-18
[3] ./async1.js 29 bytes {1} [built]
import() ./async1 [1] ./example.js 3:0-18
chunk {2} common.[chunkhash].js (common) 97 bytes {4} [initial] [rendered]
> common [4] multi ./vendor
> common [2] 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]
harmony import ./vendor [1] ./example.js 1:0-30
single entry ./vendor [2] multi ./vendor common:100000
[2] multi ./vendor 28 bytes {2} [built]
chunk {3} main.[chunkhash].js (main) 90 bytes {2} [initial] [rendered]
> main [3] ./example.js
[3] ./example.js 90 bytes {3} [built]
> main [1] ./example.js
[1] ./example.js 90 bytes {3} [built]
chunk {4} manifest.[chunkhash].js (manifest) 0 bytes [entry] [rendered]
```

## Minimized (uglify-js, no zip)

```
Hash: ea635224271deb1b32d9
Version: webpack 2.6.0
Hash: 49023fec553882c3285c
Version: webpack 3.0.0-rc.0
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.49 kB 4 [emitted] manifest
3db3fdaf96bbdadce99a.js 38 bytes 0 [emitted]
7c1138cf80dd374c367e.js 38 bytes 1 [emitted]
common.[chunkhash].js 150 bytes 2 [emitted] common
main.[chunkhash].js 165 bytes 3 [emitted] main
manifest.[chunkhash].js 1.46 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]
import() ./async2 [3] ./example.js 4:0-18
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 {0} 3db3fdaf96bbdadce99a.js 29 bytes {3} [rendered]
> [1] ./example.js 4:0-18
[4] ./async2.js 29 bytes {0} [built]
import() ./async2 [1] ./example.js 4:0-18
chunk {1} 7c1138cf80dd374c367e.js 29 bytes {3} [rendered]
> [1] ./example.js 3:0-18
[3] ./async1.js 29 bytes {1} [built]
import() ./async1 [1] ./example.js 3:0-18
chunk {2} common.[chunkhash].js (common) 97 bytes {4} [initial] [rendered]
> common [4] multi ./vendor
> common [2] 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]
harmony import ./vendor [1] ./example.js 1:0-30
single entry ./vendor [2] multi ./vendor common:100000
[2] multi ./vendor 28 bytes {2} [built]
chunk {3} main.[chunkhash].js (main) 90 bytes {2} [initial] [rendered]
> main [3] ./example.js
[3] ./example.js 90 bytes {3} [built]
> main [1] ./example.js
[1] ./example.js 90 bytes {3} [built]
chunk {4} manifest.[chunkhash].js (manifest) 0 bytes [entry] [rendered]
```
Loading

0 comments on commit 3455d7b

Please sign in to comment.