示例工程 15-why-bundlers
15-why-bundlers/03-wrapped-runtime/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>15 · 函数包装 + 运行时</title>
</head>
<body>
<p>打开 Console 查看手写打包产物的执行结果。</p>
<script type="module">
import { GRAPH, buildBundle, evaluateBundle, run } from './main.js';
const bundle = buildBundle(GRAPH, './main.js');
const result = evaluateBundle(bundle);
console.log('bundle 开头 =>', bundle.split('\n').slice(0, 5).join(' | '));
console.log('main.run() =>', result.run());
run();
</script>
</body>
</html>