webpack/examples/dll/README.md

224 lines
5.7 KiB
Markdown
Raw Normal View History

# DllReference
[DllPlugin documentation](https://webpack.js.org/plugins/dll-plugin)
This is the _reference_ bundle (with the manifests) for [dll user example](https://github.com/webpack/webpack/tree/master/examples/dll-user)
2015-05-17 00:27:59 +08:00
# webpack.config.js
``` javascript
var path = require("path");
2015-06-13 23:41:14 +08:00
var webpack = require("../../");
2015-05-17 00:27:59 +08:00
module.exports = {
2017-12-14 17:58:03 +08:00
// mode: "development || "production",
2016-09-07 20:57:53 +08:00
resolve: {
2017-03-31 02:25:01 +08:00
extensions: [".js", ".jsx"]
2016-09-07 20:57:53 +08:00
},
2015-05-17 00:27:59 +08:00
entry: {
2015-10-13 22:19:11 +08:00
alpha: ["./alpha", "./a", "module"],
2016-09-07 20:57:53 +08:00
beta: ["./beta", "./b", "./c"]
2015-05-17 00:27:59 +08:00
},
output: {
path: path.join(__dirname, "dist"),
2015-05-17 00:27:59 +08:00
filename: "MyDll.[name].js",
2019-01-28 09:27:57 +08:00
library: "[name]_[fullhash]"
2015-05-17 00:27:59 +08:00
},
plugins: [
2015-06-13 23:41:14 +08:00
new webpack.DllPlugin({
path: path.join(__dirname, "dist", "[name]-manifest.json"),
2019-01-28 09:27:57 +08:00
name: "[name]_[fullhash]"
2015-05-17 00:27:59 +08:00
})
]
};
```
# dist/MyDll.alpha.js
2015-05-17 00:27:59 +08:00
``` javascript
2018-12-19 21:05:17 +08:00
var alpha_382bfbbbdad9425c171d =
2016-12-14 19:03:24 +08:00
```
2017-03-31 02:42:42 +08:00
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
2016-12-14 19:03:24 +08:00
``` js
2018-12-19 21:05:17 +08:00
/******/ (function(modules, runtime) { // webpackBootstrap
/******/ "use strict";
2015-05-17 00:27:59 +08:00
/******/ // The module cache
/******/ var installedModules = {};
2017-03-31 02:25:01 +08:00
/******/
2015-05-17 00:27:59 +08:00
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
2017-03-31 02:25:01 +08:00
/******/
2015-05-17 00:27:59 +08:00
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
2015-05-17 00:27:59 +08:00
/******/ return installedModules[moduleId].exports;
/******/ }
2015-05-17 00:27:59 +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: {}
2015-05-17 00:27:59 +08:00
/******/ };
2017-03-31 02:25:01 +08:00
/******/
2015-05-17 00:27:59 +08:00
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
2017-03-31 02:25:01 +08:00
/******/
2015-05-17 00:27:59 +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
/******/
2015-05-17 00:27:59 +08:00
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
2017-03-31 02:25:01 +08:00
/******/
/******/
/******/
/******/
2015-05-17 00:27:59 +08:00
/******/ // Load entry module and return exports
2018-12-19 21:05:17 +08:00
/******/ return __webpack_require__(0);
2015-05-17 00:27:59 +08:00
/******/ })
/************************************************************************/
2016-12-14 19:03:24 +08:00
```
2017-03-31 02:42:42 +08:00
2016-12-14 19:03:24 +08:00
</details>
2017-03-31 02:42:42 +08:00
2016-12-14 19:03:24 +08:00
``` js
2015-05-17 00:27:59 +08:00
/******/ ([
/* 0 */
2017-06-05 22:12:12 +08:00
/*!*****************!*\
!*** dll alpha ***!
\*****************/
/*! no static exports found */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: __webpack_require__, module */
2017-06-05 22:12:12 +08:00
/*! all exports used */
2018-12-19 21:05:17 +08:00
/***/ (function(module, __unusedexports, __webpack_require__) {
2015-05-17 00:27:59 +08:00
2017-06-05 22:12:12 +08:00
module.exports = __webpack_require__;
2015-05-17 00:27:59 +08:00
2017-03-31 02:25:01 +08:00
/***/ }),
2015-05-17 00:27:59 +08:00
/* 1 */
/*!******************!*\
!*** ./alpha.js ***!
\******************/
2017-06-05 22:12:12 +08:00
/*! no static exports found */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
2017-06-05 22:12:12 +08:00
/*! all exports used */
2018-12-19 21:05:17 +08:00
/***/ (function(module) {
2015-05-17 00:27:59 +08:00
2016-09-07 18:28:56 +08:00
module.exports = "alpha";
2015-05-17 00:27:59 +08:00
2017-03-31 02:25:01 +08:00
/***/ }),
2017-06-05 22:12:12 +08:00
/* 2 */
/*!**************!*\
!*** ./a.js ***!
\**************/
/*! no static exports found */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
2017-06-05 22:12:12 +08:00
/*! all exports used */
2018-12-19 21:05:17 +08:00
/***/ (function(module) {
2015-10-13 22:19:11 +08:00
2017-06-05 22:12:12 +08:00
module.exports = "a";
2015-10-13 22:19:11 +08:00
2017-03-31 02:25:01 +08:00
/***/ }),
2017-06-05 22:12:12 +08:00
/* 3 */
/*!*********************************!*\
!*** ../node_modules/module.js ***!
\*********************************/
/*! no static exports found */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
2017-06-05 22:12:12 +08:00
/*! all exports used */
2018-12-19 21:05:17 +08:00
/***/ (function(module) {
2016-02-04 07:27:47 +08:00
2017-06-05 22:12:12 +08:00
module.exports = "module";
2016-02-04 07:27:47 +08:00
2017-03-31 02:25:01 +08:00
/***/ })
2015-05-17 00:27:59 +08:00
/******/ ]);
```
# dist/alpha-manifest.json
2015-05-17 00:27:59 +08:00
``` javascript
2018-12-19 21:05:17 +08:00
{"name":"alpha_382bfbbbdad9425c171d","content":{"./alpha.js":{"id":1,"buildMeta":{"providedExports":true}},"./a.js":{"id":2,"buildMeta":{"providedExports":true}},"../node_modules/module.js":{"id":3,"buildMeta":{"providedExports":true}}}}
2015-05-17 00:27:59 +08:00
```
# Info
2017-12-14 17:58:03 +08:00
## Unoptimized
2015-05-17 00:27:59 +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
2017-11-23 16:47:19 +08:00
Asset Size Chunks Chunk Names
2018-12-19 21:05:17 +08:00
MyDll.alpha.js 2.19 KiB {0} [emitted] alpha
MyDll.beta.js 2.16 KiB {1} [emitted] beta
2016-09-07 18:28:56 +08:00
Entrypoint alpha = MyDll.alpha.js
Entrypoint beta = MyDll.beta.js
2018-12-19 21:05:17 +08:00
chunk {0} MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
> alpha
2018-05-07 18:36:38 +08:00
[0] dll alpha 12 bytes {0} [built]
2018-12-19 21:05:17 +08:00
dll entry
DllPlugin
2018-05-07 18:36:38 +08:00
[1] ./alpha.js 25 bytes {0} [built]
2018-09-26 05:13:58 +08:00
entry ./alpha [0] dll alpha alpha[0]
2018-12-19 21:05:17 +08:00
DllPlugin
2018-05-07 18:36:38 +08:00
[2] ./a.js 21 bytes {0} [built]
2018-09-26 05:13:58 +08:00
entry ./a [0] dll alpha alpha[1]
2018-12-19 21:05:17 +08:00
DllPlugin
[3] ../node_modules/module.js 26 bytes {0} [built]
entry module [0] dll alpha alpha[2]
DllPlugin
chunk {1} MyDll.beta.js (beta) 80 bytes [entry] [rendered]
> beta
2018-05-07 18:36:38 +08:00
[4] dll beta 12 bytes {1} [built]
2018-12-19 21:05:17 +08:00
dll entry
DllPlugin
2018-05-07 18:36:38 +08:00
[5] ./beta.js 24 bytes {1} [built]
2018-09-26 05:13:58 +08:00
entry ./beta [4] dll beta beta[0]
2018-12-19 21:05:17 +08:00
DllPlugin
2018-05-07 18:36:38 +08:00
[6] ./b.js 21 bytes {1} [built]
2018-09-26 05:13:58 +08:00
entry ./b [4] dll beta beta[1]
2018-12-19 21:05:17 +08:00
DllPlugin
2018-05-07 18:36:38 +08:00
[7] ./c.jsx 23 bytes {1} [built]
2018-09-26 05:13:58 +08:00
entry ./c [4] dll beta beta[2]
2018-12-19 21:05:17 +08:00
DllPlugin
2015-05-17 00:27:59 +08:00
```
2017-12-14 17:58:03 +08:00
## Production mode
2015-05-17 00:27:59 +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
2018-12-19 21:05:17 +08:00
Asset Size Chunks Chunk Names
MyDll.alpha.js 353 bytes {963} [emitted] alpha
MyDll.beta.js 347 bytes {188} [emitted] beta
2016-09-07 18:28:56 +08:00
Entrypoint alpha = MyDll.alpha.js
Entrypoint beta = MyDll.beta.js
2018-12-19 21:05:17 +08:00
chunk {188} MyDll.beta.js (beta) 80 bytes [entry] [rendered]
2018-09-25 23:08:35 +08:00
> beta
2018-12-19 21:05:17 +08:00
[21] ./b.js 21 bytes {188} [built]
entry ./b [350] dll beta beta[1]
DllPlugin
[145] ./beta.js 24 bytes {188} [built]
entry ./beta [350] dll beta beta[0]
DllPlugin
[235] ./c.jsx 23 bytes {188} [built]
entry ./c [350] dll beta beta[2]
DllPlugin
[350] dll beta 12 bytes {188} [built]
dll entry
DllPlugin
chunk {963} MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
> alpha
[162] ./a.js 21 bytes {963} [built]
entry ./a [673] dll alpha alpha[1]
DllPlugin
[673] dll alpha 12 bytes {963} [built]
dll entry
DllPlugin
[683] ../node_modules/module.js 26 bytes {963} [built]
entry module [673] dll alpha alpha[2]
DllPlugin
[930] ./alpha.js 25 bytes {963} [built]
entry ./alpha [673] dll alpha alpha[0]
DllPlugin
```