Module Specifications and Examples
All code files can be roughly divided into Plugin Script and Module two kinds, this section mainly introduces the module related.
Code created in the project, including component scripts and project (non-component) scripts.
Functionality provided by the engine, please refer to the Engine Modules for details.
Third-party modules, such as the
npmmodule. Please review the External Module Usage Case documentation for details.
Cocos Creator natively supports and recommends the use of the ECMAScript (ESM for short) module format. To support the use of external modules, Cocos Creator also supports the CommonJS module format to some extent. For additional information about the module format and usage in Cocos Creator, please refer to the Module Specification documentation.
Module Loading Order
The modules are loaded in the following order:
First import of the engine module
"cc"of Cocos Creator 3.x.
Plugin scripts: all plugin scripts will be executed in the order of the specified plugin script dependencies, there is disorder between plugin scripts that do not have dependencies. Please refer to the Plugin Scripts documentation for details.
Common scripts: all common scripts will be imported concurrently, and the import will strictly follow the reference relationships and execution order determined by