# Mini game framework is running

The developer selects the corresponding framework version number, and the corresponding framework code will be downloaded when the client downloads the mini game.

# Use Mini Game Framework Ability

The developer's code can obtain the interface of the mini game framework through the global variable engine. However, there is no way to directly obtain code hints. Developers can use import engine from "engine" to obtain them. In this way, the editor can use the index.d.ts in node_modules/@types/engine injected by the tool. , Prompt the code. The default node_modules/engine/miniprogram_dist/index.js in the new project is actually not a real npm package, but directly returns the framework capabilities of the global injection, and an error will be reported if npm install. When upgrading the version, the tool will automatically update the corresponding index.d.ts.

# Typescript

It is recommended to use Typescript to develop small games by default, so that you can use the code hints of the small game framework interface. It also supports javascript development, but some capabilities are not easy to implement, such as decorators and type checking that are often used in development, which are more suitable for importing external libraries. Finally, after the tool is compiled, the js code runs on the real machine.

# Compilation and packaging

The Typescript compiler of version 4.1.3 is built in the tool. Developers can create code files directly in the Project window without installing the compiler themselves. For the javascript code, the built-in compilation module is not supported temporarily, if the developer needs to use it, they need to compile it by themselves. In the development stage, the tool will inject the code in the fastest way to load it, and at the same time will ensure the hot update of the code in the editing mode. Before uploading the code, it also supports compressing the obfuscated code to ensure that the package size is minimized.

# Code Editor

Developers can use the built-in code editor of the tool, or use the code editor installed by themselves. Either way, the tool will monitor the file modification in real time.

# npm package

The applet currently does not support direct import of node_modules. When developers need to use node_modules, it is recommended to copy the relevant code to the applet’s directory, or use the npm function supported by the applet (after npm install, use the tool "build npm" to compile That's it).

点击咨询小助手