示例工程 20-amd-requirejs
20-amd-requirejs/02-paths-shim/README.md
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
# 02 · paths-shim
**演示**:`require.config` 的 `paths` 把模块 ID `legacy` 指到非 AMD 脚本,`shim` 指定它导出的全局名。
**运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开
`http://localhost:8080/examples/20-amd-requirejs/02-paths-shim/`;开 Console。
**预期控制台输出**:
```text
legacy: 6
```
**类型检查**:`node node_modules/typescript/bin/tsc -p examples/20-amd-requirejs/02-paths-shim/tsconfig.types.json`
**注意**:`paths` 是运行时配置,类型检查不会验证它;模块 ID 与实际文件对不上时只有浏览器报错。