示例工程 17-pre-module-globals
17-pre-module-globals/03-script-order/README.md
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
# 03 · script-order
**演示**:依赖方先加载、被依赖方后加载,`DepUtils` 还不存在,赋值表达式抛 `ReferenceError`。
**运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开
`http://localhost:8080/examples/17-pre-module-globals/03-script-order/`;开 Console。
**预期控制台输出**:
```text
Uncaught ReferenceError: DepUtils is not defined
orderResult:undefined
DepUtils:object
```
**类型检查**:`node node_modules/typescript/bin/tsc -p examples/17-pre-module-globals/03-script-order/tsconfig.types.json`
**注意**:第一行红色错误来自 `scripts/user.js`;页面继续加载 `dep.js`,所以模块还能读到 `DepUtils`。