二七王:逻辑文件补双运行时守卫,解锁 Node 单测
按 dev-guide 01 §1「一套代码,两个运行时」补齐 erqiwang 缺失的守卫(此前只支持友乐全局加载模型):
- 顶部:跨模块依赖走 `if (typeof require!=='undefined') var X=require('./class.X.js')`
(config/pai/arith 无跨模块依赖;paiju 依赖 arith/config/pai;desk 依赖 paiju;export 依赖 arith/config/desk)
- 底部:`if (typeof module!=='undefined') module.exports = cls_X`
- export/import 的平台接线 `youle_erqiwang.X=...` 加 `typeof youle_erqiwang` 守卫,Node 无此全局时跳过
纯增量:友乐无 require(浏览器模型),守卫全部跳过、全局名仍无条件暴露,线上行为不变;
仅在 Node 下额外启用 require/module.exports,从而可用 node 直接单测。min_*/youle_erqiwang 等平台全局仍按全局名引用(Node 侧由测试 shim 提供)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -26,5 +26,12 @@ var cls_youle_erqiwang_import = cls_youle_erqiwang_import || {
|
||||
}
|
||||
}
|
||||
|
||||
// 输入接口
|
||||
youle_erqiwang.import = cls_youle_erqiwang_import.new();
|
||||
// 输入接口(友乐/浏览器:youle_erqiwang 由 mod.js 先建;Node 单测无此全局时跳过)
|
||||
if (typeof youle_erqiwang !== "undefined"){
|
||||
youle_erqiwang.import = cls_youle_erqiwang_import.new();
|
||||
}
|
||||
|
||||
//Node 导出;友乐/浏览器无 module 时跳过(dev-guide 01 §1)。youle_erqiwang.app 为平台全局
|
||||
if (typeof module !== "undefined"){
|
||||
module.exports = cls_youle_erqiwang_import;
|
||||
}
|
||||
Reference in New Issue
Block a user