webpack/examples/dll/README.md

223 lines
5.6 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
2019-04-09 02:29:40 +08:00
```javascript
2015-05-17 00:27:59 +08:00
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
2019-04-09 02:29:40 +08:00
```javascript
2019-11-15 07:06:30 +08:00
var alpha_dcd111488d58f7509919 =
2019-10-11 05:11:05 +08:00
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
2015-05-17 00:27:59 +08:00
/* 0 */
2017-06-05 22:12:12 +08:00
/*!*****************!*\
!*** dll alpha ***!
\*****************/
2019-08-05 19:32:25 +08:00
/*! exports [maybe provided (runtime-defined)] [maybe used (runtime-defined)] */
/*! runtime requirements: __webpack_require__, module */
2019-10-11 05:11:05 +08:00
/***/ ((module, __unused_webpack_exports, __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 ***!
\******************/
2019-08-05 19:32:25 +08:00
/*! exports [maybe provided (runtime-defined)] [maybe used (runtime-defined)] */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
2019-10-09 05:45:47 +08:00
/***/ ((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 ***!
\**************/
2019-08-05 19:32:25 +08:00
/*! exports [maybe provided (runtime-defined)] [maybe used (runtime-defined)] */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
2019-10-09 05:45:47 +08:00
/***/ ((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 ***!
\*********************************/
2019-08-05 19:32:25 +08:00
/*! exports [maybe provided (runtime-defined)] [maybe used (runtime-defined)] */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
2019-10-09 05:45:47 +08:00
/***/ ((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
/***/ })
2019-10-11 05:11:05 +08:00
/******/ ]);
```
<details><summary><code>/* webpack runtime code */</code></summary>
``` js
2019-10-11 05:11:05 +08:00
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
```
</details>
``` js
2019-10-11 05:11:05 +08:00
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })()
;
2015-05-17 00:27:59 +08:00
```
# dist/alpha-manifest.json
2015-05-17 00:27:59 +08:00
2019-04-09 02:29:40 +08:00
```javascript
2019-11-15 07:06:30 +08:00
{"name":"alpha_dcd111488d58f7509919","content":{"./alpha.js":{"id":1,"buildMeta":{}},"./a.js":{"id":2,"buildMeta":{}},"../node_modules/module.js":{"id":3,"buildMeta":{}}}}
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
2019-11-15 07:06:30 +08:00
Version: webpack 5.0.0-beta.6
2019-10-11 05:11:05 +08:00
Asset Size
MyDll.alpha.js 2.44 KiB [emitted] [name: alpha]
MyDll.beta.js 2.41 KiB [emitted] [name: beta]
2016-09-07 18:28:56 +08:00
Entrypoint alpha = MyDll.alpha.js
Entrypoint beta = MyDll.beta.js
2019-10-11 05:11:05 +08:00
chunk MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
> alpha
2019-10-11 05:11:05 +08:00
../node_modules/module.js 26 bytes [built]
entry module dll alpha alpha[2]
2018-12-19 21:05:17 +08:00
DllPlugin
2019-10-11 05:11:05 +08:00
./a.js 21 bytes [built]
entry ./a dll alpha alpha[1]
2018-12-19 21:05:17 +08:00
DllPlugin
2019-10-11 05:11:05 +08:00
./alpha.js 25 bytes [built]
entry ./alpha dll alpha alpha[0]
2018-12-19 21:05:17 +08:00
DllPlugin
2019-10-11 05:11:05 +08:00
dll alpha 12 bytes [built]
dll entry
used a library export
2018-12-19 21:05:17 +08:00
DllPlugin
2019-10-11 05:11:05 +08:00
chunk MyDll.beta.js (beta) 80 bytes [entry] [rendered]
> beta
2019-10-11 05:11:05 +08:00
./b.js 21 bytes [built]
entry ./b dll beta beta[1]
2018-12-19 21:05:17 +08:00
DllPlugin
2019-10-11 05:11:05 +08:00
./beta.js 24 bytes [built]
entry ./beta dll beta beta[0]
2018-12-19 21:05:17 +08:00
DllPlugin
2019-10-11 05:11:05 +08:00
./c.jsx 23 bytes [built]
entry ./c dll beta beta[2]
2018-12-19 21:05:17 +08:00
DllPlugin
2019-10-11 05:11:05 +08:00
dll beta 12 bytes [built]
dll entry
used a library export
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
2019-11-15 07:06:30 +08:00
Version: webpack 5.0.0-beta.6
2019-10-11 05:11:05 +08:00
Asset Size
MyDll.alpha.js 291 bytes [emitted] [name: alpha]
MyDll.beta.js 282 bytes [emitted] [name: beta]
2016-09-07 18:28:56 +08:00
Entrypoint alpha = MyDll.alpha.js
Entrypoint beta = MyDll.beta.js
2019-10-11 05:11:05 +08:00
chunk MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
> alpha
2019-10-11 05:11:05 +08:00
../node_modules/module.js 26 bytes [built]
entry module dll alpha alpha[2]
DllPlugin
./a.js 21 bytes [built]
entry ./a dll alpha alpha[1]
DllPlugin
./alpha.js 25 bytes [built]
entry ./alpha dll alpha alpha[0]
DllPlugin
dll alpha 12 bytes [built]
dll entry
used a library export
DllPlugin
chunk MyDll.beta.js (beta) 80 bytes [entry] [rendered]
2018-09-25 23:08:35 +08:00
> beta
2019-10-11 05:11:05 +08:00
./b.js 21 bytes [built]
entry ./b dll beta beta[1]
DllPlugin
./beta.js 24 bytes [built]
entry ./beta dll beta beta[0]
DllPlugin
./c.jsx 23 bytes [built]
entry ./c dll beta beta[2]
DllPlugin
dll beta 12 bytes [built]
dll entry
used a library export
DllPlugin
```