【bundle】关于Bundle热加载,脚本更新的问题

在window7是了一下是可以的。脚本可以重新加载了。需要魔改

14:48:16 [DEBUG]: D/ JS: [WARN]: Failed to set shading scale, pipelineSceneData is invalid.
14:48:16 [DEBUG]: EGL context bounded to thread ed4d41b27595a77
14:48:16 [INFO]: Device thread detached.
14:48:16 [DEBUG]: D/ JS: downloadBundle internal
14:48:16 [DEBUG]: D/ JS: Cocos Creator v3.6.1
14:48:16 [DEBUG]: D/ JS: downloadBundle main
14:48:16 [INFO]: Shader ‘util/splash-screen|splash-screen-vs:vert|splash-screen-fs:frag’ compilation succeeded.
14:48:20 [DEBUG]: D/ JS: Success to load scene: db://assets/scene-2d.scene
14:48:20 [INFO]: Shader ‘builtin-sprite|sprite-vs:vert|sprite-fs:frag|CC_USE_EMBEDDED_ALPHA0|USE_TEXTURE1|IS_GRAY0’ compilation succeeded.
14:48:20 [INFO]: Shader ‘util/profiler|profiler-vs:vert|profiler-fs:frag’ compilation succeeded.
14:48:22 [DEBUG]: D/ JS: bundle
14:48:22 [DEBUG]: D/ JS: 加载bundle
14:48:22 [DEBUG]: D/ JS: downloadBundle bundle_01
14:48:22 [DEBUG]: D/ JS: bundle_game_1脚本
14:48:22 [DEBUG]: D/ JS: bundle_game_1 2脚本
14:48:22 [DEBUG]: D/ JS: bundle_game_2脚本
14:48:22 [DEBUG]: D/ JS: bundle_01脚本
线程 0x2880 已退出,返回值为 0 (0x0)。
14:48:23 [DEBUG]: D/ JS: bundle
14:48:23 [DEBUG]: D/ JS: 移除bundle
14:48:25 [DEBUG]: D/ JS: bundle
14:48:25 [DEBUG]: D/ JS: 加载bundle
14:48:25 [DEBUG]: D/ JS: downloadBundle bundle_01
14:48:25 [DEBUG]: D/ JS: bundle_game_1脚本
14:48:25 [DEBUG]: D/ JS: [ERROR]: A Class already exists with the same cid : “60a25hgAXhCToShSex+/DtA”.
14:48:25 [DEBUG]: D/ JS: bundle_game_1 2脚本
14:48:25 [DEBUG]: D/ JS: [ERROR]: A Class already exists with the same cid : “6aafcsOxEBCO4dmDo/bwnm/”.
14:48:25 [DEBUG]: D/ JS: bundle_game_2脚本
14:48:25 [DEBUG]: D/ JS: [ERROR]: A Class already exists with the same cid : “3b44auPptdF15ef2vvdHW1L”.
14:48:25 [DEBUG]: D/ JS: bundle_01脚本
14:48:25 [DEBUG]: D/ JS: [ERROR]: A Class already exists with the same cid : “41285oJOYFPTrUxRpiEPEFX”.
14:48:25 [DEBUG]: D/ JS: bundle
14:48:25 [DEBUG]: D/ JS: 移除bundle

我也找到了,就是有点烦,需要先移除SystemJS[REGISTRY]里面的缓存,然后再修改instantiated.js里面setup,这就有点烦了

这个是构建之后的文件吧,要改他引擎构建前的,我回头试下

可以.关注了.

大佬有联系方式吗?请教下


image



这样卸载就可以了,版本3.6.1

6赞

不错不错,借鉴下

已经是精髓代码了





我不想动引擎,通过插件hack构建后的代码实现了

这个tsFileNames.json文件是自己生成写进去的吗?引擎这边没有找到这个文件。

一看就是自己写的啦。

拿来就用是吧~~~

项目中不要出现重名的脚本,因为编译的时候重名的脚本会加上后缀(1, 2, 3, …),这样会导致如果删除了其中一个,就会导致后缀顺序错乱,这样引用就会出问题了

哈哈,照着思路写了下,发现这个json文件,在想是不是构建的时候解析index.js,然后存到里面去的

嗯嗯,活到老学到老。

目前我是运行时解析(更新的时候解析一次)

嗯,感谢大佬的细心指导,我验证下。那个system.bundle.js这个是构建出来的文件,我在引擎只看到loader.js有类似的代码,但是我修改之后构建出来的system.bundle.js并没有生效,所以还是可以利用打包工具在build之后再插入你的修改,你是不是这样搞的?

是的,构建扩展,构建完后把代码加进去

这边验证了,也确实是删除了,但是重新loadBundle,会报找不到之前的classimage 是不是还得手动register这个class

不需要,你更新子包后先卸载之前的子包,再重新加载该子包,是这样操作的吗?

image