2019-12-05 05:54:26 +08:00
|
|
|
# example.js
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
const inc = require("./increment").increment;
|
|
|
|
|
var a = 1;
|
|
|
|
|
inc(a); // 2
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# increment.js
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
const add = require("./math").add;
|
|
|
|
|
exports.increment = function increment(val) {
|
|
|
|
|
return add(val, 1);
|
|
|
|
|
};
|
|
|
|
|
exports.incrementBy2 = function incrementBy2(val) {
|
|
|
|
|
return add(val, 2);
|
|
|
|
|
};
|
|
|
|
|
exports.decrement = function decrement(val) {
|
|
|
|
|
return add(val, 1);
|
|
|
|
|
};
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# math.js
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
exports.add = function add() {
|
|
|
|
|
var sum = 0,
|
|
|
|
|
i = 0,
|
|
|
|
|
args = arguments,
|
|
|
|
|
l = args.length;
|
|
|
|
|
while (i < l) {
|
|
|
|
|
sum += args[i++];
|
|
|
|
|
}
|
|
|
|
|
return sum;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.multiply = function multiply() {
|
|
|
|
|
var product = 0,
|
|
|
|
|
i = 0,
|
|
|
|
|
args = arguments,
|
|
|
|
|
l = args.length;
|
|
|
|
|
while (i < l) {
|
|
|
|
|
sum *= args[i++];
|
|
|
|
|
}
|
|
|
|
|
return sum;
|
|
|
|
|
};
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# dist/output.js
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
/******/ (() => { // webpackBootstrap
|
|
|
|
|
/******/ var __webpack_modules__ = ([
|
|
|
|
|
/* 0 */,
|
|
|
|
|
/* 1 */
|
|
|
|
|
/*!**********************!*\
|
|
|
|
|
!*** ./increment.js ***!
|
|
|
|
|
\**********************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! default exports */
|
|
|
|
|
/*! export decrement [provided] [unused] [renamed to Mj] */
|
2020-09-21 04:39:12 +08:00
|
|
|
/*! export increment [provided] [used in main] [renamed to nP] */
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! export incrementBy2 [provided] [unused] [renamed to pN] */
|
2019-12-05 05:54:26 +08:00
|
|
|
/*! runtime requirements: __webpack_require__, __webpack_exports__ */
|
|
|
|
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
|
|
|
|
|
|
|
|
var __webpack_unused_export__;
|
2023-04-08 06:23:22 +08:00
|
|
|
const add = (__webpack_require__(/*! ./math */ 2)/* .add */ .I);
|
2020-05-21 05:26:51 +08:00
|
|
|
exports.nP = function increment(val) {
|
2019-12-05 05:54:26 +08:00
|
|
|
return add(val, 1);
|
|
|
|
|
};
|
|
|
|
|
__webpack_unused_export__ = function incrementBy2(val) {
|
|
|
|
|
return add(val, 2);
|
|
|
|
|
};
|
|
|
|
|
__webpack_unused_export__ = function decrement(val) {
|
|
|
|
|
return add(val, 1);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
/* 2 */
|
|
|
|
|
/*!*****************!*\
|
|
|
|
|
!*** ./math.js ***!
|
|
|
|
|
\*****************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! default exports */
|
2020-09-21 04:39:12 +08:00
|
|
|
/*! export add [provided] [used in main] [renamed to I] */
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! export multiply [provided] [unused] [renamed to J] */
|
2019-12-05 05:54:26 +08:00
|
|
|
/*! runtime requirements: __webpack_exports__ */
|
|
|
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
|
|
|
|
|
|
var __webpack_unused_export__;
|
2020-05-21 05:26:51 +08:00
|
|
|
exports.I = function add() {
|
2019-12-05 05:54:26 +08:00
|
|
|
var sum = 0,
|
|
|
|
|
i = 0,
|
|
|
|
|
args = arguments,
|
|
|
|
|
l = args.length;
|
|
|
|
|
while (i < l) {
|
|
|
|
|
sum += args[i++];
|
|
|
|
|
}
|
|
|
|
|
return sum;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
__webpack_unused_export__ = function multiply() {
|
|
|
|
|
var product = 0,
|
|
|
|
|
i = 0,
|
|
|
|
|
args = arguments,
|
|
|
|
|
l = args.length;
|
|
|
|
|
while (i < l) {
|
|
|
|
|
sum *= args[i++];
|
|
|
|
|
}
|
|
|
|
|
return sum;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
/******/ ]);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
<details><summary><code>/* webpack runtime code */</code></summary>
|
|
|
|
|
|
|
|
|
|
``` js
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
/******/ // The module cache
|
|
|
|
|
/******/ var __webpack_module_cache__ = {};
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // The require function
|
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
|
/******/ // Check if module is in cache
|
2021-08-20 14:12:50 +08:00
|
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
|
|
|
/******/ if (cachedModule !== undefined) {
|
|
|
|
|
/******/ return cachedModule.exports;
|
2019-12-05 05:54:26 +08:00
|
|
|
/******/ }
|
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
|
|
|
/******/ // no module.id needed
|
|
|
|
|
/******/ // no module.loaded needed
|
|
|
|
|
/******/ exports: {}
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Execute the module function
|
|
|
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
|
/******/ return module.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
``` js
|
2021-08-20 14:12:50 +08:00
|
|
|
var __webpack_exports__ = {};
|
2024-10-12 16:38:03 +08:00
|
|
|
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
2019-12-05 05:54:26 +08:00
|
|
|
(() => {
|
|
|
|
|
/*!********************!*\
|
|
|
|
|
!*** ./example.js ***!
|
|
|
|
|
\********************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! unknown exports (runtime-defined) */
|
2019-12-05 05:54:26 +08:00
|
|
|
/*! runtime requirements: __webpack_require__ */
|
2023-04-08 06:23:22 +08:00
|
|
|
const inc = (__webpack_require__(/*! ./increment */ 1)/* .increment */ .nP);
|
2019-12-05 05:54:26 +08:00
|
|
|
var a = 1;
|
|
|
|
|
inc(a); // 2
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
/******/ })()
|
|
|
|
|
;
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# dist/output.js (production)
|
|
|
|
|
|
|
|
|
|
```javascript
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! For license information please see output.js.LICENSE.txt */
|
2021-08-20 14:12:50 +08:00
|
|
|
(()=>{var r=[,(r,n,t)=>{const o=t(2).I;n.nP=function(r){return o(r,1)}},(r,n)=>{n.I=function(){for(var r=0,n=0,t=arguments,o=t.length;n<o;)r+=t[n++];return r}}],n={};(0,function t(o){var e=n[o];if(void 0!==e)return e.exports;var u=n[o]={exports:{}};return r[o](u,u.exports,t),u.exports}(1).nP)(1)})();
|
2019-12-05 05:54:26 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# dist/without.js (same without tree shaking)
|
|
|
|
|
|
|
|
|
|
```javascript
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! For license information please see without.js.LICENSE.txt */
|
2021-08-20 14:12:50 +08:00
|
|
|
(()=>{var n=[,(n,r,t)=>{const e=t(2).add;r.increment=function(n){return e(n,1)},r.incrementBy2=function(n){return e(n,2)},r.decrement=function(n){return e(n,1)}},(n,r)=>{r.add=function(){for(var n=0,r=0,t=arguments,e=t.length;r<e;)n+=t[r++];return n},r.multiply=function(){for(var n=0,r=arguments,t=r.length;n<t;)sum*=r[n++];return sum}}],r={};(0,function t(e){var u=r[e];if(void 0!==u)return u.exports;var o=r[e]={exports:{}};return n[e](o,o.exports,t),o.exports}(1).increment)(1)})();
|
2019-12-05 05:54:26 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
|
|
|
|
|
## Unoptimized
|
|
|
|
|
|
|
|
|
|
```
|
2023-04-08 06:23:22 +08:00
|
|
|
asset output.js 2.94 KiB [emitted] (name: main)
|
2020-09-21 04:39:12 +08:00
|
|
|
chunk (runtime: main) output.js (main) 634 bytes [entry] [rendered]
|
|
|
|
|
> ./example.js main
|
|
|
|
|
dependent modules 564 bytes [dependent] 2 modules
|
|
|
|
|
./example.js 70 bytes [built] [code generated]
|
|
|
|
|
[no exports used]
|
|
|
|
|
entry ./example.js main
|
2023-04-08 06:23:22 +08:00
|
|
|
webpack 5.78.0 compiled successfully
|
2020-09-21 04:39:12 +08:00
|
|
|
|
2021-08-20 14:12:50 +08:00
|
|
|
asset without.js 3.08 KiB [emitted] (name: main)
|
2020-12-11 17:29:32 +08:00
|
|
|
chunk (runtime: main) without.js (main) 634 bytes [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./example.js main
|
|
|
|
|
dependent modules 564 bytes [dependent] 2 modules
|
|
|
|
|
./example.js 70 bytes [built] [code generated]
|
|
|
|
|
[used exports unknown]
|
|
|
|
|
entry ./example.js main
|
2023-04-08 06:23:22 +08:00
|
|
|
webpack 5.78.0 compiled successfully
|
2019-12-05 05:54:26 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Production mode
|
|
|
|
|
|
|
|
|
|
```
|
2021-08-20 14:12:50 +08:00
|
|
|
asset output.js 365 bytes [emitted] [minimized] (name: main) 1 related asset
|
2020-09-21 04:39:12 +08:00
|
|
|
chunk (runtime: main) output.js (main) 634 bytes [entry] [rendered]
|
|
|
|
|
> ./example.js main
|
|
|
|
|
dependent modules 564 bytes [dependent] 2 modules
|
|
|
|
|
./example.js 70 bytes [built] [code generated]
|
|
|
|
|
[no exports used]
|
|
|
|
|
entry ./example.js main
|
2023-04-08 06:23:22 +08:00
|
|
|
webpack 5.78.0 compiled successfully
|
2020-09-21 04:39:12 +08:00
|
|
|
|
2021-08-20 14:12:50 +08:00
|
|
|
asset without.js 551 bytes [emitted] [minimized] (name: main) 1 related asset
|
2020-12-11 17:29:32 +08:00
|
|
|
chunk (runtime: main) without.js (main) 634 bytes [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./example.js main
|
|
|
|
|
dependent modules 564 bytes [dependent] 2 modules
|
|
|
|
|
./example.js 70 bytes [built] [code generated]
|
|
|
|
|
[used exports unknown]
|
|
|
|
|
entry ./example.js main
|
2023-04-08 06:23:22 +08:00
|
|
|
webpack 5.78.0 compiled successfully
|
2019-12-05 05:54:26 +08:00
|
|
|
```
|