Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add an example with chunk splitting
- Loading branch information
Showing
17 changed files
with
792 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Webpack App</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"></head> | ||
<body> | ||
<script src="libMath.js"></script><script src="libText.js"></script><script src="vendors~entryA~entryB.js"></script><script src="entryA~entryB.js"></script><script src="entryA.js"></script></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // install a JSONP callback for chunk loading | ||
/******/ function webpackJsonpCallback(data) { | ||
/******/ var chunkIds = data[0]; | ||
/******/ var moreModules = data[1] | ||
/******/ var executeModules = data[2]; | ||
/******/ // 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)) { | ||
/******/ modules[moduleId] = moreModules[moduleId]; | ||
/******/ } | ||
/******/ } | ||
/******/ if(parentJsonpFunction) parentJsonpFunction(data); | ||
/******/ while(resolves.length) { | ||
/******/ resolves.shift()(); | ||
/******/ } | ||
/******/ | ||
/******/ // add entry modules from loaded chunk to deferred list | ||
/******/ deferredModules.push.apply(deferredModules, executeModules || []); | ||
/******/ | ||
/******/ // run deferred modules when all chunks ready | ||
/******/ return checkDeferredModules(); | ||
/******/ }; | ||
/******/ function checkDeferredModules() { | ||
/******/ var result; | ||
/******/ for(var i = 0; i < deferredModules.length; i++) { | ||
/******/ var deferredModule = deferredModules[i]; | ||
/******/ var fullfilled = true; | ||
/******/ for(var j = 1; j < deferredModule.length; j++) { | ||
/******/ var depId = deferredModule[j]; | ||
/******/ if(installedChunks[depId] !== 0) fullfilled = false; | ||
/******/ } | ||
/******/ if(fullfilled) { | ||
/******/ deferredModules.splice(i--, 1); | ||
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]); | ||
/******/ } | ||
/******/ } | ||
/******/ return result; | ||
/******/ } | ||
/******/ | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // object to store loaded and loading chunks | ||
/******/ var installedChunks = { | ||
/******/ 5: 0 | ||
/******/ }; | ||
/******/ | ||
/******/ var deferredModules = []; | ||
/******/ | ||
/******/ // 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; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ 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; | ||
/******/ | ||
/******/ | ||
/******/ // add entry module to deferred list | ||
/******/ deferredModules.push([8,2,3,1,0]); | ||
/******/ // run deferred modules when ready | ||
/******/ return checkDeferredModules(); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ({ | ||
|
||
/***/ 8: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
|
||
__webpack_require__(1); | ||
var multiply = __webpack_require__(0); | ||
var concat = __webpack_require__(3); | ||
var h1 = document.createElement('h1'); | ||
h1.innerHTML = concat('Hello world from Entry ', multiply(1, 1)); | ||
document.body.appendChild(h1); | ||
|
||
|
||
/***/ }) | ||
|
||
/******/ }); |
34 changes: 34 additions & 0 deletions
34
examples/chunk-optimization/dist/webpack-4/entryA~entryB.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{ | ||
|
||
/***/ 1: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
|
||
// style-loader: Adds some css to the DOM by adding a <style> tag | ||
|
||
// load the styles | ||
var content = __webpack_require__(7); | ||
if(typeof content === 'string') content = [[module.i, content, '']]; | ||
// add the styles to the DOM | ||
var update = __webpack_require__(5)(content, {}); | ||
if(content.locals) module.exports = content.locals; | ||
// Hot Module Replacement | ||
if(false) {} | ||
|
||
/***/ }), | ||
|
||
/***/ 7: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
|
||
exports = module.exports = __webpack_require__(6)(); | ||
// imports | ||
|
||
|
||
// module | ||
exports.push([module.i, "body {\n background: snow;\n}", ""]); | ||
|
||
// exports | ||
|
||
|
||
/***/ }) | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Webpack App</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"></head> | ||
<body> | ||
<script src="libMath.js"></script><script src="vendors~entryA~entryB.js"></script><script src="entryA~entryB.js"></script><script src="entryB.js"></script></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // install a JSONP callback for chunk loading | ||
/******/ function webpackJsonpCallback(data) { | ||
/******/ var chunkIds = data[0]; | ||
/******/ var moreModules = data[1] | ||
/******/ var executeModules = data[2]; | ||
/******/ // 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)) { | ||
/******/ modules[moduleId] = moreModules[moduleId]; | ||
/******/ } | ||
/******/ } | ||
/******/ if(parentJsonpFunction) parentJsonpFunction(data); | ||
/******/ while(resolves.length) { | ||
/******/ resolves.shift()(); | ||
/******/ } | ||
/******/ | ||
/******/ // add entry modules from loaded chunk to deferred list | ||
/******/ deferredModules.push.apply(deferredModules, executeModules || []); | ||
/******/ | ||
/******/ // run deferred modules when all chunks ready | ||
/******/ return checkDeferredModules(); | ||
/******/ }; | ||
/******/ function checkDeferredModules() { | ||
/******/ var result; | ||
/******/ for(var i = 0; i < deferredModules.length; i++) { | ||
/******/ var deferredModule = deferredModules[i]; | ||
/******/ var fullfilled = true; | ||
/******/ for(var j = 1; j < deferredModule.length; j++) { | ||
/******/ var depId = deferredModule[j]; | ||
/******/ if(installedChunks[depId] !== 0) fullfilled = false; | ||
/******/ } | ||
/******/ if(fullfilled) { | ||
/******/ deferredModules.splice(i--, 1); | ||
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]); | ||
/******/ } | ||
/******/ } | ||
/******/ return result; | ||
/******/ } | ||
/******/ | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // object to store loaded and loading chunks | ||
/******/ var installedChunks = { | ||
/******/ 4: 0 | ||
/******/ }; | ||
/******/ | ||
/******/ var deferredModules = []; | ||
/******/ | ||
/******/ // 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; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // define __esModule on exports | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ 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; | ||
/******/ | ||
/******/ | ||
/******/ // add entry module to deferred list | ||
/******/ deferredModules.push([2,2,1,0]); | ||
/******/ // run deferred modules when ready | ||
/******/ return checkDeferredModules(); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ({ | ||
|
||
/***/ 2: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
|
||
__webpack_require__(1); | ||
var multiply = __webpack_require__(0); | ||
var h1 = document.createElement('h1'); | ||
h1.innerHTML = 'Hello world from Entry ' + multiply(1, 2); | ||
document.body.appendChild(h1); | ||
|
||
|
||
/***/ }) | ||
|
||
/******/ }); |
Oops, something went wrong.