示例工程 17-pre-module-globals
17-pre-module-globals/03-script-order/src/main.ts
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
// 演示:脚本顺序错乱时,依赖方拿到 undefined(这里读全局结果)
export function run(log: (msg: string) => void = console.log): string[] {
const lines = [
`orderResult:${String(orderResult ?? 'undefined')}`,
`DepUtils:${typeof DepUtils}`,
];
for (const line of lines) {
log(line);
}
return lines;
}