V3.0. How to add new classes via an extension

I’m trying to adopt extension written for v2.4 for version 3.0 of the Creator. I can’t find any documentation on how to add classes to the applications using extensions.

From the documentation repository (GitHub - cocos-creator/creator-docs: Manual docs content for Cocos Creator) I can see some contributions functionality, but the docs are very poor and don’t describe clearly how to write classes in the extension and use them in the main game scripts.

Is there any related documentation written?

Maybe you mean you want the extension to provide scripts and resources

In the 2.4 version
extension can used as the media for the components and resources.

// package.json
  "runtime-resource": {
    "path": "path/to/runtime-resource",
    "name": "shared-resource"

In the 3.0 version

We need to define it this way.


    "name": "test-package",

    "contributions": {

        "asset-db": {

            "mount": {

                "path": "./assets",

                "readonly": true





interface AssetDBConfig {


        //Directory of resources, relative to the extension

        path: string;

        //Whether the resource is read-only or not, the default is not

        readonly?: boolean;



@a34285648 I put provided "contributions" section into my package.json and now I see the scripts from the extension. I didn’t get where to put interface AssetDBConfig {... section, but it looks everything is accepted without it.

My next step is to import a script from the extension into a script from the application.
I have a script {project}/extensions/neutrinoparticles/runtime/NeutrinoComponent.ts in the extension.
Also, following section in the {project]/extensions/neutrinoparticles/package.json:

"contributions": {
    "asset-db": {
      "mount": {
        "path": "./runtime",
        "readonly": false

How can I import NeutrinoComponent script above to an application script {project}/assets/SomeScript.ts? Which path should I use in the import directive?

import NeutrinoComponent from './NeutrinoComponent.ts doesn’t work.

Sorry, don’t support this

@a34285648, you probably didn’t understand what I mean, because that is essential part of the engine.

I have an extension and I introduced some class in this extension by .ts script. What I need is to use this class in the main application scripts in assets folder. So I need to know how correctly import the script.

It is an essential part of the engine, because why then we need extensions if we can’t use scripts from them?

For the example above I tried:

  1. import NeutrinoComponent from './NeutrinoComponent.ts
  2. import NeutrinoComponent from 'NeutrinoComponent'

And none of those are working in 3.0 version. But in the 2.4 version the second variant worked well.

We currently do not support cross-referencing to script modules between different asset-db(ie. between plugins’ assets folders and main assets folder). We have plans for that.

Hi, we released an experimental support in 3.1.

Enable your plugin and mount your plugin assets directory as described in V3.0. How to add new classes via an extension - #2 by a34285648 . After this you can let users import your plugin assets through URL “db://your-plugin-name/script-path”. For example, to reference “assets/scripts/bar” in plugin “foo”, use “db://foo/scripts/bar”.

Again, this feature is experimantal, undocumented and might be bugly. If errors were encountered, you may try to remove the “temp” folder under project root.

So, I need to import scripts something like this:
import NeutrinoComponent from 'db://neutrinoparticles/runtime/NeutrinoComponent.ts'