2019-06-15 02:32:33 +08:00
|
|
|
# example.js
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
console.log(require("./index"));
|
|
|
|
```
|
|
|
|
|
|
|
|
# index.ts
|
|
|
|
|
|
|
|
```typescript
|
2019-06-16 21:06:50 +08:00
|
|
|
const myName: string = "Junya";
|
|
|
|
const age: number = 22;
|
2019-06-15 02:32:33 +08:00
|
|
|
|
|
|
|
function getArray<T>(...args: T[]): T[] {
|
|
|
|
return [...args];
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(getArray("foo", "bar"));
|
|
|
|
console.log(getArray(1, 2, 3));
|
|
|
|
```
|
|
|
|
|
2019-06-19 15:39:06 +08:00
|
|
|
# webpack.config.js
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
module.exports = {
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
loader: "ts-loader",
|
|
|
|
options: {
|
|
|
|
transpileOnly: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: [".ts", ".js", ".json"]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
```
|
|
|
|
|
2019-06-15 02:32:33 +08:00
|
|
|
# dist/output.js
|
|
|
|
|
|
|
|
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
|
|
|
|
|
|
|
|
```javascript
|
2019-06-16 21:06:50 +08:00
|
|
|
/******/ (function(modules, runtime) { // webpackBootstrap
|
|
|
|
/******/ "use strict";
|
2019-06-15 02:32:33 +08:00
|
|
|
/******/ // The module cache
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
/******/
|
|
|
|
/******/ // 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;
|
|
|
|
/******/ }
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/
|
2019-06-16 21:06:50 +08:00
|
|
|
/******/ // the startup function
|
|
|
|
/******/ function startup() {
|
|
|
|
/******/ // Load entry module and return exports
|
|
|
|
/******/ return __webpack_require__(0);
|
2019-06-15 02:32:33 +08:00
|
|
|
/******/ };
|
|
|
|
/******/
|
2019-06-16 21:06:50 +08:00
|
|
|
/******/ // run startup
|
|
|
|
/******/ return startup();
|
2019-06-15 02:32:33 +08:00
|
|
|
/******/ })
|
|
|
|
/************************************************************************/
|
|
|
|
```
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
/******/ ([
|
|
|
|
/* 0 */
|
|
|
|
/*!********************!*\
|
|
|
|
!*** ./example.js ***!
|
|
|
|
\********************/
|
2019-06-16 21:06:50 +08:00
|
|
|
/*! exports [maybe provided (runtime-defined)] [no usage info] */
|
|
|
|
/*! runtime requirements: __webpack_require__ */
|
|
|
|
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
|
2019-06-15 02:32:33 +08:00
|
|
|
|
|
|
|
console.log(__webpack_require__(/*! ./index */ 1));
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/* 1 */
|
|
|
|
/*!******************!*\
|
|
|
|
!*** ./index.ts ***!
|
|
|
|
\******************/
|
2019-06-16 21:06:50 +08:00
|
|
|
/*! exports [maybe provided (runtime-defined)] [no usage info] */
|
|
|
|
/*! runtime requirements: */
|
|
|
|
/***/ (function() {
|
2019-06-15 02:32:33 +08:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const myName = "Junya";
|
2019-06-16 21:06:50 +08:00
|
|
|
const age = 22;
|
2019-06-15 02:32:33 +08:00
|
|
|
function getArray(...args) {
|
|
|
|
return [...args];
|
|
|
|
}
|
|
|
|
console.log(getArray("foo", "bar"));
|
|
|
|
console.log(getArray(1, 2, 3));
|
|
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
/******/ ]);
|
|
|
|
```
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
|
|
|
## Unoptimized
|
|
|
|
|
|
|
|
```
|
|
|
|
Hash: 0a1b2c3d4e5f6a7b8c9d
|
2019-06-16 21:06:50 +08:00
|
|
|
Version: webpack 5.0.0-alpha.16
|
|
|
|
Asset Size Chunks Chunk Names
|
2019-06-19 15:39:06 +08:00
|
|
|
output.js 1.98 KiB {0} [emitted] main
|
2019-06-15 02:32:33 +08:00
|
|
|
Entrypoint main = output.js
|
2019-06-19 15:39:06 +08:00
|
|
|
chunk {0} output.js (main) 209 bytes [entry] [rendered]
|
2019-06-15 02:32:33 +08:00
|
|
|
> ./example.js main
|
|
|
|
[0] ./example.js 33 bytes {0} [built]
|
2019-06-16 21:06:50 +08:00
|
|
|
[used exports unknown]
|
|
|
|
entry ./example.js main
|
2019-06-19 15:39:06 +08:00
|
|
|
[1] ./index.ts 176 bytes {0} [built]
|
2019-06-16 21:06:50 +08:00
|
|
|
[used exports unknown]
|
2019-06-15 02:32:33 +08:00
|
|
|
cjs require ./index [0] ./example.js 1:12-30
|
|
|
|
```
|
|
|
|
|
|
|
|
## Production mode
|
|
|
|
|
|
|
|
```
|
|
|
|
Hash: 0a1b2c3d4e5f6a7b8c9d
|
2019-06-16 21:06:50 +08:00
|
|
|
Version: webpack 5.0.0-alpha.16
|
|
|
|
Asset Size Chunks Chunk Names
|
|
|
|
output.js 332 bytes {179} [emitted] main
|
2019-06-15 02:32:33 +08:00
|
|
|
Entrypoint main = output.js
|
2019-06-19 15:39:06 +08:00
|
|
|
chunk {179} output.js (main) 209 bytes [entry] [rendered]
|
2019-06-15 02:32:33 +08:00
|
|
|
> ./example.js main
|
2019-06-16 21:06:50 +08:00
|
|
|
[144] ./example.js 33 bytes {179} [built]
|
|
|
|
entry ./example.js main
|
2019-06-19 15:39:06 +08:00
|
|
|
[862] ./index.ts 176 bytes {179} [built]
|
2019-06-16 21:06:50 +08:00
|
|
|
cjs require ./index [144] ./example.js 1:12-30
|
2019-06-15 02:32:33 +08:00
|
|
|
```
|