Introduction to the

Portal:

  • Amove Compiler – General purpose solution for code compilation
  • Wx2my – wechat applets transferred to Alipay version based on Amove reconstruction

Antmove small program converter, last May began the project, about July officially open source, so far has helped hundreds of small programs to achieve conversion migration. In the process of updating maintenance, along with the increase in conversion platform and user-defined demand growth, Antmove need to deal with problems and logic become more complex, in order to deal with the expansion of the support platform and transformation function of complicated logic, the team has carried on the 2.0 version refactoring, aims to provide a set of generic code compilation of scalable plug-in solutions.

Amove – An underlying compiler tool for quick compilation implementation of code

Code compilation and transformation is a complex application scenario. In order to deal with code compilation of large projects, we need a safe, reliable and convenient architectural model, thus Amove was born. After a long time of iteration, Amove has accumulated a set of best practice solutions for code compilation. In addition to Antmove, it also supports code migration and transformation for multiple projects of the team.

Flow chart of Amove compilation

As can be seen from the figure above, the compilation process of Amove is divided into two stages: compilation and secondary compilation. At the same time, the hot compilation function can be simply realized through predictable compilation model.

In addition to the control of compilation process, Amove provides flexible plug-in mechanism (refer to Babel’s plug-in working mechanism). Amove’s plug-in design is more flexible than Babel and can be used in combination with other compiler tools. For example, the code compilation part of Antmove version JS based on Amove reconstruction is combined with Babel.

For more information, see the Amove documentation.

Ant – move. Making. IO/amove / # amov…

wx-compiler

Wx-compiler is the first step of Antmove 2.0 reconstruction. It is a fully plug-in version of wechat applets to other applets. Based on this version, users can insert custom operations into the entire compilation process of WX-Compiler, so as to realize the custom conversion tool.

How to use

The latest version of AntMove has integrated wX2my command, namely wX-Compiler to Alipay small program ability, wechat to other platforms will be gradually introduced.

  • Quick guide

Antmove compiles atomic splitting

The current implementation version of WX-Compiler consists of about 50 compiler atoms, which are divided into the following three modules

  • @AMOve/WX – wechat small program data parsing module
  • Amove/wX-utils – wechat applet general processing compiler atomic set
  • @AMOve/WX – Alipay – wechat small program to alipay compilation atomic set

Based on the above structure, as long as we expand the @amove/ WX-Alipay module, we can get the conversion version of wechat mini program to other platforms.

Compile plug-in writing?

Writing a plug-in is as simple as writing a simple function like this:

  • Change the navigation background color

Create a new JS file and copy the following code to take effect before compiling.

useReducer({
    AppJsonWindow (node) {
        node.body.window.navigationBarBackgroundColor = '# 000000'; }});Copy the code

AppJsonWindow is a compilation atom built into Antmove, which is also a compilation process node of Antmove. It is easy to customize the functions of this stage in the above way.

  • Component import path handling
useReducer({
    AppJson (node) {
        node.body.window.navigationBarBackgroundColor = '# 000000';
    },
    UsingComponent (node) {
        console.log(node.body);
	  // For example, vCard => V-card
	  // Or specify an import path for a component}});Copy the code

conclusion

In Antmove 2.0, we hope that Antmove converters will become a universal solution for small program compilation, so that more users who need customization can make full use of Antmove’s capabilities, while also expanding their transformation needs. In addition to the basic Antmove extension, which provides plug-ins for Antmove, Amove can also be used as a solution to other compilation challenges, such as code migration, scaffolding generation, etc.