chore: rename runtime Lib/Module.lua & Lib/Class.lua to lowercase lib/module.lua & lib/class.lua (v0.3.1)
This commit is contained in:
1 parent
b1a53d8660
commit
1e2a0b7546
13 files changed
+42
-37
No files matched your search
@@ -158,13 +158,13 @@ export default class WBP_TempPopup {
|
||||
|
||||
### 3.4 自定义模块化与单文件热更(`v0.3.0+` 默认启用)
|
||||
|
||||
`ts2lua-unreal` 默认启用 `moduleSystem: "hot-reload"`,会在编译输出目录自动生成 `Lib/Module.lua` 与 `Lib/Class.lua`(零入侵 UnLua,不劫持 `_G.require`)。
|
||||
`ts2lua-unreal` 默认启用 `moduleSystem: "hot-reload"`,会在编译输出目录自动生成 `lib/module.lua` 与 `lib/class.lua`(零入侵 UnLua,不劫持 `_G.require`)。
|
||||
|
||||
**启动引导(`Boot.lua` 或 UE 启动入口)**:
|
||||
```lua
|
||||
-- 启动期以原生 require 加载基础库(不热更)
|
||||
require("Lib.Module")
|
||||
require("Lib.Class")
|
||||
require("lib.module")
|
||||
require("lib.class")
|
||||
-- 进入业务 TS 模块体系
|
||||
__MODULE__.Import("Main").Startup()
|
||||
```
|
||||
@@ -172,7 +172,7 @@ __MODULE__.Import("Main").Startup()
|
||||
**`require` 与 `__MODULE__.Import` 边界**:
|
||||
- UnLua 自身代码、外部原生 Lua/C 插件:TS 中直接写 `const cjson = require("cjson")` / `require("UnLua.HotReload")`,编译后原样保留 `require(...)`(且不会触发 TSTL 100000 报错);
|
||||
- 项目内业务/框架 TS 模块之间的 `import` / `export ... from`:自动编译为 `__MODULE__.Import("...", __module)` 并生成 `__module.UpdateImports()`;
|
||||
- 推荐在 UE C++ 层仅保留少量薄桥接类,通过回调分发至纯 TS 模块与纯 TS 类(`Lib/Class.lua` 的 `__TS__DefineClass` 自动复用类原型表),实现全业务无痛单文件热更。
|
||||
- 推荐在 UE C++ 层仅保留少量薄桥接类,通过回调分发至纯 TS 模块与纯 TS 类(`lib/class.lua` 的 `__TS__DefineClass` 自动复用类原型表),实现全业务无痛单文件热更。
|
||||
|
||||
**跨热更保留状态(`@module_data`)与生命周期钩子**:
|
||||
```ts
|
||||
@@ -201,7 +201,7 @@ const [ok, err] = __MODULE__.ReimportSafely("Framework.Counter");
|
||||
```
|
||||
|
||||
> 如需切回传统 TSTL `require` 产物或关闭运行时自动输出,可在 `tsconfig.json` 的 `tstl.luaPlugins` 中传入:
|
||||
> `{ "name": "ts2lua-unreal", "moduleSystem": "standard" }` 或 `{ "name": "ts2lua-unreal", "emitRuntime": false, "runtimeDir": "Lib" }`。
|
||||
> `{ "name": "ts2lua-unreal", "moduleSystem": "standard" }` 或 `{ "name": "ts2lua-unreal", "emitRuntime": false, "runtimeDir": "lib" }`。
|
||||
|
||||
### 3.5 纯逻辑工具模块(非 `UObject`)
|
||||
文件顶部加 `/** @noSelfInFile */`,编译为点号调用模块(如 `Log.Info(...)`、`EventBus.On(...)`):
|
||||
|
||||
Reference in new issue
Block a user