2019-10-09 04:29:46 +08:00
|
|
|
# example.js
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
import { increment as inc, value } from "./counter";
|
|
|
|
|
import { resetCounter, print } from "./methods";
|
|
|
|
|
print(value);
|
|
|
|
|
inc();
|
|
|
|
|
inc();
|
|
|
|
|
inc();
|
|
|
|
|
print(value);
|
|
|
|
|
resetCounter();
|
|
|
|
|
print(value);
|
2021-02-05 06:17:20 +08:00
|
|
|
|
|
|
|
|
export { inc, print };
|
2019-10-09 04:29:46 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# methods.js
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
export { reset as resetCounter } from "./counter";
|
|
|
|
|
|
|
|
|
|
export const print = value => console.log(value);
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# counter.js
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
export let value = 0;
|
|
|
|
|
export function increment() {
|
|
|
|
|
value++;
|
|
|
|
|
}
|
|
|
|
|
export function decrement() {
|
|
|
|
|
value--;
|
|
|
|
|
}
|
|
|
|
|
export function reset() {
|
|
|
|
|
value = 0;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# dist/output.js
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
/*!********************************!*\
|
|
|
|
|
!*** ./example.js + 2 modules ***!
|
|
|
|
|
\********************************/
|
2020-05-21 05:26:51 +08:00
|
|
|
/*! namespace exports */
|
2021-02-05 06:17:20 +08:00
|
|
|
/*! export inc [provided] [used in main] [could be renamed] -> ./counter.js .increment */
|
|
|
|
|
/*! export print [provided] [used in main] [could be renamed] -> ./methods.js .print */
|
2025-04-25 01:57:25 +08:00
|
|
|
/*! runtime requirements: */
|
2019-10-09 04:29:46 +08:00
|
|
|
|
2025-04-25 01:57:25 +08:00
|
|
|
;// ./counter.js
|
2019-10-09 04:29:46 +08:00
|
|
|
let value = 0;
|
|
|
|
|
function increment() {
|
|
|
|
|
value++;
|
|
|
|
|
}
|
|
|
|
|
function decrement() {
|
|
|
|
|
value--;
|
|
|
|
|
}
|
|
|
|
|
function counter_reset() {
|
|
|
|
|
value = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-25 01:57:25 +08:00
|
|
|
;// ./methods.js
|
2019-10-09 04:29:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const print = value => console.log(value);
|
|
|
|
|
|
2025-04-25 01:57:25 +08:00
|
|
|
;// ./example.js
|
2019-10-09 04:29:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
print(value);
|
|
|
|
|
increment();
|
|
|
|
|
increment();
|
|
|
|
|
increment();
|
|
|
|
|
print(value);
|
|
|
|
|
counter_reset();
|
|
|
|
|
print(value);
|
2021-02-05 06:17:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-25 01:57:25 +08:00
|
|
|
export { increment as inc, print };
|
2019-10-09 04:29:46 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# dist/output.js (production)
|
|
|
|
|
|
|
|
|
|
```javascript
|
2025-04-25 01:57:25 +08:00
|
|
|
let o=0;function n(){o++}const c=o=>console.log(o);c(o),n(),n(),n(),c(o),o=0,c(o);export{n as inc,c as print};
|
2019-10-09 04:29:46 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
|
|
|
|
|
## Unoptimized
|
|
|
|
|
|
|
|
|
|
```
|
2025-04-25 01:57:25 +08:00
|
|
|
asset output.js 710 bytes [emitted] [javascript module] (name: main)
|
|
|
|
|
chunk (runtime: main) output.js (main) 453 bytes [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./example.js main
|
2021-02-05 06:17:20 +08:00
|
|
|
./example.js + 2 modules 453 bytes [built] [code generated]
|
|
|
|
|
[exports: inc, print]
|
|
|
|
|
[all exports used]
|
2020-09-21 04:39:12 +08:00
|
|
|
entry ./example.js main
|
2021-02-05 06:17:20 +08:00
|
|
|
used as library export
|
2025-04-29 02:11:48 +08:00
|
|
|
webpack X.X.X compiled successfully
|
2019-10-09 04:29:46 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Production mode
|
|
|
|
|
|
|
|
|
|
```
|
2025-04-25 01:57:25 +08:00
|
|
|
asset output.js 110 bytes [emitted] [javascript module] [minimized] (name: main)
|
|
|
|
|
chunk (runtime: main) output.js (main) 453 bytes [entry] [rendered]
|
2020-09-21 04:39:12 +08:00
|
|
|
> ./example.js main
|
2021-02-05 06:17:20 +08:00
|
|
|
./example.js + 2 modules 453 bytes [built] [code generated]
|
|
|
|
|
[exports: inc, print]
|
|
|
|
|
[all exports used]
|
2020-09-21 04:39:12 +08:00
|
|
|
entry ./example.js main
|
2021-02-05 06:17:20 +08:00
|
|
|
used as library export
|
2025-04-29 02:11:48 +08:00
|
|
|
webpack X.X.X compiled successfully
|
2019-10-09 04:29:46 +08:00
|
|
|
```
|