Skip to content

Commit d518b36

Browse files
committed
update examples
1 parent 0b56650 commit d518b36

3 files changed

Lines changed: 91 additions & 132 deletions

File tree

‎examples/chunkhash/README.md‎

Lines changed: 29 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,11 @@ The configuration required for this is:
1010
# example.js
1111

1212
``` javascript
13-
import vendor from "./vendor";
1413
// some module
1514
import("./async1");
1615
import("./async2");
1716
```
1817

19-
# vendor.js
20-
21-
``` javascript
22-
// some vendor lib (should be in common chunk)
23-
export default 123;
24-
```
25-
2618
# webpack.config.js
2719

2820
``` javascript
@@ -51,21 +43,18 @@ module.exports = {
5143
</head>
5244
<body>
5345

54-
<!-- inlined minimized file "manifest.[chunkhash].js" -->
46+
<!-- inlined minimized file "runtime~main.[chunkhash].js" -->
5547
<script>
5648
!function(e){function r(r){for(var n,o,i=r[0],c=r[1],s=r[2],p=0,f=[];p<i.length;p++)o=i[p],u[o]&&f.push(u[o][0]),u[o]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(l&&l(r);f.length;)f.shift()();return a.push.apply(a,s||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],o=!0,i=1;i<t.length;i++){var c=t[i];0!==u[c]&&(o=!1)}o&&(a.splice(r--,1),e=n(n.s=t[0]))}return e}function n(r){if(o[r])return o[r].exports;var t=o[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,n),t.l=!0,t.exports}var o={},u={2:0},a=[];n.e=function(e){var r=[],t=u[e];if(0!==t)if(t)r.push(t[2]);else{var o=new Promise(function(r,n){t=u[e]=[r,n]});r.push(t[2]=o);var a=document.getElementsByTagName("head")[0],i=document.createElement("script");i.charset="utf-8",i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+""+({}[e]||e)+".[chunkhash].js";var c=setTimeout(function(){s({type:"timeout",target:i})},12e4);i.onerror=i.onload=s;function s(r){i.onerror=i.onload=null,clearTimeout(c);var t=u[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src,a=new Error("Loading chunk "+e+" failed.\n("+n+": "+o+")");a.type=n,a.request=o,t[1](a)}u[e]=void 0}}a.appendChild(i)}return Promise.all(r)},n.m=e,n.c=o,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},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,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="dist/",n.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var s=0;s<i.length;s++)r(i[s]);var l=c;t()}([]);
5749
</script>
5850

59-
<!-- optional when using the CommonChunkPlugin for vendor modules -->
60-
<script src="dist/main-runtime.[chunkhash].js"></script>
61-
6251
<script src="dist/main.[chunkhash].js"></script>
6352

6453
</body>
6554
</html>
6655
```
6756

68-
# dist/main-runtime.[chunkhash].js
57+
# dist/runtime~main.[chunkhash].js
6958

7059
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
7160

@@ -280,30 +269,12 @@ module.exports = {
280269
/*!********************!*\
281270
!*** ./example.js ***!
282271
\********************/
283-
/*! no exports provided */
284-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
285-
286-
"use strict";
287-
__webpack_require__.r(__webpack_exports__);
288-
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */ 1);
272+
/*! no static exports found */
273+
/***/ (function(module, exports, __webpack_require__) {
289274

290275
// some module
291-
__webpack_require__.e(/*! import() */ 1).then(function() { var module = __webpack_require__(/*! ./async1 */ 2); return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; });
292-
__webpack_require__.e(/*! import() */ 2).then(function() { var module = __webpack_require__(/*! ./async2 */ 3); return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; });
293-
294-
295-
/***/ }),
296-
/* 1 */
297-
/*!*******************!*\
298-
!*** ./vendor.js ***!
299-
\*******************/
300-
/*! exports provided: default */
301-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
302-
303-
"use strict";
304-
__webpack_require__.r(__webpack_exports__);
305-
// some vendor lib (should be in common chunk)
306-
/* harmony default export */ __webpack_exports__["default"] = (123);
276+
__webpack_require__.e(/*! import() */ 1).then(function() { var module = __webpack_require__(/*! ./async1 */ 1); return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; });
277+
__webpack_require__.e(/*! import() */ 2).then(function() { var module = __webpack_require__(/*! ./async2 */ 2); return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; });
307278

308279

