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

686 lines
23 KiB
Markdown
Raw Permalink Normal View History

This example shows how to use multiple entry points with a commons chunk.
2014-07-24 17:29:49 +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 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:
* `commons.js` contains:
* module `common.js` which is used in both pages
* `pageA.js` contains: (`pageB.js` is similar)
2018-02-21 22:21:05 +08:00
* the module system
* chunk loading logic
2014-07-24 17:29:49 +08:00
* the entry point `pageA.js`
* it would contain any other module that is only used by `pageA`
2018-09-26 05:13:58 +08:00
* `1.js` is an additional chunk which is used by both pages. It contains:
2014-07-24 17:29:49 +08:00
* module `shared.js`
You can also see the info that is printed to console. It shows among others:
* the generated files
* the chunks with file, name and id
* see lines starting with `chunk`
* the modules that are in the chunks
2014-07-24 17:29:49 +08:00
* the reasons why the modules are included
* the reasons why a chunk is created
* see lines starting with `>`
2013-11-20 01:09:26 +08:00
# pageA.js
``` javascript
var common = require("./common");
2013-11-20 01:09:26 +08:00
require(["./shared"], function(shared) {
shared("This is page A");
});
```
# pageB.js
``` 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
``` javascript
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
``` 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
``` javascript
2018-12-19 21:05:17 +08:00
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[987],[
/* 0 */,
/* 1 */
/*!*******************!*\
!*** ./common.js ***!
\*******************/
/*! no static exports found */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
/***/ (function(module) {
module.exports = "Common";
/***/ })
]]);
```
# dist/pageA.js
2017-03-31 02:42:42 +08:00
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
2013-11-20 01:09:26 +08:00
``` javascript
2018-12-19 21:05:17 +08:00
/******/ (function(modules, runtime) { // webpackBootstrap
/******/ "use strict";
2013-11-20 01:09:26 +08:00
/******/ // The module cache
/******/ var installedModules = {};
2017-03-31 02:25:01 +08:00
/******/
2013-11-20 01:09:26 +08:00
/******/ // The require function
2014-03-25 17:44:10 +08:00
/******/ function __webpack_require__(moduleId) {
2017-03-31 02:25:01 +08:00
/******/
2013-11-20 01:09:26 +08:00
/******/ // Check if module is in cache
2017-05-23 04:45:18 +08:00
/******/ if(installedModules[moduleId]) {
2014-03-25 17:44:10 +08:00
/******/ return installedModules[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)
/******/ var module = installedModules[moduleId] = {
2016-06-06 02:51:44 +08:00
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
2013-11-20 01:09:26 +08:00
/******/ };
2017-03-31 02:25:01 +08:00
/******/
2013-11-20 01:09:26 +08:00
/******/ // Execute the module function
2014-03-25 17:44:10 +08:00
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
2017-03-31 02:25:01 +08:00
/******/
2013-11-20 01:09:26 +08:00
/******/ // Flag the module as loaded
2016-06-06 02:51:44 +08:00
/******/ module.l = true;
2017-03-31 02:25:01 +08:00
/******/
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
/******/ }
2017-03-31 02:25:01 +08:00
/******/
/******/
2013-11-20 01:09:26 +08:00
/******/ // expose the modules object (__webpack_modules__)
2014-03-25 17:44:10 +08:00
/******/ __webpack_require__.m = modules;
2017-03-31 02:25:01 +08:00
/******/
2018-12-19 21:05:17 +08:00
/******/ // initialize runtime
/******/ runtime(__webpack_require__);
2017-11-24 15:40:39 +08:00
/******/
2018-12-19 21:05:17 +08:00
/******/ // run modules when ready
/******/ return __webpack_require__.x();
2013-11-20 01:09:26 +08:00
/******/ })
/************************************************************************/
2016-09-07 18:28:56 +08:00
```
2017-03-31 02:42:42 +08:00
2016-09-07 18:28:56 +08:00
</details>
2017-03-31 02:42:42 +08:00
2016-09-07 18:28:56 +08:00
``` javascript
2018-09-26 05:13:58 +08:00
/******/ ([
/* 0 */
2013-11-20 01:09:26 +08:00
/*!******************!*\
!*** ./pageA.js ***!
\******************/
2017-06-05 22:12:12 +08:00
/*! no static exports found */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: __webpack_require__, __webpack_require__.e, __webpack_require__.oe */
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
2013-11-20 01:09:26 +08:00
2017-12-21 18:19:53 +08:00
var common = __webpack_require__(/*! ./common */ 1);
2018-12-19 21:05:17 +08:00
__webpack_require__.e(/*! AMD require */ 406).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./shared */ 3)]; (function(shared) {
2016-09-07 18:28:56 +08:00
shared("This is page A");
2018-01-03 18:03:20 +08:00
}).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}).catch(__webpack_require__.oe);
2013-11-20 01:09:26 +08:00
2017-03-31 02:25:01 +08:00
/***/ })
2018-12-19 21:05:17 +08:00
/******/ ],
2013-11-20 01:09:26 +08:00
```
2018-12-19 21:05:17 +08:00
<details><summary><code>function(__webpack_require__) { /* webpackRuntimeModules */ });</code></summary>
``` js
/******/ function(__webpack_require__) { // webpackRuntimeModules
/******/ "use strict";
/******/
/******/ /* webpack/runtime/ensure chunk */
/******/ !function() {
/******/ __webpack_require__.f = {};
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) { __webpack_require__.f[key](chunkId, promises); return promises; }, []));
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/publicPath */
/******/ !function() {
/******/ __webpack_require__.p = "dist/";
/******/ }();
/******/
/******/ /* webpack/runtime/get javascript chunk filename */
/******/ !function() {
/******/ __webpack_require__.u = function(chunkId) {
/******/ return "" + chunkId + ".js";
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/jsonp chunk loading */
/******/ !function() {
/******/
/******/
/******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ // Promise = chunk loading, 0 = chunk loaded
/******/ var installedChunks = {
/******/ 641: 0
/******/ };
/******/
/******/ var deferredModules = [
/******/ [0,987]
/******/ ];
/******/
/******/ __webpack_require__.f.j = function(chunkId, promises) {
/******/ // JSONP chunk loading for javascript
/******/ var installedChunkData = installedChunks[chunkId];
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
/******/ // a Promise means "currently loading".
/******/ if(installedChunkData) {
/******/ promises.push(installedChunkData[2]);
/******/ } else {
/******/ // setup Promise in chunk cache
/******/ var promise = new Promise(function(resolve, reject) {
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
/******/ });
/******/ promises.push(installedChunkData[2] = promise);
/******/
/******/ // start chunk loading
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
/******/ var loadingEnded = function() { if(installedChunks[chunkId]) return installedChunks[chunkId][1]; if(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined; };
/******/ var script = document.createElement('script');
/******/ var onScriptComplete;
/******/
/******/ script.charset = 'utf-8';
/******/ script.timeout = 120;
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = url;
/******/
/******/ onScriptComplete = function (event) {
/******/ // avoid mem leaks in IE.
/******/ script.onerror = script.onload = null;
/******/ clearTimeout(timeout);
/******/ var reportError = loadingEnded();
/******/ if(reportError) {
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
/******/ var realSrc = event && event.target && event.target.src;
/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
/******/ error.type = errorType;
/******/ error.request = realSrc;
/******/ reportError(error);
/******/ }
/******/ };
/******/ var timeout = setTimeout(function(){
/******/ onScriptComplete({ type: 'timeout', target: script });
/******/ }, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ document.head.appendChild(script);
/******/
/******/ // no HMR
/******/ }
/******/ }
2018-12-19 21:05:17 +08:00
/******/
/******/ // no chunk preloading needed
/******/ };
/******/
/******/ // no prefetching
/******/
/******/ // no HMR
/******/
/******/ // no HMR manifest
/******/
/******/ var checkDeferredModules = function() {};
/******/ 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]);
/******/ }
/******/ }
2018-12-19 21:05:17 +08:00
/******/ return result;
/******/ }
2018-12-19 21:05:17 +08:00
/******/ __webpack_require__.x = function() {
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
/******/ };
/******/
/******/ // install a JSONP callback for chunk loading
/******/ function webpackJsonpCallback(data) {
/******/ var chunkIds = data[0];
/******/ var moreModules = data[1];
/******/ var executeModules = data[2];
/******/ var runtime = data[3];
/******/
/******/ // 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];
/******/ if(installedChunks[chunkId]) {
/******/ resolves.push(installedChunks[chunkId][0]);
/******/ }
/******/ installedChunks[chunkId] = 0;
/******/ }
2018-12-19 21:05:17 +08:00
/******/ for(moduleId in moreModules) {
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
2018-12-19 21:05:17 +08:00
/******/ if(runtime) runtime(__webpack_require__);
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/
/******/ 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();
/******/ };
/******/
/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
/******/ jsonpArray.push = webpackJsonpCallback;
/******/ jsonpArray = jsonpArray.slice();
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
/******/ var parentJsonpFunction = oldJsonpFunction;
/******/ }();
/******/
/******/ }
);
```
</details>
# dist/pageB.js
``` javascript
/******/ (function(modules, runtime) { // webpackBootstrap
/******/ "use strict";
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
2018-12-19 21:05:17 +08:00
/******/ // initialize runtime
/******/ runtime(__webpack_require__);
/******/
2018-12-19 21:05:17 +08:00
/******/ // run modules when ready
/******/ return __webpack_require__.x();
/******/ })
/************************************************************************/
/******/ ({
2016-02-04 20:02:53 +08:00
2017-12-21 18:19:53 +08:00
/***/ 2:
2013-11-20 01:09:26 +08:00
/*!******************!*\
!*** ./pageB.js ***!
\******************/
2017-06-05 22:12:12 +08:00
/*! no static exports found */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: __webpack_require__, __webpack_require__.e */
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
2013-11-20 01:09:26 +08:00
2017-12-21 18:19:53 +08:00
var common = __webpack_require__(/*! ./common */ 1);
2018-12-19 21:05:17 +08:00
__webpack_require__.e(/*! require.ensure */ 406).then((function(require) {
2018-09-26 05:13:58 +08:00
var shared = __webpack_require__(/*! ./shared */ 3);
2016-09-07 18:28:56 +08:00
shared("This is page B");
2016-12-14 19:03:24 +08:00
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
2013-11-20 01:09:26 +08:00
2017-03-31 02:25:01 +08:00
/***/ })
2016-02-04 20:02:53 +08:00
2018-12-19 21:05:17 +08:00
/******/ },
/******/ function(__webpack_require__) { // webpackRuntimeModules
/******/ "use strict";
/******/
/******/ /* webpack/runtime/ensure chunk */
/******/ !function() {
/******/ __webpack_require__.f = {};
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) { __webpack_require__.f[key](chunkId, promises); return promises; }, []));
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/publicPath */
/******/ !function() {
/******/ __webpack_require__.p = "dist/";
/******/ }();
/******/
/******/ /* webpack/runtime/get javascript chunk filename */
/******/ !function() {
/******/ __webpack_require__.u = function(chunkId) {
/******/ return "" + chunkId + ".js";
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/jsonp chunk loading */
/******/ !function() {
/******/
/******/
/******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ // Promise = chunk loading, 0 = chunk loaded
/******/ var installedChunks = {
/******/ 791: 0
/******/ };
/******/
/******/ var deferredModules = [
/******/ [2,987]
/******/ ];
/******/
/******/ __webpack_require__.f.j = function(chunkId, promises) {
/******/ // JSONP chunk loading for javascript
/******/ var installedChunkData = installedChunks[chunkId];
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
/******/ // a Promise means "currently loading".
/******/ if(installedChunkData) {
/******/ promises.push(installedChunkData[2]);
/******/ } else {
/******/ // setup Promise in chunk cache
/******/ var promise = new Promise(function(resolve, reject) {
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
/******/ });
/******/ promises.push(installedChunkData[2] = promise);
/******/
/******/ // start chunk loading
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
/******/ var loadingEnded = function() { if(installedChunks[chunkId]) return installedChunks[chunkId][1]; if(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined; };
/******/ var script = document.createElement('script');
/******/ var onScriptComplete;
/******/
/******/ script.charset = 'utf-8';
/******/ script.timeout = 120;
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = url;
/******/
/******/ onScriptComplete = function (event) {
/******/ // avoid mem leaks in IE.
/******/ script.onerror = script.onload = null;
/******/ clearTimeout(timeout);
/******/ var reportError = loadingEnded();
/******/ if(reportError) {
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
/******/ var realSrc = event && event.target && event.target.src;
/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
/******/ error.type = errorType;
/******/ error.request = realSrc;
/******/ reportError(error);
/******/ }
/******/ };
/******/ var timeout = setTimeout(function(){
/******/ onScriptComplete({ type: 'timeout', target: script });
/******/ }, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ document.head.appendChild(script);
/******/
/******/ // no HMR
/******/ }
/******/ }
/******/
/******/ // no chunk preloading needed
/******/ };
/******/
/******/ // no prefetching
/******/
/******/ // no HMR
/******/
/******/ // no HMR manifest
/******/
/******/ var checkDeferredModules = function() {};
/******/ 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]);
/******/ }
/******/ }
/******/ return result;
/******/ }
/******/ __webpack_require__.x = function() {
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
/******/ };
/******/
/******/ // install a JSONP callback for chunk loading
/******/ function webpackJsonpCallback(data) {
/******/ var chunkIds = data[0];
/******/ var moreModules = data[1];
/******/ var executeModules = data[2];
/******/ var runtime = data[3];
/******/
/******/ // 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];
/******/ if(installedChunks[chunkId]) {
/******/ resolves.push(installedChunks[chunkId][0]);
/******/ }
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
/******/ if(runtime) runtime(__webpack_require__);
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/
/******/ 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();
/******/ };
/******/
/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
/******/ jsonpArray.push = webpackJsonpCallback;
/******/ jsonpArray = jsonpArray.slice();
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
/******/ var parentJsonpFunction = oldJsonpFunction;
/******/ }();
/******/
/******/ }
);
2013-11-20 01:09:26 +08:00
```
2018-12-19 21:05:17 +08:00
# dist/406.js
2013-11-20 01:09:26 +08:00
``` javascript
2018-12-19 21:05:17 +08:00
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[406],{
2018-09-26 05:13:58 +08:00
/***/ 3:
2013-11-20 01:09:26 +08:00
/*!*******************!*\
!*** ./shared.js ***!
\*******************/
2017-06-05 22:12:12 +08:00
/*! no static exports found */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: __webpack_require__, module */
/***/ (function(module, __unusedexports, __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
```
2017-12-14 17:58:03 +08:00
Hash: 0a1b2c3d4e5f6a7b8c9d
2018-09-26 05:13:58 +08:00
Version: webpack 5.0.0-next
Asset Size Chunks Chunk Names
2018-12-19 21:05:17 +08:00
406.js 430 bytes {406} [emitted]
commons.js 296 bytes {987} [emitted] commons
pageA.js 8.49 KiB {641} [emitted] pageA
pageB.js 8.42 KiB {791} [emitted] pageB
Entrypoint pageA = commons.js pageA.js
Entrypoint pageB = commons.js pageB.js
2018-12-19 21:05:17 +08:00
chunk {406} 406.js 88 bytes <{641}> <{791}> <{987}> [rendered]
2018-09-26 05:13:58 +08:00
> ./shared [0] ./pageA.js 2:0-4:2
> [2] ./pageB.js 2:0-5:2
2018-12-19 21:05:17 +08:00
[3] ./shared.js 88 bytes {406} [built]
2018-09-26 05:13:58 +08:00
[used exports unknown]
amd require ./shared [0] ./pageA.js 2:0-4:2
2018-05-07 18:36:38 +08:00
require.ensure item ./shared [2] ./pageB.js 2:0-5:2
cjs require ./shared [2] ./pageB.js 3:14-33
2018-12-19 21:05:17 +08:00
chunk {641} pageA.js (pageA) 105 bytes (javascript) 4.5 KiB (runtime) ={987}= >{406}< [entry] [rendered]
2018-02-21 22:21:05 +08:00
> ./pageA pageA
2018-12-19 21:05:17 +08:00
[0] ./pageA.js 105 bytes {641} [built]
2018-09-26 05:13:58 +08:00
[used exports unknown]
2018-12-19 21:05:17 +08:00
entry ./pageA pageA
+ 4 hidden chunk modules
chunk {791} pageB.js (pageB) 148 bytes (javascript) 4.5 KiB (runtime) ={987}= >{406}< [entry] [rendered]
2018-04-04 21:17:13 +08:00
> ./pageB pageB
2018-12-19 21:05:17 +08:00
[2] ./pageB.js 148 bytes {791} [built]
2018-09-26 05:13:58 +08:00
[used exports unknown]
2018-12-19 21:05:17 +08:00
entry ./pageB pageB
+ 4 hidden chunk modules
chunk {987} commons.js (commons) 26 bytes ={641}= ={791}= >{406}< [initial] [rendered] split chunk (cache group: commons) (name: commons)
> ./pageA pageA
2018-09-25 23:08:35 +08:00
> ./pageB pageB
2018-12-19 21:05:17 +08:00
[1] ./common.js 26 bytes {987} [built]
[used exports unknown]
cjs require ./common [0] ./pageA.js 1:13-32
cjs require ./common [2] ./pageB.js 1:13-32
cjs require ./common [3] ./shared.js 1:13-32
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
```
2017-12-14 17:58:03 +08:00
Hash: 0a1b2c3d4e5f6a7b8c9d
2018-09-26 05:13:58 +08:00
Version: webpack 5.0.0-next
Asset Size Chunks Chunk Names
2018-12-19 21:05:17 +08:00
406.js 128 bytes {406} [emitted]
commons.js 98 bytes {987} [emitted] commons
pageA.js 1.73 KiB {641} [emitted] pageA
pageB.js 1.71 KiB {791} [emitted] pageB
Entrypoint pageA = commons.js pageA.js
Entrypoint pageB = commons.js pageB.js
2018-12-19 21:05:17 +08:00
chunk {406} 406.js 88 bytes <{641}> <{791}> <{987}> [rendered]
> ./shared [953] ./pageA.js 2:0-4:2
> [954] ./pageB.js 2:0-5:2
[406] ./shared.js 88 bytes {406} [built]
amd require ./shared [953] ./pageA.js 2:0-4:2
require.ensure item ./shared [954] ./pageB.js 2:0-5:2
cjs require ./shared [954] ./pageB.js 3:14-33
chunk {641} pageA.js (pageA) 105 bytes (javascript) 4.5 KiB (runtime) ={987}= >{406}< [entry] [rendered]
2018-02-21 22:21:05 +08:00
> ./pageA pageA
2018-12-19 21:05:17 +08:00
[953] ./pageA.js 105 bytes {641} [built]
entry ./pageA pageA
+ 4 hidden chunk modules
chunk {791} pageB.js (pageB) 148 bytes (javascript) 4.5 KiB (runtime) ={987}= >{406}< [entry] [rendered]
2018-04-04 21:17:13 +08:00
> ./pageB pageB
2018-12-19 21:05:17 +08:00
[954] ./pageB.js 148 bytes {791} [built]
entry ./pageB pageB
+ 4 hidden chunk modules
chunk {987} commons.js (commons) 26 bytes ={641}= ={791}= >{406}< [initial] [rendered] split chunk (cache group: commons) (name: commons)
> ./pageA pageA
2018-09-25 23:08:35 +08:00
> ./pageB pageB
2018-12-19 21:05:17 +08:00
[280] ./common.js 26 bytes {987} [built]
cjs require ./common [406] ./shared.js 1:13-32
cjs require ./common [953] ./pageA.js 1:13-32
cjs require ./common [954] ./pageB.js 1:13-32
2013-11-20 01:09:26 +08:00
```