webpack/examples/multiple-entry-points/README.md

773 lines
28 KiB
Markdown
Raw Normal View History

This example shows how to use multiple entry points with a commons chunk.
2014-07-24 17:29:49 +08:00
2020-05-21 05:26:51 +08:00
In this example, you have two (HTML) pages `pageA` and `pageB`. You want to create individual bundles for each page. In addition to this, you want to create a shared bundle that contains all the modules used in both pages (assuming there are many/big modules in common). The pages also use Code Splitting to load a less used part of the features on demand.
2014-07-24 17:29:49 +08:00
You can see how to define multiple entry points via the `entry` option.
2018-02-21 22:21:05 +08:00
You can use
2014-07-24 17:29:49 +08:00
You can see the output files:
2019-04-09 02:29:40 +08:00
- `commons.js` contains:
- module `common.js` which is used in both pages
- `pageA.js` contains: (`pageB.js` is similar)
- the module system
- chunk loading logic
- the entry point `pageA.js`
- it would contain any other module that is only used by `pageA`
2019-05-10 03:34:28 +08:00
- `406.js` is an additional chunk which is used by both pages. It contains:
2019-04-09 02:29:40 +08:00
- module `shared.js`
2014-07-24 17:29:49 +08:00
You can also see the info that is printed to console. It shows among others:
2019-04-09 02:29:40 +08:00
- the generated files
- the chunks with file, name, and id
2019-04-09 02:29:40 +08:00
- see lines starting with `chunk`
- the modules that are in the chunks
- the reasons why the modules are included
- the reasons why a chunk is created
- see lines starting with `>`
2014-07-24 17:29:49 +08:00
2013-11-20 01:09:26 +08:00
# pageA.js
2019-04-09 02:29:40 +08:00
```javascript
var common = require("./common");
2013-11-20 01:09:26 +08:00
require(["./shared"], function(shared) {
shared("This is page A");
});
```
# pageB.js
2019-04-09 02:29:40 +08:00
```javascript
var common = require("./common");
2013-11-20 01:09:26 +08:00
require.ensure(["./shared"], function(require) {
var shared = require("./shared");
shared("This is page B");
});
```
# webpack.config.js
2019-04-09 02:29:40 +08:00
```javascript
2013-11-20 01:09:26 +08:00
module.exports = {
2017-12-14 17:58:03 +08:00
// mode: "development || "production",
2013-11-20 01:09:26 +08:00
entry: {
pageA: "./pageA",
pageB: "./pageB"
},
2017-12-14 17:58:03 +08:00
optimization: {
splitChunks: {
cacheGroups: {
commons: {
name: "commons",
chunks: "initial",
minChunks: 2,
minSize: 0
}
}
},
2018-12-19 21:05:17 +08:00
chunkIds: "deterministic" // To keep filename consistent between different modes (for example building only)
2017-12-14 17:58:03 +08:00
}
2017-03-31 02:25:01 +08:00
};
2013-11-20 01:09:26 +08:00
```
# pageA.html
2019-04-09 02:29:40 +08:00
```html
<html>
<head></head>
<body>
2013-12-03 18:19:30 +08:00
<script src="js/commons.js" charset="utf-8"></script>
<script src="js/pageA.bundle.js" charset="utf-8"></script>
</body>
</html>
```
# dist/commons.js
2013-11-20 01:09:26 +08:00
2019-04-09 02:29:40 +08:00
```javascript
2020-09-21 04:39:12 +08:00
(self["webpackChunk"] = self["webpackChunk"] || []).push([[351],[
/* 0 */,
/* 1 */
/*!*******************!*\
!*** ./common.js ***!
\*******************/
2020-05-21 05:26:51 +08:00
/*! unknown exports (runtime-defined) */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
2020-09-21 04:39:12 +08:00
/*! CommonJS bailout: module.exports is used directly at 1:0-14 */
2019-10-09 05:45:47 +08:00
/***/ ((module) => {
module.exports = "Common";
/***/ })
]]);
```
# dist/pageA.js
2019-04-09 02:29:40 +08:00
```javascript
2019-10-11 05:11:05 +08:00
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */
/*!******************!*\
!*** ./pageA.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__, __webpack_require__.e, __webpack_require__.oe, __webpack_require__.* */
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
var common = __webpack_require__(/*! ./common */ 1);
__webpack_require__.e(/*! AMD require */ 52).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./shared */ 3)]; (function(shared) {
shared("This is page A");
}).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}).catch(__webpack_require__.oe);
/***/ })
/******/ ]);
```
<details><summary><code>/* webpack runtime code */</code></summary>
``` js
2019-10-11 05:11:05 +08:00
/************************************************************************/
2013-11-20 01:09:26 +08:00
/******/ // The module cache
2019-10-11 05:11:05 +08:00
/******/ var __webpack_module_cache__ = {};
/******/
2013-11-20 01:09:26 +08:00
/******/ // The require function
2014-03-25 17:44:10 +08:00
/******/ function __webpack_require__(moduleId) {
2013-11-20 01:09:26 +08:00
/******/ // 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;
2017-05-23 04:45:18 +08:00
/******/ }
2013-11-20 01:09:26 +08:00
/******/ // 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
2016-06-06 02:51:44 +08:00
/******/ exports: {}
2013-11-20 01:09:26 +08:00
/******/ };
2019-10-11 05:11:05 +08:00
/******/
2013-11-20 01:09:26 +08:00
/******/ // Execute the module function
2019-10-11 05:11:05 +08:00
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
2013-11-20 01:09:26 +08:00
/******/ // Return the exports of the module
2014-03-25 17:44:10 +08:00
/******/ return module.exports;
2013-11-20 01:09:26 +08:00
/******/ }
2019-10-11 05:11:05 +08:00
/******/
2013-11-20 01:09:26 +08:00
/******/ // expose the modules object (__webpack_modules__)
2019-10-11 05:11:05 +08:00
/******/ __webpack_require__.m = __webpack_modules__;
/******/
2013-11-20 01:09:26 +08:00
/************************************************************************/
2018-12-19 21:05:17 +08:00
/******/ /* webpack/runtime/ensure chunk */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2018-12-19 21:05:17 +08:00
/******/ __webpack_require__.f = {};
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
2019-10-09 05:45:47 +08:00
/******/ __webpack_require__.e = (chunkId) => {
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
2019-08-05 19:32:25 +08:00
/******/ __webpack_require__.f[key](chunkId, promises);
/******/ return promises;
/******/ }, []));
2018-12-19 21:05:17 +08:00
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
2018-12-19 21:05:17 +08:00
/******/
/******/ /* webpack/runtime/get javascript chunk filename */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2019-05-10 03:34:28 +08:00
/******/ // This function allow to reference async chunks
2019-10-09 05:45:47 +08:00
/******/ __webpack_require__.u = (chunkId) => {
2019-02-05 01:52:39 +08:00
/******/ // return url for filenames based on template
2018-12-19 21:05:17 +08:00
/******/ return "" + chunkId + ".js";
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
/******/ })();
2018-12-19 21:05:17 +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);
/******/ };
/******/ })();
/******/
2019-11-15 07:06:30 +08:00
/******/ /* webpack/runtime/publicPath */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2019-11-15 07:06:30 +08:00
/******/ __webpack_require__.p = "dist/";
2020-05-21 05:26:51 +08:00
/******/ })();
2019-11-15 07:06:30 +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 = {
2019-05-10 03:34:28 +08:00
/******/ 424: 0
2018-12-19 21:05:17 +08:00
/******/ };
/******/
/******/ var deferredModules = [
2019-05-10 03:34:28 +08:00
/******/ [0,351]
2018-12-19 21:05:17 +08:00
/******/ ];
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".
/******/
/******/ // 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);
/******/
/******/ // 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
/******/
2019-10-09 05:45:47 +08:00
/******/ var checkDeferredModules = () => {
/******/
/******/ };
2018-12-19 21:05:17 +08:00
/******/ 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]);
/******/ }
/******/ }
2020-05-21 05:26:51 +08:00
/******/ if(deferredModules.length === 0) {
/******/ __webpack_require__.x();
/******/ __webpack_require__.x = () => {
/******/
/******/ }
/******/ }
2018-12-19 21:05:17 +08:00
/******/ return result;
/******/ }
2019-10-09 05:45:47 +08:00
/******/ __webpack_require__.x = () => {
2020-05-21 05:26:51 +08:00
/******/ // reset startup function so it can be called again when more startup code is added
/******/ __webpack_require__.x = () => {
/******/
/******/ }
2020-09-21 04:39:12 +08:00
/******/ chunkLoadingGlobal = chunkLoadingGlobal.slice();
/******/ for(var i = 0; i < chunkLoadingGlobal.length; i++) webpackJsonpCallback(chunkLoadingGlobal[i]);
2018-12-19 21:05:17 +08:00
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
/******/ };
/******/
/******/ // install a JSONP callback for chunk loading
2020-09-21 04:39:12 +08:00
/******/ var webpackJsonpCallback = (data) => {
/******/ 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;
/******/ }
2018-12-19 21:05:17 +08:00
/******/ 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];
/******/ }
/******/ }
2018-12-19 21:05:17 +08:00
/******/ if(runtime) runtime(__webpack_require__);
2020-09-21 04:39:12 +08:00
/******/ 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"] || [];
/******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
/******/ chunkLoadingGlobal.push = webpackJsonpCallback;
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();
/******/ })()
;
2018-12-19 21:05:17 +08:00
```
# dist/pageB.js
2019-05-10 03:34:28 +08:00
```javascript
2019-10-11 05:11:05 +08:00
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 2:
/*!******************!*\
!*** ./pageB.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__, __webpack_require__.e, __webpack_require__.* */
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
var common = __webpack_require__(/*! ./common */ 1);
__webpack_require__.e(/*! require.ensure */ 52).then((function(require) {
var shared = __webpack_require__(/*! ./shared */ 3);
shared("This is page B");
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
/***/ })
/******/ });
```
<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
/******/
/******/ // expose the modules object (__webpack_modules__)
2019-10-11 05:11:05 +08:00
/******/ __webpack_require__.m = __webpack_modules__;
/******/
/************************************************************************/
2018-12-19 21:05:17 +08:00
/******/ /* webpack/runtime/ensure chunk */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2018-12-19 21:05:17 +08:00
/******/ __webpack_require__.f = {};
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
2019-10-09 05:45:47 +08:00
/******/ __webpack_require__.e = (chunkId) => {
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
2019-08-05 19:32:25 +08:00
/******/ __webpack_require__.f[key](chunkId, promises);
/******/ return promises;
/******/ }, []));
2018-12-19 21:05:17 +08:00
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
2018-12-19 21:05:17 +08:00
/******/
/******/ /* webpack/runtime/get javascript chunk filename */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2019-05-10 03:34:28 +08:00
/******/ // This function allow to reference async chunks
2019-10-09 05:45:47 +08:00
/******/ __webpack_require__.u = (chunkId) => {
2019-02-05 01:52:39 +08:00
/******/ // return url for filenames based on template
2018-12-19 21:05:17 +08:00
/******/ return "" + chunkId + ".js";
/******/ };
2020-05-21 05:26:51 +08:00
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
/******/ })();
2018-12-19 21:05:17 +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);
/******/ };
/******/ })();
/******/
2019-11-15 07:06:30 +08:00
/******/ /* webpack/runtime/publicPath */
2020-05-21 05:26:51 +08:00
/******/ (() => {
2019-11-15 07:06:30 +08:00
/******/ __webpack_require__.p = "dist/";
2020-05-21 05:26:51 +08:00
/******/ })();
2019-11-15 07:06:30 +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 = {
2019-05-10 03:34:28 +08:00
/******/ 121: 0
2018-12-19 21:05:17 +08:00
/******/ };
/******/
/******/ var deferredModules = [
2019-05-10 03:34:28 +08:00
/******/ [2,351]
2018-12-19 21:05:17 +08:00
/******/ ];
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".
/******/
/******/ // 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);
/******/
/******/ // 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
/******/
2019-10-09 05:45:47 +08:00
/******/ var checkDeferredModules = () => {
/******/
/******/ };
2018-12-19 21:05:17 +08:00
/******/ 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]);
/******/ }
/******/ }
2020-05-21 05:26:51 +08:00
/******/ if(deferredModules.length === 0) {
/******/ __webpack_require__.x();
/******/ __webpack_require__.x = () => {
/******/
/******/ }
/******/ }
2018-12-19 21:05:17 +08:00
/******/ return result;
/******/ }
2019-10-09 05:45:47 +08:00
/******/ __webpack_require__.x = () => {
2020-05-21 05:26:51 +08:00
/******/ // reset startup function so it can be called again when more startup code is added
/******/ __webpack_require__.x = () => {
/******/
/******/ }
2020-09-21 04:39:12 +08:00
/******/ chunkLoadingGlobal = chunkLoadingGlobal.slice();
/******/ for(var i = 0; i < chunkLoadingGlobal.length; i++) webpackJsonpCallback(chunkLoadingGlobal[i]);
2018-12-19 21:05:17 +08:00
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
/******/ };
/******/
/******/ // install a JSONP callback for chunk loading
2020-09-21 04:39:12 +08:00
/******/ var webpackJsonpCallback = (data) => {
/******/ 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__);
2020-09-21 04:39:12 +08:00
/******/ 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"] || [];
/******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
/******/ chunkLoadingGlobal.push = webpackJsonpCallback;
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();
/******/ })()
;
2013-11-20 01:09:26 +08:00
```
2019-05-10 03:34:28 +08:00
# dist/52.js
2013-11-20 01:09:26 +08:00
2019-04-09 02:29:40 +08:00
```javascript
2020-09-21 04:39:12 +08:00
(self["webpackChunk"] = self["webpackChunk"] || []).push([[52],{
2018-09-26 05:13:58 +08:00
/***/ 3:
2013-11-20 01:09:26 +08:00
/*!*******************!*\
!*** ./shared.js ***!
\*******************/
2020-05-21 05:26:51 +08:00
/*! unknown exports (runtime-defined) */
/*! runtime requirements: module, __webpack_require__ */
2020-09-21 04:39:12 +08:00
/*! CommonJS bailout: module.exports is used directly at 2:0-14 */
2019-10-11 05:11:05 +08:00
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2013-11-20 01:09:26 +08:00
2017-12-21 18:19:53 +08:00
var common = __webpack_require__(/*! ./common */ 1);
2016-09-07 18:28:56 +08:00
module.exports = function(msg) {
console.log(msg);
};
2013-11-20 01:09:26 +08:00
2017-03-31 02:25:01 +08:00
/***/ })
2018-09-26 05:13:58 +08:00
}]);
2013-11-20 01:09:26 +08:00
```
# Info
2017-12-14 17:58:03 +08:00
## Unoptimized
2013-11-20 01:09:26 +08:00
```
2020-09-21 04:39:12 +08:00
asset pageA.js 10.6 KiB [emitted] (name: pageA)
asset pageB.js 10.5 KiB [emitted] (name: pageB)
asset 52.js 506 bytes [emitted]
asset commons.js 364 bytes [emitted] (name: commons) (id hint: commons)
Entrypoint pageA 10.9 KiB = commons.js 364 bytes pageA.js 10.6 KiB
Entrypoint pageB 10.9 KiB = commons.js 364 bytes pageB.js 10.5 KiB
2019-10-11 05:11:05 +08:00
chunk 52.js 88 bytes [rendered]
2020-09-21 04:39:12 +08:00
> ./shared ./pageA.js 2:0-4:2
> ./pageB.js 2:0-5:2
./shared.js 88 bytes [built] [code generated]
[used exports unknown]
amd require ./shared ./pageA.js 2:0-4:2
require.ensure item ./shared ./pageB.js 2:0-5:2
cjs require ./shared ./pageB.js 3:14-33
cjs self exports reference ./shared.js 2:0-14
chunk pageB.js (pageB) 148 bytes (javascript) 6.03 KiB (runtime) [entry] [rendered]
> ./pageB pageB
runtime modules 6.03 KiB 6 modules
./pageB.js 148 bytes [built] [code generated]
[used exports unknown]
entry ./pageB pageB
2019-10-11 05:11:05 +08:00
chunk commons.js (commons) (id hint: commons) 26 bytes [initial] [rendered] split chunk (cache group: commons) (name: commons)
2020-09-21 04:39:12 +08:00
> ./pageA pageA
> ./pageB pageB
./common.js 26 bytes [built] [code generated]
[used exports unknown]
cjs self exports reference ./common.js 1:0-14
cjs require ./common ./pageA.js 1:13-32
cjs require ./common ./pageB.js 1:13-32
cjs require ./common ./shared.js 1:13-32
chunk pageA.js (pageA) 105 bytes (javascript) 6.03 KiB (runtime) [entry] [rendered]
> ./pageA pageA
runtime modules 6.03 KiB 6 modules
./pageA.js 105 bytes [built] [code generated]
[used exports unknown]
entry ./pageA pageA
2020-10-11 04:06:28 +08:00
webpack 5.0.0 compiled successfully
2013-11-20 01:09:26 +08:00
```
2017-12-14 17:58:03 +08:00
## Production mode
2013-11-20 01:09:26 +08:00
```
2020-09-21 04:39:12 +08:00
asset pageA.js 2.02 KiB [emitted] [minimized] (name: pageA)
asset pageB.js 2 KiB [emitted] [minimized] (name: pageB)
asset 52.js 116 bytes [emitted] [minimized]
asset commons.js 86 bytes [emitted] [minimized] (name: commons) (id hint: commons)
Entrypoint pageA 2.11 KiB = commons.js 86 bytes pageA.js 2.02 KiB
Entrypoint pageB 2.08 KiB = commons.js 86 bytes pageB.js 2 KiB
chunk (runtime: pageA, pageB) 52.js 88 bytes [rendered]
> ./shared ./pageA.js 2:0-4:2
> ./pageB.js 2:0-5:2
./shared.js 88 bytes [built] [code generated]
[used exports unknown]
amd require ./shared ./pageA.js 2:0-4:2
require.ensure item ./shared ./pageB.js 2:0-5:2
cjs require ./shared ./pageB.js 3:14-33
cjs self exports reference ./shared.js 2:0-14
chunk (runtime: pageB) pageB.js (pageB) 148 bytes (javascript) 6.04 KiB (runtime) [entry] [rendered]
> ./pageB pageB
runtime modules 6.04 KiB 6 modules
./pageB.js 148 bytes [built] [code generated]
[no exports used]
entry ./pageB pageB
chunk (runtime: pageA, pageB) commons.js (commons) (id hint: commons) 26 bytes [initial] [rendered] split chunk (cache group: commons) (name: commons)
> ./pageA pageA
> ./pageB pageB
./common.js 26 bytes [built] [code generated]
[used exports unknown]
cjs self exports reference ./common.js 1:0-14
cjs require ./common ./pageA.js 1:13-32
cjs require ./common ./pageB.js 1:13-32
cjs require ./common ./shared.js 1:13-32
chunk (runtime: pageA) pageA.js (pageA) 105 bytes (javascript) 6.04 KiB (runtime) [entry] [rendered]
> ./pageA pageA
runtime modules 6.04 KiB 6 modules
./pageA.js 105 bytes [built] [code generated]
[no exports used]
entry ./pageA pageA
2020-10-11 04:06:28 +08:00
webpack 5.0.0 compiled successfully
2013-11-20 01:09:26 +08:00
```