309280
/***/ })
@@ -318,28 +289,24 @@ __webpack_require__.r(__webpack_exports__);
318289
Hash: 0a1b2c3d4e5f6a7b8c9d
319290
Version: webpack next
320291
Asset Size Chunks Chunk Names
321-
main.[chunkhash].js 1.28 KiB 0 [emitted] main
322-
1.[chunkhash].js 264 bytes 1 [emitted]
292+
main.[chunkhash].js 768 bytes 0 [emitted] main
293+
1.[chunkhash].js 270 bytes 1 [emitted]
323294
2.[chunkhash].js 264 bytes 2 [emitted]
324-
main-runtime.[chunkhash].js 7.49 KiB 3 [emitted] main-runtime
325-
Entrypoint main = main-runtime.[chunkhash].js main.[chunkhash].js
326-
chunk {0} main.[chunkhash].js (main) 159 bytes ={3}= >{1}< >{2}< [initial] [rendered]
295+
runtime~main.[chunkhash].js 7.49 KiB 3 [emitted] runtime~main
296+
Entrypoint main = runtime~main.[chunkhash].js main.[chunkhash].js
297+
chunk {0} main.[chunkhash].js (main) 58 bytes ={3}= >{1}< >{2}< [initial] [rendered]
327298
> ./example main
328-
[0] ./example.js 90 bytes {0} [built]
329-
[no exports]
299+
[0] ./example.js 58 bytes {0} [built]
330300
single entry ./example main
331-
[1] ./vendor.js 69 bytes {0} [built]
332-
[exports: default]
333-
harmony side effect evaluation ./vendor [0] ./example.js 1:0-30
334301
chunk {1} 1.[chunkhash].js 29 bytes <{3}> <{0}> [rendered]
335-
> ./async1 [0] ./example.js 3:0-18
336-
[2] ./async1.js 29 bytes {1} [built]
337-
import() ./async1 [0] ./example.js 3:0-18
302+
> ./async1 [0] ./example.js 2:0-18
303+
[1] ./async1.js 29 bytes {1} [built]
304+
import() ./async1 [0] ./example.js 2:0-18
338305
chunk {2} 2.[chunkhash].js 29 bytes <{3}> <{0}> [rendered]
339-
> ./async2 [0] ./example.js 4:0-18
340-
[3] ./async2.js 29 bytes {2} [built]
341-
import() ./async2 [0] ./example.js 4:0-18
342-
chunk {3} main-runtime.[chunkhash].js (main-runtime) 0 bytes ={0}= >{1}< >{2}< [entry] [rendered]
306+
> ./async2 [0] ./example.js 3:0-18
307+
[2] ./async2.js 29 bytes {2} [built]
308+
import() ./async2 [0] ./example.js 3:0-18
309+
chunk {3} runtime~main.[chunkhash].js (runtime~main) 0 bytes ={0}= >{1}< >{2}< [entry] [rendered]
343310
> ./example main
344311
```
345312

@@ -351,29 +318,21 @@ Version: webpack next
351318
Asset Size Chunks Chunk Names
352319
0.[chunkhash].js 77 bytes 0 [emitted]
353320
1.[chunkhash].js 78 bytes 1 [emitted]
354-
main-runtime.[chunkhash].js 1.76 KiB 2 [emitted] main-runtime
355-
main.[chunkhash].js 289 bytes 3 [emitted] main
356-
Entrypoint main = main-runtime.[chunkhash].js main.[chunkhash].js
321+
runtime~main.[chunkhash].js 1.76 KiB 2 [emitted] runtime~main
322+
main.[chunkhash].js 269 bytes 3 [emitted] main
323+
Entrypoint main = runtime~main.[chunkhash].js main.[chunkhash].js
357324
chunk {0} 0.[chunkhash].js 29 bytes <{2}> <{3}> [rendered]
358-
> ./async2 [] 4:0-18
325+
> ./async2 [0] ./example.js 3:0-18
359326
[1] ./async2.js 29 bytes {0} [built]
360-
import() ./async2 ./example.js 4:0-18
327+
import() ./async2 [0] ./example.js 3:0-18
361328
chunk {1} 1.[chunkhash].js 29 bytes <{2}> <{3}> [rendered]
362-
> ./async1 [] 3:0-18
329+
> ./async1 [0] ./example.js 2:0-18
363330
[2] ./async1.js 29 bytes {1} [built]
364-
import() ./async1 ./example.js 3:0-18
365-
chunk {2} main-runtime.[chunkhash].js (main-runtime) 0 bytes ={3}= >{0}< >{1}< [entry] [rendered]
331+
import() ./async1 [0] ./example.js 2:0-18
332+
chunk {2} runtime~main.[chunkhash].js (runtime~main) 0 bytes ={3}= >{0}< >{1}< [entry] [rendered]
366333
> ./example main
367-
chunk {3} main.[chunkhash].js (main) 159 bytes ={2}= >{0}< >{1}< [initial] [rendered]
334+
chunk {3} main.[chunkhash].js (main) 58 bytes ={2}= >{0}< >{1}< [initial] [rendered]
368335
> ./example main
369-
[0] ./example.js + 1 modules 159 bytes {3} [built]
370-
[no exports]
336+
[0] ./example.js 58 bytes {3} [built]
371337
single entry ./example main
372-
| ./example.js 90 bytes [built]
373-
| [no exports]
374-
| single entry ./example main
375-
| ./vendor.js 69 bytes [built]
376-
| [exports: default]
377-
| [no exports used]
378-
| harmony side effect evaluation ./vendor ./example.js 1:0-30
379338
```

0 commit comments

Comments
 (0)