How to define a bundle in extension package?

Is it possible to define a bundle in extension packages of the editor? And load it dynamically by cc.assetManager.loadBundle()?

It shouldn’t be a remote bundle. Just normal one.

@yufang.wu do you know?

Firstly, you need to configurate your package as runtime resources, refer this. package.json Reference · Cocos Creator. then you will see a folder in your project like this:
image

Secondly, you need a bit of hacking: find and open the folder’s meta file, change isBundle to true.(Sorry, the resources of extension in the Creator 2.4.x are read-only and can only be set by modifying the meta file, 3.0 will fix this issue)

and then you will see the folder is changed to the bundle, you can load and use this bundle as usual

1 Like

Thank you @SantyWang, I already figured that out and created a folder in the extension which is marked as a bundle. I made it by creating folder in assets and then moved it manually with .meta file to the package runtime folder.

But when I try to load it with:

image

It gives me an error:

NeutrinoContext: can’t load a bundle. Error: Load assets/test_bundle/index.js failed!

Looks like it tries to load the bundle from assets and not from extension.

Do you have any suggestions?

Where do you call loadBundle,loadBundle is not available in the editor environment

I see. Then a bundle is not my choice, because I need to have components from the extension package working in the editor and using resources from the bundle.

Then I’ll return to the topic How to load cc.Effect from extension package? as I need to load .effect file somehow dynamically and to have it working in the editor. Could you check my further question there?