webpack/examples/chunkhash/README.md

448 lines
20 KiB
Markdown
Raw Normal View History

2020-05-21 05:26:51 +08:00
A common challenge with combining `[chunkhash]` and Code Splitting is that the entry chunk includes the webpack runtime and with it the chunkhash mappings. This means it's always updated and the `[chunkhash]` is pretty useless because this chunk won't be cached.
2015-11-21 04:36:43 +08:00
2020-05-21 05:26:51 +08:00
A very simple solution to this problem is to create another chunk that contains only the webpack runtime (including chunkhash map). This can be achieved with `optimization.runtimeChunk` options. To avoid the additional request for another chunk, this pretty small chunk can be inlined into the HTML page.
2015-11-21 04:36:43 +08:00
The configuration required for this is:
2019-04-09 02:29:40 +08:00
- use `[chunkhash]` in `output.filename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
- use `[chunkhash]` in `output.chunkFilename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
2015-11-21 04:36:43 +08:00
# example.js
2019-04-09 02:29:40 +08:00
```javascript
2015-11-21 04:36:43 +08:00
// some module
2017-02-13 15:49:35 +08:00
import("./async1");
import("./async2");
2015-11-21 04:36:43 +08:00
```
# webpack.config.js
2019-04-09 02:29:40 +08:00
```javascript
2015-11-21 04:36:43 +08:00
var path = require("path");
module.exports = {
2017-12-14 17:58:03 +08:00
// mode: "development || "production",
2015-11-21 04:36:43 +08:00
entry: {
main: "./example"
},
optimization: {
runtimeChunk: true
2015-11-21 04:36:43 +08:00
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].[chunkhash].js",
chunkFilename: "[name].[chunkhash].js"
}
2015-11-21 04:36:43 +08:00
};
```
# index.html
2019-04-09 02:29:40 +08:00
```html
2015-11-21 04:36:43 +08:00
<html>
2019-04-09 02:29:40 +08:00
<head> </head>
<body>
<!-- inlined minimized file "runtime~main.[chunkhash].js" -->
<script>
(()=>{"use strict";var e,r,t,o={},n={};function a(e){if(n[e])return n[e].exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,a.x=e=>{},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(t,o){if(1&o&&(t=this(t)),8&o)return t;if("object"==typeof t&&t){if(4&o&&t.__esModule)return t;if(16&o&&"function"==typeof t.then)return t}var n=Object.create(null);a.r(n);var u={};e=e||[null,r({}),r([]),r(r)];for(var i=2&o&&t;"object"==typeof i&&!~e.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach((e=>u[e]=()=>t[e]));return u.default=()=>t,a.d(n,u),n},a.d=(e,r)=>{for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((r,t)=>(a.f[t](e,r),r)),[])),a.u=e=>e+".[chunkhash].js",a.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},a.l=(e,r,o)=>{if(t[e])t[e].push(r);else{var n,u;if(void 0!==o)for(var i=document.getElementsByTagName("script"),l=0;l<i.length;l++){var f=i[l];if(f.getAttribute("src")==e){n=f;break}}n||(u=!0,(n=document.createElement("script")).charset="utf-8",n.timeout=120,a.nc&&n.setAttribute("nonce",a.nc),n.src=e),t[e]=[r];var s=(r,o)=>{n.onerror=n.onload=null,clearTimeout(c);var a=t[e];if(delete t[e],n.parentNode&&n.parentNode.removeChild(n),a&&a.forEach((e=>e(o))),r)return r(o)},c=setTimeout(s.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=s.bind(null,n.onerror),n.onload=s.bind(null,n.onload),u&&document.head.appendChild(n)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.p="dist/",(()=>{var e={303:0},r=[];a.f.j=(r,t)=>{var o=a.o(e,r)?e[r]:void 0;if(0!==o)if(o)t.push(o[2]);else{var n=new Promise(((t,n)=>{o=e[r]=[t,n]}));t.push(o[2]=n);var u=a.p+a.u(r),i=new Error;a.l(u,(t=>{if(a.o(e,r)&&(0!==(o=e[r])&&(e[r]=void 0),o)){var n=t&&("load"===t.type?"missing":t.type),u=t&&t.target&&t.target.src;i.message="Loading chunk "+r+" failed.\n("+n+": "+u+")",i.name="ChunkLoadError",i.type=n,i.request=u,o[1](i)}}),"chunk-"+r)}};var t=e=>{},o=(o,n)=>{for(var u,i,[l,f,s,c]=n,p=0,d=[];p<l.length;p++)i=l[p],a.o(e,i)&&e[i]&&d.push(e[i][0]),e[i]=0;for(u in f)a.o(f,u)&&(a.m[u]=f[u]);for(s&&s(a),o&&o(n);d.length;)d.shift()();return c&&r.push.apply(r,c),t()},n=self.webpackChunk=self.webpackChunk||[];function u(){for(var t,o=0;o<r.length;o++){for(var n=r[o],u=!0,i=1;i<n.length;i++){var l=n[i];0!==e[l]&&(u=!1)}u&&(r.splice(o--,1),t=a(a.s=n[0]))}return 0===r.length&&(a.x(),a.x=e=>{}),t}n.forEach(o.bind(null,0)),n.push=o.bind(null,n.push.bind(n));var i=a.x;a.x=()=>(a.x=i||(e=>{}),(t=u)())})(),a.x()})();
2019-04-09 02:29:40 +08:00
</script>
2015-11-21 04:36:43 +08:00
2019-04-09 02:29:40 +08:00
<script src="dist/main.[chunkhash].js"></script>
</body>
2015-11-21 04:36:43 +08:00
</html>
```
2018-02-10 22:09:46 +08:00
# dist/runtime~main.[chunkhash].js
2015-11-21 04:36:43 +08:00
2019-04-09 02:29:40 +08:00
```javascript
2019-10-11 05:11:05 +08:00
/******/ (() => { // webpackBootstrap
2018-12-19 21:05:17 +08:00
/******/ "use strict";
2019-10-11 05:11:05 +08:00
/******/ var __webpack_modules__ = ({});
```
<details><summary><code>/* webpack runtime code */</code></summary>
``` js
2019-10-11 05:11:05 +08:00
/************************************************************************/
/******/ // The module cache
2019-10-11 05:11:05 +08:00
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
2019-10-11 05:11:05 +08:00
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
2019-10-11 05:11:05 +08:00
/******/ var module = __webpack_module_cache__[moduleId] = {
2020-05-21 05:26:51 +08:00
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
2019-10-11 05:11:05 +08:00
/******/
/******/ // Execute the module function
2019-10-11 05:11:05 +08:00
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
2019-10-11 05:11:05 +08:00
/******/
2018-12-19 21:05:17 +08:00
/******/ // expose the modules object (__webpack_modules__)
2019-10-11 05:11:05 +08:00
/******/ __webpack_require__.m = __webpack_modules__;
/******/
/******/ // the startup function
/******/ // It's empty as some runtime module handles the default behavior
/******/ __webpack_require__.x = x => {}
2018-12-19 21:05:17 +08:00
/************************************************************************/
/******/ /* webpack/runtime/create fake namespace object */
2020-05-21 05:26:51 +08:00
/******/ (() => {
/******/ var getProto = Object.getPrototypeOf ? (obj) => Object.getPrototypeOf(obj) : (obj) => obj.__proto__;
/******/ var leafPrototypes;
2018-12-19 21:05:17 +08:00
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 16: return value when it's Promise-like
2018-12-19 21:05:17 +08:00
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = this(value);
/******/ if(mode & 8) return value;
/******/ if(typeof value === 'object' && value) {
/******/ if((mode & 4) && value.__esModule) return value;
/******/ if((mode & 16) && typeof value.then === 'function') return value;
/******/ }
2018-12-19 21:05:17 +08:00
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
2019-11-15 07:06:30 +08:00
/******/ var def = {};
/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
/******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {
/******/ Object.getOwnPropertyNames(current).forEach(key => def[key] = () => value[key]);
2019-10-09 05:45:47 +08:00
/******/ }
2019-11-15 07:06:30 +08:00
/******/ def['default'] = () => value;
/******/ __webpack_require__.d(ns, def);
2018-12-19 21:05:17 +08:00
/******/ return ns;
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
2018-12-19 21:05:17 +08:00
/******/
2019-10-09 05:45:47 +08:00
/******/ /* webpack/runtime/define property getters */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2019-10-09 05:45:47 +08:00
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
2020-05-21 05:26:51 +08:00
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
2019-10-09 05:45:47 +08:00
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
2018-12-19 21:05:17 +08:00
/******/ }
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
2018-12-19 21:05:17 +08:00
/******/
2019-11-15 07:06:30 +08:00
/******/ /* webpack/runtime/ensure chunk */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2019-11-15 07:06:30 +08:00
/******/ __webpack_require__.f = {};
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = (chunkId) => {
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
/******/ __webpack_require__.f[key](chunkId, promises);
/******/ return promises;
/******/ }, []));
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
2019-11-15 07:06:30 +08:00
/******/
/******/ /* webpack/runtime/get javascript chunk filename */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2019-11-15 07:06:30 +08:00
/******/ // This function allow to reference async chunks
/******/ __webpack_require__.u = (chunkId) => {
/******/ // return url for filenames based on template
/******/ return "" + chunkId + ".[chunkhash].js";
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
/******/ })();
2019-11-15 07:06:30 +08:00
/******/
2020-09-21 04:39:12 +08:00
/******/ /* webpack/runtime/load script */
/******/ (() => {
/******/ var inProgress = {};
/******/ // data-webpack is not used as build has no uniqueName
/******/ // loadScript function to load a script via script tag
/******/ __webpack_require__.l = (url, done, key) => {
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
/******/ var script, needAttach;
/******/ if(key !== undefined) {
/******/ var scripts = document.getElementsByTagName("script");
/******/ for(var i = 0; i < scripts.length; i++) {
/******/ var s = scripts[i];
/******/ if(s.getAttribute("src") == url) { script = s; break; }
/******/ }
/******/ }
/******/ if(!script) {
/******/ needAttach = true;
/******/ script = document.createElement('script');
/******/
/******/ script.charset = 'utf-8';
/******/ script.timeout = 120;
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/
/******/ script.src = url;
/******/ }
/******/ inProgress[url] = [done];
/******/ var onScriptComplete = (prev, event) => {
/******/ // avoid mem leaks in IE.
/******/ script.onerror = script.onload = null;
/******/ clearTimeout(timeout);
/******/ var doneFns = inProgress[url];
/******/ delete inProgress[url];
/******/ script.parentNode && script.parentNode.removeChild(script);
/******/ doneFns && doneFns.forEach((fn) => fn(event));
/******/ if(prev) return prev(event);
/******/ }
/******/ ;
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
/******/ script.onload = onScriptComplete.bind(null, script.onload);
/******/ needAttach && document.head.appendChild(script);
/******/ };
/******/ })();
/******/
2018-12-19 21:05:17 +08:00
/******/ /* webpack/runtime/make namespace object */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2018-12-19 21:05:17 +08:00
/******/ // define __esModule on exports
2019-10-09 05:45:47 +08:00
/******/ __webpack_require__.r = (exports) => {
2018-12-19 21:05:17 +08:00
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
2018-12-19 21:05:17 +08:00
/******/
/******/ /* webpack/runtime/publicPath */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2018-12-19 21:05:17 +08:00
/******/ __webpack_require__.p = "dist/";
2020-05-21 05:26:51 +08:00
/******/ })();
2018-12-19 21:05:17 +08:00
/******/
/******/ /* webpack/runtime/jsonp chunk loading */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2020-09-21 04:39:12 +08:00
/******/ // no baseURI
/******/
2018-12-19 21:05:17 +08:00
/******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ // Promise = chunk loading, 0 = chunk loaded
/******/ var installedChunks = {
2020-09-21 04:39:12 +08:00
/******/ 1: 0
2018-12-19 21:05:17 +08:00
/******/ };
/******/
/******/ var deferredModules = [
/******/
/******/ ];
2019-10-09 05:45:47 +08:00
/******/ __webpack_require__.f.j = (chunkId, promises) => {
/******/ // JSONP chunk loading for javascript
2020-05-21 05:26:51 +08:00
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
2019-10-09 05:45:47 +08:00
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
2018-12-19 21:05:17 +08:00
/******/
2019-10-09 05:45:47 +08:00
/******/ // a Promise means "currently loading".
/******/ if(installedChunkData) {
/******/ promises.push(installedChunkData[2]);
/******/ } else {
/******/ if(true) { // all chunks have JS
/******/ // setup Promise in chunk cache
/******/ var promise = new Promise((resolve, reject) => {
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
/******/ });
/******/ promises.push(installedChunkData[2] = promise);
2018-12-19 21:05:17 +08:00
/******/
2019-10-09 05:45:47 +08:00
/******/ // start chunk loading
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
2020-09-21 04:39:12 +08:00
/******/ // create error before stack unwound to get useful stacktrace later
/******/ var error = new Error();
/******/ var loadingEnded = (event) => {
2020-05-21 05:26:51 +08:00
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
2019-11-15 07:06:30 +08:00
/******/ installedChunkData = installedChunks[chunkId];
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
2020-09-21 04:39:12 +08:00
/******/ if(installedChunkData) {
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
/******/ var realSrc = event && event.target && event.target.src;
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
/******/ error.name = 'ChunkLoadError';
/******/ error.type = errorType;
/******/ error.request = realSrc;
/******/ installedChunkData[1](error);
/******/ }
2019-11-15 07:06:30 +08:00
/******/ }
2019-10-09 05:45:47 +08:00
/******/ };
2020-09-21 04:39:12 +08:00
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId);
2019-10-09 05:45:47 +08:00
/******/ } else installedChunks[chunkId] = 0;
/******/ }
2018-12-19 21:05:17 +08:00
/******/ }
/******/ };
/******/
/******/ // no prefetching
/******/
2020-05-21 05:26:51 +08:00
/******/ // no preloaded
/******/
2018-12-19 21:05:17 +08:00
/******/ // no HMR
/******/
/******/ // no HMR manifest
/******/
/******/ var checkDeferredModules = x => {};
2018-12-19 21:05:17 +08:00
/******/
/******/ // install a JSONP callback for chunk loading
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
2020-09-21 04:39:12 +08:00
/******/ var [chunkIds, moreModules, runtime, executeModules] = data;
2018-12-19 21:05:17 +08:00
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
2020-05-21 05:26:51 +08:00
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
2018-12-19 21:05:17 +08:00
/******/ resolves.push(installedChunks[chunkId][0]);
/******/ }
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
2020-05-21 05:26:51 +08:00
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
2018-12-19 21:05:17 +08:00
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
/******/ if(runtime) runtime(__webpack_require__);
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
2018-12-19 21:05:17 +08:00
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ // add entry modules from loaded chunk to deferred list
/******/ if(executeModules) deferredModules.push.apply(deferredModules, executeModules);
/******/
/******/ // run deferred modules when all chunks ready
/******/ return checkDeferredModules();
2020-09-21 04:39:12 +08:00
/******/ }
2018-12-19 21:05:17 +08:00
/******/
2020-09-21 04:39:12 +08:00
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
/******/
/******/ function checkDeferredModulesImpl() {
/******/ var result;
/******/ for(var i = 0; i < deferredModules.length; i++) {
/******/ var deferredModule = deferredModules[i];
/******/ var fulfilled = true;
/******/ for(var j = 1; j < deferredModule.length; j++) {
/******/ var depId = deferredModule[j];
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
/******/ }
/******/ if(fulfilled) {
/******/ deferredModules.splice(i--, 1);
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
/******/ }
/******/ }
/******/ if(deferredModules.length === 0) {
/******/ __webpack_require__.x();
/******/ __webpack_require__.x = x => {};
/******/ }
/******/ return result;
/******/ }
/******/ var startup = __webpack_require__.x;
/******/ __webpack_require__.x = () => {
/******/ // reset startup function so it can be called again when more startup code is added
/******/ __webpack_require__.x = startup || (x => {});
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
2018-12-19 21:05:17 +08:00
/******/
2019-10-11 05:11:05 +08:00
/************************************************************************/
```
</details>
``` js
2019-10-11 05:11:05 +08:00
/******/ // run startup
/******/ return __webpack_require__.x();
/******/ })()
;
```
2015-11-21 04:36:43 +08:00
# dist/main.[chunkhash].js
2015-11-21 04:36:43 +08:00
2019-04-09 02:29:40 +08:00
```javascript
2020-09-21 04:39:12 +08:00
(self["webpackChunk"] = self["webpackChunk"] || []).push([[0],[
2017-12-14 17:58:03 +08:00
/* 0 */
2015-11-21 04:36:43 +08:00
/*!********************!*\
!*** ./example.js ***!
\********************/
2020-05-21 05:26:51 +08:00
/*! unknown exports (runtime-defined) */
2019-10-11 05:11:05 +08:00
/*! runtime requirements: __webpack_require__.e, __webpack_require__.t, __webpack_require__.* */
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
2015-11-21 04:36:43 +08:00
2016-09-07 18:28:56 +08:00
// some module
__webpack_require__.e(/*! import() */ 2).then(__webpack_require__.t.bind(__webpack_require__, /*! ./async1 */ 1, 23));
__webpack_require__.e(/*! import() */ 3).then(__webpack_require__.t.bind(__webpack_require__, /*! ./async2 */ 2, 23));
2015-11-21 04:36:43 +08:00
2017-02-13 15:49:35 +08:00
/***/ })
2020-09-21 04:39:12 +08:00
],
0,[[0,1]]]);
2015-11-21 04:36:43 +08:00
```
# Info
2017-12-14 17:58:03 +08:00
## Unoptimized
2015-11-21 04:36:43 +08:00
```
asset runtime~main.[chunkhash].js 12.5 KiB [emitted] (name: runtime~main)
asset main.[chunkhash].js 652 bytes [emitted] (name: main)
2020-09-21 04:39:12 +08:00
asset 2.[chunkhash].js 285 bytes [emitted]
asset 3.[chunkhash].js 279 bytes [emitted]
Entrypoint main 13.1 KiB = runtime~main.[chunkhash].js 12.5 KiB main.[chunkhash].js 652 bytes
chunk (runtime: runtime~main) main.[chunkhash].js (main) 55 bytes [initial] [rendered]
2020-09-21 04:39:12 +08:00
> ./example main
./example.js 55 bytes [built] [code generated]
[used exports unknown]
entry ./example main
chunk (runtime: runtime~main) runtime~main.[chunkhash].js (runtime~main) 7.7 KiB [entry] [rendered]
2020-09-21 04:39:12 +08:00
> ./example main
runtime modules 7.7 KiB 9 modules
chunk (runtime: runtime~main) 2.[chunkhash].js 28 bytes [rendered]
2020-09-21 04:39:12 +08:00
> ./async1 ./example.js 2:0-18
./async1.js 28 bytes [built] [code generated]
[used exports unknown]
import() ./async1 ./example.js 2:0-18
chunk (runtime: runtime~main) 3.[chunkhash].js 28 bytes [rendered]
2020-09-21 04:39:12 +08:00
> ./async2 ./example.js 3:0-18
./async2.js 28 bytes [built] [code generated]
[used exports unknown]
import() ./async2 ./example.js 3:0-18
webpack 5.11.1 compiled successfully
2015-11-21 04:36:43 +08:00
```
2017-12-14 17:58:03 +08:00
## Production mode
2015-11-21 04:36:43 +08:00
```
asset runtime~main.[chunkhash].js 2.63 KiB [emitted] [minimized] (name: runtime~main)
asset main.[chunkhash].js 155 bytes [emitted] [minimized] (name: main)
2020-09-21 04:39:12 +08:00
asset 114.[chunkhash].js 69 bytes [emitted] [minimized]
asset 172.[chunkhash].js 69 bytes [emitted] [minimized]
Entrypoint main 2.78 KiB = runtime~main.[chunkhash].js 2.63 KiB main.[chunkhash].js 155 bytes
2020-09-21 04:39:12 +08:00
chunk (runtime: runtime~main) 114.[chunkhash].js 28 bytes [rendered]
> ./async1 ./example.js 2:0-18
./async1.js 28 bytes [built] [code generated]
[used exports unknown]
import() ./async1 ./example.js 2:0-18
chunk (runtime: runtime~main) 172.[chunkhash].js 28 bytes [rendered]
> ./async2 ./example.js 3:0-18
./async2.js 28 bytes [built] [code generated]
[used exports unknown]
import() ./async2 ./example.js 3:0-18
chunk (runtime: runtime~main) main.[chunkhash].js (main) 55 bytes [initial] [rendered]
> ./example main
./example.js 55 bytes [built] [code generated]
[no exports used]
entry ./example main
chunk (runtime: runtime~main) runtime~main.[chunkhash].js (runtime~main) 7.7 KiB [entry] [rendered]
2020-09-21 04:39:12 +08:00
> ./example main
runtime modules 7.7 KiB 9 modules
webpack 5.11.1 compiled successfully
2017-12-14 17:58:03 +08:00
```