示例工程 11-commonjs

11-commonjs/03-circular-deps/index.html

html · 0.5 KB

运行:11 · CommonJS 循环依赖

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

<!doctype html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>11 · CommonJS 循环依赖</title>
</head>
<body>
  <p>打开 Console 查看循环依赖时双方拿到的半成品。</p>
  <script type="module">
    import { FACTORIES, createRuntime, run } from './main.js';
 
    const { require } = createRuntime(FACTORIES);
    const a = require('./a');
    console.log('a.bSawA =>', a.bSawA);
    console.log('require("./b").aBName =>', require('./b').aBName);
    run();
  </script>
</body>
</html>