2017-10-30 20:56:57 +08:00
|
|
|
This very simple example shows usage of WebAssembly.
|
|
|
|
|
|
2019-05-24 19:54:49 +08:00
|
|
|
WebAssembly modules can be imported like other async modules with `import await` or `import()`.
|
|
|
|
|
They are downloaded and instantiated in a streaming way when importing.
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
# example.js
|
|
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2019-05-24 18:30:43 +08:00
|
|
|
import await { add } from "./add.wasm";
|
|
|
|
|
import await { add as mathAdd, factorial, factorialJavascript, fibonacci, fibonacciJavascript } from "./math";
|
|
|
|
|
|
|
|
|
|
console.log(add(22, 2200));
|
|
|
|
|
console.log(mathAdd(10, 101));
|
|
|
|
|
console.log(factorial(15));
|
|
|
|
|
console.log(factorialJavascript(15));
|
|
|
|
|
console.log(fibonacci(15));
|
|
|
|
|
console.log(fibonacciJavascript(15));
|
|
|
|
|
timed("wasm factorial", () => factorial(1500));
|
|
|
|
|
timed("js factorial", () => factorialJavascript(1500));
|
|
|
|
|
timed("wasm fibonacci", () => fibonacci(22));
|
|
|
|
|
timed("js fibonacci", () => fibonacciJavascript(22));
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
function timed(name, fn) {
|
|
|
|
|
if(!console.time || !console.timeEnd)
|
|
|
|
|
return fn();
|
|
|
|
|
// warmup
|
|
|
|
|
for(var i = 0; i < 10; i++)
|
|
|
|
|
fn();
|
|
|
|
|
console.time(name)
|
|
|
|
|
for(var i = 0; i < 5000; i++)
|
|
|
|
|
fn();
|
|
|
|
|
console.timeEnd(name)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# math.js
|
|
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2019-05-24 18:30:43 +08:00
|
|
|
import await { add } from "./add.wasm";
|
|
|
|
|
import await { factorial } from "./factorial.wasm";
|
|
|
|
|
import await { fibonacci } from "./fibonacci.wasm";
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
export { add, factorial, fibonacci };
|
|
|
|
|
|
|
|
|
|
export function factorialJavascript(i) {
|
|
|
|
|
if(i < 1) return 1;
|
|
|
|
|
return i * factorialJavascript(i - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function fibonacciJavascript(i) {
|
|
|
|
|
if(i < 2) return 1;
|
|
|
|
|
return fibonacciJavascript(i - 1) + fibonacciJavascript(i - 2);
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2018-01-05 04:39:29 +08:00
|
|
|
# dist/output.js
|
2017-10-30 20:56:57 +08:00
|
|
|
|
2019-04-09 02:29:40 +08:00
|
|
|
```javascript
|
2019-10-09 05:45:47 +08:00
|
|
|
/******/ ((modules, runtime) => { // webpackBootstrap
|
2018-12-19 21:05:17 +08:00
|
|
|
/******/ "use strict";
|
2017-10-30 20:56:57 +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
|
2019-10-09 05:45:47 +08:00
|
|
|
/******/ modules[moduleId](module, module.exports, __webpack_require__);
|
2017-10-30 20:56:57 +08:00
|
|
|
/******/
|
|
|
|
|
/******/ // Flag the module as loaded
|
|
|
|
|
/******/ module.l = true;
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
|
/******/ return module.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/
|
|
|
|
|
/******/
|
2019-02-05 01:52:39 +08:00
|
|
|
/******/ // the startup function
|
|
|
|
|
/******/ function startup() {
|
|
|
|
|
/******/ // Load entry module and return exports
|
|
|
|
|
/******/ return __webpack_require__(0);
|
2017-10-30 20:56:57 +08:00
|
|
|
/******/ };
|
2018-12-19 21:05:17 +08:00
|
|
|
/******/ // initialize runtime
|
|
|
|
|
/******/ runtime(__webpack_require__);
|
2017-10-30 20:56:57 +08:00
|
|
|
/******/
|
2019-02-05 01:52:39 +08:00
|
|
|
/******/ // run startup
|
|
|
|
|
/******/ return startup();
|
2017-10-30 20:56:57 +08:00
|
|
|
/******/ })
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
/******/ ([
|
|
|
|
|
/* 0 */
|
|
|
|
|
/*!********************!*\
|
|
|
|
|
!*** ./example.js ***!
|
|
|
|
|
\********************/
|
2019-06-05 20:26:08 +08:00
|
|
|
/*! exports [not provided] [no usage info] */
|
2019-05-24 18:30:43 +08:00
|
|
|
/*! runtime requirements: __webpack_require__.r, __webpack_exports__, module, __webpack_require__ */
|
2019-10-09 05:45:47 +08:00
|
|
|
/***/ ((module, __webpack_exports__, __webpack_require__) => {
|
2019-05-24 18:30:43 +08:00
|
|
|
|
|
|
|
|
"use strict";
|
2019-06-05 20:26:08 +08:00
|
|
|
module.exports = (async () => {
|
2019-05-24 18:30:43 +08:00
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
|
/* harmony import */ var _add_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./add.wasm */ 1);
|
|
|
|
|
/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ 2);
|
2019-10-09 05:45:47 +08:00
|
|
|
([_math__WEBPACK_IMPORTED_MODULE_1__, _add_wasm__WEBPACK_IMPORTED_MODULE_0__] = await Promise.all([_math__WEBPACK_IMPORTED_MODULE_1__, _add_wasm__WEBPACK_IMPORTED_MODULE_0__]));
|
2019-05-24 18:30:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-09 05:45:47 +08:00
|
|
|
console.log((0,_add_wasm__WEBPACK_IMPORTED_MODULE_0__.add)(22, 2200));
|
|
|
|
|
console.log((0,_math__WEBPACK_IMPORTED_MODULE_1__.add)(10, 101));
|
|
|
|
|
console.log((0,_math__WEBPACK_IMPORTED_MODULE_1__.factorial)(15));
|
|
|
|
|
console.log((0,_math__WEBPACK_IMPORTED_MODULE_1__.factorialJavascript)(15));
|
|
|
|
|
console.log((0,_math__WEBPACK_IMPORTED_MODULE_1__.fibonacci)(15));
|
|
|
|
|
console.log((0,_math__WEBPACK_IMPORTED_MODULE_1__.fibonacciJavascript)(15));
|
|
|
|
|
timed("wasm factorial", () => (0,_math__WEBPACK_IMPORTED_MODULE_1__.factorial)(1500));
|
|
|
|
|
timed("js factorial", () => (0,_math__WEBPACK_IMPORTED_MODULE_1__.factorialJavascript)(1500));
|
|
|
|
|
timed("wasm fibonacci", () => (0,_math__WEBPACK_IMPORTED_MODULE_1__.fibonacci)(22));
|
|
|
|
|
timed("js fibonacci", () => (0,_math__WEBPACK_IMPORTED_MODULE_1__.fibonacciJavascript)(22));
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
function timed(name, fn) {
|
|
|
|
|
if(!console.time || !console.timeEnd)
|
|
|
|
|
return fn();
|
|
|
|
|
// warmup
|
|
|
|
|
for(var i = 0; i < 10; i++)
|
|
|
|
|
fn();
|
|
|
|
|
console.time(name)
|
|
|
|
|
for(var i = 0; i < 5000; i++)
|
|
|
|
|
fn();
|
|
|
|
|
console.timeEnd(name)
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 20:26:08 +08:00
|
|
|
return __webpack_exports__;
|
|
|
|
|
})();
|
2017-10-30 20:56:57 +08:00
|
|
|
|
2019-05-24 18:30:43 +08:00
|
|
|
/***/ }),
|
2017-10-30 20:56:57 +08:00
|
|
|
/* 1 */
|
|
|
|
|
/*!******************!*\
|
|
|
|
|
!*** ./add.wasm ***!
|
|
|
|
|
\******************/
|
2019-08-05 19:32:25 +08:00
|
|
|
/*! export add [provided] [no usage info] [provision prevents renaming (no use info)] */
|
2019-02-05 01:52:39 +08:00
|
|
|
/*! other exports [not provided] [no usage info] */
|
2019-06-05 20:26:08 +08:00
|
|
|
/*! runtime requirements: module, __webpack_exports__, __webpack_require__.v, __webpack_require__ */
|
2019-10-09 05:45:47 +08:00
|
|
|
/***/ ((module, exports, __webpack_require__) => {
|
2018-05-07 18:36:38 +08:00
|
|
|
|
2019-06-05 20:26:08 +08:00
|
|
|
module.exports = __webpack_require__.v(exports, module.i)
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
/* 2 */
|
|
|
|
|
/*!*****************!*\
|
|
|
|
|
!*** ./math.js ***!
|
|
|
|
|
\*****************/
|
2019-02-05 01:52:39 +08:00
|
|
|
/*! export add [provided] [no usage info] [missing usage info prevents renaming] */
|
|
|
|
|
/*! export factorial [provided] [no usage info] [missing usage info prevents renaming] */
|
|
|
|
|
/*! export factorialJavascript [provided] [no usage info] [missing usage info prevents renaming] */
|
|
|
|
|
/*! export fibonacci [provided] [no usage info] [missing usage info prevents renaming] */
|
|
|
|
|
/*! export fibonacciJavascript [provided] [no usage info] [missing usage info prevents renaming] */
|
|
|
|
|
/*! other exports [not provided] [no usage info] */
|
2019-05-24 18:30:43 +08:00
|
|
|
/*! runtime requirements: __webpack_require__.r, __webpack_exports__, module, __webpack_require__, __webpack_require__.d */
|
2019-10-09 05:45:47 +08:00
|
|
|
/***/ ((module, __webpack_exports__, __webpack_require__) => {
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
"use strict";
|
2019-06-05 20:26:08 +08:00
|
|
|
module.exports = (async () => {
|
2017-11-24 15:40:39 +08:00
|
|
|
__webpack_require__.r(__webpack_exports__);
|
2019-10-09 05:45:47 +08:00
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
|
|
/* harmony export */ "add": () => /* reexport safe */ _add_wasm__WEBPACK_IMPORTED_MODULE_0__.add,
|
|
|
|
|
/* harmony export */ "factorial": () => /* reexport safe */ _factorial_wasm__WEBPACK_IMPORTED_MODULE_1__.factorial,
|
|
|
|
|
/* harmony export */ "fibonacci": () => /* reexport safe */ _fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__.fibonacci,
|
|
|
|
|
/* harmony export */ "factorialJavascript": () => /* binding */ factorialJavascript,
|
|
|
|
|
/* harmony export */ "fibonacciJavascript": () => /* binding */ fibonacciJavascript
|
|
|
|
|
/* harmony export */ });
|
2019-05-24 18:30:43 +08:00
|
|
|
/* harmony import */ var _add_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./add.wasm */ 1);
|
|
|
|
|
/* harmony import */ var _factorial_wasm__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./factorial.wasm */ 3);
|
|
|
|
|
/* harmony import */ var _fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fibonacci.wasm */ 4);
|
2019-10-09 05:45:47 +08:00
|
|
|
([_fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__, _factorial_wasm__WEBPACK_IMPORTED_MODULE_1__, _add_wasm__WEBPACK_IMPORTED_MODULE_0__] = await Promise.all([_fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__, _factorial_wasm__WEBPACK_IMPORTED_MODULE_1__, _add_wasm__WEBPACK_IMPORTED_MODULE_0__]));
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function factorialJavascript(i) {
|
|
|
|
|
if(i < 1) return 1;
|
|
|
|
|
return i * factorialJavascript(i - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fibonacciJavascript(i) {
|
|
|
|
|
if(i < 2) return 1;
|
|
|
|
|
return fibonacciJavascript(i - 1) + fibonacciJavascript(i - 2);
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 20:26:08 +08:00
|
|
|
return __webpack_exports__;
|
|
|
|
|
})();
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
/* 3 */
|
|
|
|
|
/*!************************!*\
|
2018-09-25 23:08:35 +08:00
|
|
|
!*** ./factorial.wasm ***!
|
2017-10-30 20:56:57 +08:00
|
|
|
\************************/
|
2019-08-05 19:32:25 +08:00
|
|
|
/*! export factorial [provided] [no usage info] [provision prevents renaming (no use info)] */
|
2019-02-05 01:52:39 +08:00
|
|
|
/*! other exports [not provided] [no usage info] */
|
2019-06-05 20:26:08 +08:00
|
|
|
/*! runtime requirements: module, __webpack_exports__, __webpack_require__.v, __webpack_require__ */
|
2019-10-09 05:45:47 +08:00
|
|
|
/***/ ((module, exports, __webpack_require__) => {
|
2017-10-30 20:56:57 +08:00
|
|
|
|
2019-06-05 20:26:08 +08:00
|
|
|
module.exports = __webpack_require__.v(exports, module.i)
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
/* 4 */
|
|
|
|
|
/*!************************!*\
|
2018-09-25 23:08:35 +08:00
|
|
|
!*** ./fibonacci.wasm ***!
|
2017-10-30 20:56:57 +08:00
|
|
|
\************************/
|
2019-08-05 19:32:25 +08:00
|
|
|
/*! export fibonacci [provided] [no usage info] [provision prevents renaming (no use info)] */
|
2019-02-05 01:52:39 +08:00
|
|
|
/*! other exports [not provided] [no usage info] */
|
2019-06-05 20:26:08 +08:00
|
|
|
/*! runtime requirements: module, __webpack_exports__, __webpack_require__.v, __webpack_require__ */
|
2019-10-09 05:45:47 +08:00
|
|
|
/***/ ((module, exports, __webpack_require__) => {
|
2018-05-07 18:36:38 +08:00
|
|
|
|
2019-06-05 20:26:08 +08:00
|
|
|
module.exports = __webpack_require__.v(exports, module.i)
|
2018-12-19 18:36:59 +08:00
|
|
|
|
|
|
|
|
/***/ })
|
2019-05-24 18:30:43 +08:00
|
|
|
/******/ ],
|
2018-12-19 18:36:59 +08:00
|
|
|
```
|
|
|
|
|
|
2019-05-24 18:30:43 +08:00
|
|
|
<details><summary><code>function(__webpack_require__) { /* webpackRuntimeModules */ });</code></summary>
|
2018-05-07 18:36:38 +08:00
|
|
|
|
2019-05-24 18:30:43 +08:00
|
|
|
``` js
|
|
|
|
|
/******/ function(__webpack_require__) { // webpackRuntimeModules
|
|
|
|
|
/******/ "use strict";
|
|
|
|
|
/******/
|
|
|
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
|
|
|
/******/ !function() {
|
|
|
|
|
/******/ // define __esModule on exports
|
2019-10-09 05:45:47 +08:00
|
|
|
/******/ __webpack_require__.r = (exports) => {
|
2019-05-24 18:30:43 +08:00
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ }();
|
|
|
|
|
/******/
|
2019-10-09 05:45:47 +08:00
|
|
|
/******/ /* webpack/runtime/define property getters */
|
2019-05-24 18:30:43 +08:00
|
|
|
/******/ !function() {
|
2019-10-09 05:45:47 +08:00
|
|
|
/******/ // define getter functions for harmony exports
|
2019-05-24 18:30:43 +08:00
|
|
|
/******/ var hasOwnProperty = Object.prototype.hasOwnProperty;
|
2019-10-09 05:45:47 +08:00
|
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
|
|
|
|
/******/ for(var key in definition) {
|
|
|
|
|
/******/ if(hasOwnProperty.call(definition, key) && !hasOwnProperty.call(exports, key)) {
|
|
|
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
|
|
|
/******/ }
|
2019-05-24 18:30:43 +08:00
|
|
|
/******/ }
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/ }();
|
|
|
|
|
/******/
|
|
|
|
|
/******/ /* webpack/runtime/publicPath */
|
|
|
|
|
/******/ !function() {
|
|
|
|
|
/******/ __webpack_require__.p = "dist/";
|
|
|
|
|
/******/ }();
|
|
|
|
|
/******/
|
|
|
|
|
/******/ /* webpack/runtime/wasm chunk loading */
|
|
|
|
|
/******/ !function() {
|
2019-06-05 20:26:08 +08:00
|
|
|
/******/ __webpack_require__.v = function(exports, wasmModuleId, importsObj) {
|
|
|
|
|
/******/ var req = fetch(__webpack_require__.p + "" + {"1":"3ee1e22348cddba39f35","3":"04913f0d8c9a5aaf9873","4":"4877696a77609bcaa166"}[wasmModuleId] + ".wasm");
|
2019-05-24 18:30:43 +08:00
|
|
|
/******/ if(typeof WebAssembly.instantiateStreaming === 'function') {
|
|
|
|
|
/******/ return WebAssembly.instantiateStreaming(req, importsObj)
|
2019-06-05 20:26:08 +08:00
|
|
|
/******/ .then(function(res) { return Object.assign(exports, res.instance.exports); });
|
2019-05-24 18:30:43 +08:00
|
|
|
/******/ }
|
|
|
|
|
/******/ return req
|
|
|
|
|
/******/ .then(function(x) { return x.arrayBuffer(); })
|
|
|
|
|
/******/ .then(function(bytes) { return WebAssembly.instantiate(bytes, importsObj); })
|
2019-06-05 20:26:08 +08:00
|
|
|
/******/ .then(function(res) { return Object.assign(exports, res.instance.exports); });
|
2019-05-24 18:30:43 +08:00
|
|
|
/******/ };
|
|
|
|
|
/******/ }();
|
|
|
|
|
/******/
|
|
|
|
|
/******/ }
|
|
|
|
|
);
|
|
|
|
|
```
|
2018-05-07 18:36:38 +08:00
|
|
|
|
2019-05-24 18:30:43 +08:00
|
|
|
</details>
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Info
|
|
|
|
|
|
2017-12-14 17:58:03 +08:00
|
|
|
## Unoptimized
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
```
|
2017-12-14 17:58:03 +08:00
|
|
|
Hash: 0a1b2c3d4e5f6a7b8c9d
|
2019-10-09 05:45:47 +08:00
|
|
|
Version: webpack 5.0.0-alpha.30
|
|
|
|
|
Asset Size Chunks Chunk Names
|
|
|
|
|
04913f0d8c9a5aaf9873.wasm 62 bytes ({179}) [emitted] [immutable] (main)
|
|
|
|
|
3ee1e22348cddba39f35.wasm 41 bytes ({179}) [emitted] [immutable] (main)
|
|
|
|
|
4877696a77609bcaa166.wasm 67 bytes ({179}) [emitted] [immutable] (main)
|
|
|
|
|
output.js 8.85 KiB {179} [emitted] main
|
2019-08-05 19:32:25 +08:00
|
|
|
Entrypoint main = output.js (04913f0d8c9a5aaf9873.wasm 3ee1e22348cddba39f35.wasm 4877696a77609bcaa166.wasm)
|
2019-10-09 05:45:47 +08:00
|
|
|
chunk {179} output.js (main) 1.3 KiB (javascript) 170 bytes (webassembly) 1.29 KiB (runtime) [entry] [rendered]
|
2019-01-25 20:15:22 +08:00
|
|
|
> ./example.js main
|
2019-05-24 18:30:43 +08:00
|
|
|
[0] ./example.js 761 bytes {179} [built]
|
|
|
|
|
[no exports]
|
2018-12-19 21:05:17 +08:00
|
|
|
[used exports unknown]
|
2019-02-05 01:52:39 +08:00
|
|
|
entry ./example.js main
|
2019-05-24 18:30:43 +08:00
|
|
|
[1] ./add.wasm 50 bytes (javascript) 41 bytes (webassembly) {179} [built]
|
2018-05-07 18:36:38 +08:00
|
|
|
[exports: add]
|
2018-09-26 05:13:58 +08:00
|
|
|
[used exports unknown]
|
2019-05-24 18:30:43 +08:00
|
|
|
harmony side effect evaluation ./add.wasm [0] ./example.js 1:0-39
|
|
|
|
|
harmony import specifier ./add.wasm [0] ./example.js 4:12-15
|
|
|
|
|
harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-39
|
2018-05-07 18:36:38 +08:00
|
|
|
harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37
|
2019-05-24 18:30:43 +08:00
|
|
|
[2] ./math.js 418 bytes {179} [built]
|
2019-02-05 01:52:39 +08:00
|
|
|
[exports: add, factorial, factorialJavascript, fibonacci, fibonacciJavascript]
|
2018-09-26 05:13:58 +08:00
|
|
|
[used exports unknown]
|
2019-05-24 18:30:43 +08:00
|
|
|
harmony side effect evaluation ./math [0] ./example.js 2:0-110
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 5:12-19
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 6:12-21
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 7:12-31
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 8:12-21
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 9:12-31
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 10:30-39
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 11:28-47
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 12:30-39
|
|
|
|
|
harmony import specifier ./math [0] ./example.js 13:28-47
|
|
|
|
|
[3] ./factorial.wasm 50 bytes (javascript) 62 bytes (webassembly) {179} [built]
|
2018-05-07 18:36:38 +08:00
|
|
|
[exports: factorial]
|
2018-09-26 05:13:58 +08:00
|
|
|
[used exports unknown]
|
2019-05-24 18:30:43 +08:00
|
|
|
harmony side effect evaluation ./factorial.wasm [2] ./math.js 2:0-51
|
2018-05-07 18:36:38 +08:00
|
|
|
harmony export imported specifier ./factorial.wasm [2] ./math.js 5:0-37
|
2019-05-24 18:30:43 +08:00
|
|
|
[4] ./fibonacci.wasm 50 bytes (javascript) 67 bytes (webassembly) {179} [built]
|
2018-09-25 23:08:35 +08:00
|
|
|
[exports: fibonacci]
|
2018-09-26 05:13:58 +08:00
|
|
|
[used exports unknown]
|
2019-05-24 18:30:43 +08:00
|
|
|
harmony side effect evaluation ./fibonacci.wasm [2] ./math.js 3:0-51
|
2018-09-25 23:08:35 +08:00
|
|
|
harmony export imported specifier ./fibonacci.wasm [2] ./math.js 5:0-37
|
2019-05-24 18:30:43 +08:00
|
|
|
+ 4 hidden chunk modules
|
2017-10-30 20:56:57 +08:00
|
|
|
```
|
|
|
|
|
|
2017-12-14 17:58:03 +08:00
|
|
|
## Production mode
|
2017-10-30 20:56:57 +08:00
|
|
|
|
|
|
|
|
```
|
2017-12-14 17:58:03 +08:00
|
|
|
Hash: 0a1b2c3d4e5f6a7b8c9d
|
2019-10-09 05:45:47 +08:00
|
|
|
Version: webpack 5.0.0-alpha.30
|
|
|
|
|
Asset Size Chunks Chunk Names
|
|
|
|
|
5ba3e3921117e9d828f5.wasm 67 bytes ({179}) [emitted] [immutable] (main)
|
|
|
|
|
5dd947250fab86306d49.wasm 62 bytes ({179}) [emitted] [immutable] (main)
|
|
|
|
|
6f6c0ffc52ce3a45ff7e.wasm 41 bytes ({179}) [emitted] [immutable] (main)
|
|
|
|
|
output.js 1.89 KiB {179} [emitted] main
|
2019-08-05 19:32:25 +08:00
|
|
|
Entrypoint main = output.js (5ba3e3921117e9d828f5.wasm 5dd947250fab86306d49.wasm 6f6c0ffc52ce3a45ff7e.wasm)
|
2019-10-09 05:45:47 +08:00
|
|
|
chunk {179} output.js (main) 1.3 KiB (javascript) 170 bytes (webassembly) 1.29 KiB (runtime) [entry] [rendered]
|
2019-01-25 20:15:22 +08:00
|
|
|
> ./example.js main
|
2019-05-24 18:30:43 +08:00
|
|
|
[78] ./factorial.wasm 50 bytes (javascript) 62 bytes (webassembly) {179} [built]
|
2019-05-10 03:34:28 +08:00
|
|
|
[exports: factorial]
|
2019-08-05 19:32:25 +08:00
|
|
|
[all exports used]
|
2019-05-24 18:30:43 +08:00
|
|
|
harmony side effect evaluation ./factorial.wasm [451] ./math.js 2:0-51
|
2019-05-10 03:34:28 +08:00
|
|
|
harmony export imported specifier ./factorial.wasm [451] ./math.js 5:0-37
|
2019-05-24 18:30:43 +08:00
|
|
|
[144] ./example.js 761 bytes {179} [built]
|
|
|
|
|
[no exports]
|
|
|
|
|
entry ./example.js main
|
|
|
|
|
[451] ./math.js 418 bytes {179} [built]
|
2019-02-05 01:52:39 +08:00
|
|
|
[exports: add, factorial, factorialJavascript, fibonacci, fibonacciJavascript]
|
2019-05-24 18:30:43 +08:00
|
|
|
[all exports used]
|
|
|
|
|
harmony side effect evaluation ./math [144] ./example.js 2:0-110
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 5:12-19
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 6:12-21
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 7:12-31
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 8:12-21
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 9:12-31
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 10:30-39
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 11:28-47
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 12:30-39
|
|
|
|
|
harmony import specifier ./math [144] ./example.js 13:28-47
|
|
|
|
|
[461] ./add.wasm 50 bytes (javascript) 41 bytes (webassembly) {179} [built]
|
2019-05-10 03:34:28 +08:00
|
|
|
[exports: add]
|
2019-08-05 19:32:25 +08:00
|
|
|
[all exports used]
|
2019-05-24 18:30:43 +08:00
|
|
|
harmony side effect evaluation ./add.wasm [144] ./example.js 1:0-39
|
|
|
|
|
harmony import specifier ./add.wasm [144] ./example.js 4:12-15
|
|
|
|
|
harmony side effect evaluation ./add.wasm [451] ./math.js 1:0-39
|
2019-05-10 03:34:28 +08:00
|
|
|
harmony export imported specifier ./add.wasm [451] ./math.js 5:0-37
|
2019-05-24 18:30:43 +08:00
|
|
|
[605] ./fibonacci.wasm 50 bytes (javascript) 67 bytes (webassembly) {179} [built]
|
2019-05-10 03:34:28 +08:00
|
|
|
[exports: fibonacci]
|
2019-08-05 19:32:25 +08:00
|
|
|
[all exports used]
|
2019-05-24 18:30:43 +08:00
|
|
|
harmony side effect evaluation ./fibonacci.wasm [451] ./math.js 3:0-51
|
2019-05-10 03:34:28 +08:00
|
|
|
harmony export imported specifier ./fibonacci.wasm [451] ./math.js 5:0-37
|
2019-05-24 18:30:43 +08:00
|
|
|
+ 4 hidden chunk modules
|
2017-10-30 20:56:57 +08:00
|
|
|
```
|