Applet code compiling method and device, equipment and medium

By introducing a separate management mechanism for the main package configuration file and sub-package configuration files in the mini-program code compiler, the problems of poor maintainability and code reusability during the compilation process of mini-program code are solved, and flexible compilation and management for multiple partners are realized.

CN111045683BActive Publication Date: 2026-03-24WEBANK (CHINA)
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-13
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

The existing mini-program code compilation process suffers from poor maintainability and code reusability, especially when there are customization requirements from multiple partners, making it difficult for existing technologies to effectively manage and compile different branches of code.

Method used

In the mini-program code compiler, main package configuration files and sub-package configuration files are set, and compilation is queued by processing queues. Branch code and general code of different subtype mini-programs are obtained and processed to achieve separate management and unified compilation of code.

Benefits of technology

It improves the maintainability and reusability of mini-program code compilation, can adapt to various customization needs, and simplifies the code maintenance and management process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111045683B_ABST
    Figure CN111045683B_ABST
Patent Text Reader

Abstract

The application discloses a kind of applet code compiling method, device, equipment and medium, it is related to financial technology technical field, the method is applied to applet code compiler, which is provided with main package configuration file, subpackage configuration file and processing queue, the applet code compiling method includes: when receiving applet code compiling instruction, the main package configuration file and the file content corresponding to the subpackage configuration file are obtained, wherein the branch code required by different sub-type applets in the applet is set in the subpackage configuration file, and the common code required by different sub-type applets in the applet is set in the main package configuration file;Based on the whole file content, obtain the node to be processed;The node to be processed is placed in the processing queue to be queued and compiled to obtain a compiled file.The application solves the technical problems of poor maintainability and poor code reusability in existing applet code compilation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Fintech, and in particular to a mini-program code compiling method and device, equipment and medium. BACKGROUND

[0002] With the development of Fintech, especially the Internet technology finance, more and more technologies are applied in the financial field. Among them, the mini-program code compilation in the financial field involves many technical applications. The existing mini-program code includes main branch code (the most general version) and other branch code (non-general version) to meet the customization needs of multiple partners. Specifically, when a partner needs to modify the mini-program interface UI or customize its own characteristic page, a code branch is usually added to the existing main branch code to achieve this. Since the newly added code branch is developed and customized, that is, it is not general, the customized mini-program code (code upgraded by modifying the main branch code) can only be compiled separately during the compilation process. When there are more and more partners, the technical problems of poor maintainability and poor code reusability exist in the mini-program code compilation process. SUMMARY

[0003] The main purpose of the present application is to provide a mini-program code compiling method, device, equipment and medium, which aims to solve the technical problems of poor maintainability and poor code reusability in the existing mini-program code compilation.

[0004] To achieve the above-mentioned purpose, the embodiment of the present application provides a mini-program code compiling method, which is applied to a mini-program code compiler. The mini-program code compiler is provided with a main package configuration file, a sub-package configuration file and a processing queue. The mini-program code compiling method comprises the following steps:

[0005] When receiving a mini-program code compiling instruction, the main package configuration file and the file content corresponding to the sub-package configuration file are obtained. The sub-package configuration file is provided with branch code required by different sub-type mini-programs in the mini-program, and the main package configuration file is provided with general code required by different sub-type mini-programs in the mini-program.

[0006] Based on the file content, a to-be-processed node is obtained.

[0007] The to-be-processed node is placed in the processing queue for queuing and compiling processing to obtain a compiled file.

[0008] Optionally, the mini-program code compiler is provided with a parameter configuration file. The step of obtaining the to-be-processed node based on the file content comprises the following steps:

[0009] determining whether the whole file content has a dependent node according to a file suffix in the whole file content;

[0010] if the whole file content has no dependent node, obtaining a target parameter from the parameter configuration file, and replacing a corresponding parameter in the whole file content with the target parameter;

[0011] replacing the whole file content after the corresponding parameter is replaced as a to-be-processed node.

[0012] Optionally, the step after determining whether the whole file content has a dependent node according to a file suffix in the whole file content comprises:

[0013] if the whole file content has a dependent node, searching for paths of all dependent nodes of the whole file content according to the file suffix;

[0014] reading dependent node content of the all dependent nodes according to the paths of the all dependent nodes;

[0015] replacing the dependent node content and the whole file content as a to-be-processed node.

[0016] Optionally, the step of queuing and compiling the to-be-processed node in the processing queue to obtain a compiled file comprises:

[0017] generating a project structure according to a dependency relationship between the dependent node content and the whole file content in the to-be-processed node;

[0018] performing parameter replacement processing and queuing and compiling processing on the processed dependent node content of the project structure according to the parameter configuration file, and performing parameter replacement processing and queuing and compiling processing on the processed whole file content of the project structure, to obtain a compiled file.

[0019] Optionally, the step of searching for paths of all dependent nodes of the whole file content according to the file suffix if the whole file content has a dependent node comprises:

[0020] if the whole file content has a dependent node, classifying dependent file content corresponding to the dependent node according to different file suffix types to obtain a classification result;

[0021] adopting a corresponding traversal mode to search for paths of all dependent nodes of the whole file content according to the classification result, the traversal mode comprising a statement traversal mode, an attribute traversal mode and a regular expression traversal mode.

[0022] Optionally, the applet code compiler is provided with a packaging configuration file, and the step of placing the to-be-processed node in the processing queue for queued compilation processing to obtain a compiled file comprises:

[0023] an address specified in the packaging configuration file is obtained, and the compiled file is output to the specified address.

[0024] Optionally, the step of obtaining an address specified in the packaging configuration file and outputting the compiled file to the specified address comprises:

[0025] a project name of the compiled file is obtained from the packaging configuration file, and the compiled file, the project name, and the specified address are associated and saved.

[0026] The application further provides an applet code compilation device, which is applied to an applet code compiler, the applet code compiler is provided with a main package configuration file, a subpackage configuration file, and a processing queue, and the applet code compilation device comprises:

[0027] a first obtaining module, configured to, when receiving an applet code compilation instruction, obtain all file contents corresponding to the main package configuration file and the subpackage configuration file, wherein the subpackage configuration file is provided with branch codes required by different sub-type applets in the applet, and the main package configuration file is provided with common codes required by different sub-type applets in the applet;

[0028] a second obtaining module, configured to obtain a to-be-processed node based on the all file contents.

[0029] a compiling module, configured to place the to-be-processed node in the processing queue for queued compilation processing to obtain a compiled file.

[0030] Optionally, the applet code compiler is provided with a parameter configuration file, and the second obtaining module comprises:

[0031] a determining unit, configured to determine, according to a file suffix in the all file contents, whether the all file contents have a dependent node;

[0032] an obtaining unit, configured to, if the all file contents do not have a dependent node, obtain a target parameter from the parameter configuration file, and replace a corresponding parameter in the all file contents with the target parameter;

[0033] a first setting unit, configured to take the all file contents after the corresponding parameter is replaced as the to-be-processed node.

[0034] Optionally, the second obtaining module further comprises:

[0035] The searching unit is configured to search for paths of all dependency nodes of the whole file content according to the file suffix if the whole file content has dependency nodes.

[0036] The reading unit is configured to read dependency node content of the all dependency nodes according to the paths of the all dependency nodes.

[0037] The second setting unit is configured to set the dependency node content and the whole file content as nodes to be processed.

[0038] Optionally, the compiling module comprises:

[0039] The generating unit is configured to generate a project structure according to the dependency relationship between the dependency node content and the whole file content in the nodes to be processed.

[0040] The compiling processing unit is configured to perform parameter replacement processing and queuing compiling processing on the processed dependency node content according to the project structure and the parameter configuration file, and perform parameter replacement processing and queuing compiling processing on the processed whole file content to obtain a compiled file.

[0041] Optionally, the searching unit comprises:

[0042] The classification subunit is configured to classify dependency file content corresponding to the dependency nodes according to different file suffix types to obtain a classification result if the whole file content has dependency nodes.

[0043] The traversal subunit is configured to search for paths of all dependency nodes of the whole file content according to a corresponding traversal mode according to the classification result, and the traversal mode comprises a statement traversal mode, an attribute traversal mode and a regular expression traversal mode.

[0044] Optionally, the applet code compiling apparatus comprises:

[0045] The output module is configured to obtain a specified address from the packaging configuration file and output the compiled file to the specified address.

[0046] Optionally, the applet code compiling apparatus comprises:

[0047] The association saving module is configured to obtain a project name of the compiled file from the packaging configuration file and save the compiled file, the project name and the specified address in association.

[0048] The application further provides a medium, wherein the medium stores an applet code compiling program, and the applet code compiling program is executed by a processor to implement steps of the applet code compiling method.

[0049] The application is applied to a small program code compiler, and the small program code compiler is provided with a main package configuration file, a sub-package configuration file and a processing queue. When a small program code compiling instruction is received, all file contents corresponding to the main package configuration file and the sub-package configuration file are obtained, wherein the sub-package configuration file is provided with branch codes required by different sub-type small programs in the small program, and the main package configuration file is provided with common codes required by different sub-type small programs in the small program. A to-be-processed node is obtained based on the all file contents. The to-be-processed node is placed in the processing queue for queuing and compiling processing to obtain a compiling file. In the application, the main package configuration file, the sub-package configuration file and the processing queue are provided, so that when the small program code is compiled, no matter how many customized sub-type programs or sub-type branch codes exist based on the small program, the all file contents corresponding to the main package configuration file and the sub-package configuration file can be obtained by changing the sub-package configuration file, so that the file contents corresponding to the main package configuration file, that is, the common codes, are reused after the sub-package configuration file is changed each time, thereby improving the code reusability. In addition, the sub-package configuration file is provided, so that in the application, the entire small program can be modified and maintained by modifying and maintaining the sub-package configuration file during the small program code compiling process, that is, the maintainability and the code reusability during the small program code compiling process are improved. BRIEF DESCRIPTION OF DRAWINGS

[0050] Figure 1 FIG. 1 is a flowchart of a first embodiment of the small program code compiling method of the application;

[0051] Figure 2 FIG. 2 is a detailed flowchart of the step of obtaining a to-be-processed node based on the all file contents in the second embodiment of the small program code compiling method of the application;

[0052] Figure 3 FIG. 3 is a device structure diagram of a hardware running environment involved in the embodiment method of the application.

[0053] The implementation, functional features and advantages of the application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION

[0054] It should be understood that the specific embodiments described herein are merely intended to explain the application, and are not intended to limit the application.

[0055] The application provides a small program code compiling method. In a first embodiment of the small program code compiling method, the main package configuration file and the sub-package configuration file are obtained based on the small program code compiling instruction. Figure 1The application relates to a small program code compiling method applied to a small program code compiler, wherein a main package configuration file, a subpackage configuration file and a processing queue are arranged in the small program code compiler, and the small program code compiling method comprises the following steps:

[0056] In step S10, when a small program code compiling instruction is received, the main package configuration file and the subpackage configuration file are acquired, and all file contents corresponding to the main package configuration file and the subpackage configuration file are obtained, wherein branch codes required by different subtypes of small programs in the small program are arranged in the subpackage configuration file, and common codes required by different subtypes of small programs in the small program are arranged in the main package configuration file;

[0057] In step S20, a to-be-processed node is obtained based on the all file contents.

[0058] In step S30, the to-be-processed node is arranged in the processing queue for queuing and compiling processing, so as to obtain a compiling file.

[0059] The specific steps are as follows:

[0060] In step S10, when a small program code compiling instruction is received, the main package configuration file and the subpackage configuration file are acquired, and all file contents corresponding to the main package configuration file and the subpackage configuration file are obtained, wherein branch codes required by different subtypes of small programs in the small program are arranged in the subpackage configuration file, and common codes required by different subtypes of small programs in the small program are arranged in the main package configuration file;

[0061] The applet code compiling method in the embodiment is applied to an applet code compiler, and in particular, is applied to a three-party developed applet code compiler. The three-party developed applet (involving the development of an applet by multiple partners) and a common applet are essentially the same, but the three-party developed applet faces high complexity. Specifically, the three-party developed applet often needs to provide service support for multiple partners. Since the three-party developed applet often needs to provide service support for multiple partners, the three-party developed applet needs to implement the functions of limited modification of an interface UI and customization of a specified partner page, that is, the three-party developed applet needs to implement the function of a set of logic code (main branch code) being capable of being abstractly reused in other code (other branch code) to meet the different needs of multiple partners. In the prior art, the function is implemented by using a git (an open source and free distributed version management system) branch code management manner, that is, when a partner needs to modify an applet interface UI or customize an applet characteristic page, a new partner code branch (git branch) is usually added to the existing main branch code to implement the functions of limited modification and customization. The master branch (main branch code) is the most general version of code of the three-party developed applet, that is, the partner main branch code is placed in the master branch. Once there is a customization demand, a new partner branch is pulled from the release branch (other branch code) for development. Since the newly added code branch is customized, that is, not general, the applet code after customization (the code modified, added, and upgraded on the main branch code) is different from the sub-type applet, and the sub-type applet can only be compiled separately in the compiling process. When there are more and more partners, the applet code compiling process has the technical problems of poor maintainability and poor code reusability.

[0062] To address the aforementioned technical issues, a main configuration file and sub-package configuration files are set in the mini-program code compiler, especially in third-party mini-program code compilers. It's important to note that a key characteristic of mini-programs is that all page information must be specified in the configuration file (app.json). In this embodiment, the mini-program code compiler sets up a main package configuration file and sub-package configuration files. Therefore, the wxa2.x framework (a mini-program framework that can compile mini-program code into executable code) in the mini-program code compiler can obtain all the page content within the customized mini-program by reading the main package configuration file and the sub-package configuration files. Specifically, upon receiving the mini-program code compilation instruction, it retrieves all file contents corresponding to the main package configuration file and the sub-package configuration files. The sub-package configuration files contain the branch code required by different subtypes of the mini-program, while the main package configuration file contains the common code required by different subtypes of the mini-program. In this embodiment, because the main package configuration file and the sub-package configuration files are set separately rather than in a mixed manner, the code files corresponding to the main package configuration file can be reused, while the code files corresponding to the sub-package configuration files can be customized to meet the needs of various partners. In this embodiment, the sub-package configuration files are set separately rather than in a mixed manner, and the main package configuration file includes the main branch code. Therefore, when the main branch code is changed, all mini-programs need to be modified accordingly. The sub-package configuration files include other branch code. Therefore, when other branch code is changed, the customized mini-programs or customized third-party mini-programs need to be modified accordingly. Specifically, the sub-package configuration file specifies or allows each third-party mini-program to specify corresponding project parameters, packaging configurations, and entry pages, etc. That is, the sub-package configuration file includes the following content: project name (the unique identifier of the third-party mini-program, used to distinguish it from other mini-programs), entry node point (the node specified during the compilation stage will be replaced with the content of the specified file), etc.

[0063] Step S20: Obtain the node to be processed based on the content of all the files;

[0064] After obtaining all file content, nodes to be processed are obtained based on the entire file content. For example, each page is a node to be processed. Therefore, the node composition of the node to be processed can be obtained based on the subordinate relationship of each page content in the entire file content. For example, if a main page has subordinate pages, then the node of the main page is the parent node, and the node of the subordinate page is the child node. The node composition of the node to be processed is obtained based on each parent node and child node. It should be noted that in this embodiment, the node to be processed may include other file content in addition to the entire file content.

[0065] Reference Figure 2The parameter configuration file is set in the applet code compiler, and the step of obtaining the to-be-processed node based on the entire file content includes:

[0066] In step S21, it is determined whether the entire file content has a dependent node according to a file suffix in the entire file content.

[0067] In this embodiment, the parameter configuration file can be from the subpackage configuration file, or the parameter configuration file can exist independently of the subpackage configuration file and the main package configuration file. It is determined whether the entire file content has a dependent node according to a file suffix in the entire file content, for example, whether the entire file content has a file suffix of js, wxml, css, wxss, or json. If the entire file content has a file suffix of js, wxml, css, wxss, or json, it is determined that the entire file content has a dependent node.

[0068] In step S22, if the entire file content does not have a dependent node, a target parameter is obtained from the parameter configuration file, and a corresponding parameter in the entire file content is replaced with the target parameter.

[0069] If the entire file content does not have a dependent node, a target parameter can be obtained from the parameter configuration file, and a corresponding parameter in the entire file content is replaced with the target parameter. For example, if the entire file content does not have a dependent node, a target parameter such as an applet id, an applet name, and the like is obtained from the parameter configuration file, and a corresponding parameter in the entire file content is replaced with the applet id, the applet name, and the like. That is, in this embodiment, most of the pages and logic in the three-party developed applet can be reused, and a small part of the difference can be adjusted according to different parameters.

[0070] In step S23, the entire file content after the corresponding parameter is replaced is taken as a to-be-processed node.

[0071] After the corresponding parameter is replaced, the entire file content after the corresponding parameter is replaced is taken as a to-be-processed node for the next step.

[0072] The step after determining whether the entire file content has a dependent node according to a file suffix in the entire file content includes:

[0073] In step S24, if the entire file content has a dependent node, a path of all dependent nodes of the entire file content is found according to the file suffix.

[0074] If the dependency node exists in the whole file content, the path of the dependency node of the whole file content is found according to the file suffix, specifically, the file suffix determines the search mode of the dependency node, such as the specific statement mode (determined by specific statement traversal), the regular expression search mode, and the like, and then the path of the dependency node of the whole file content is found according to the search mode.

[0075] In step S25, the dependency node content of the dependency node is read according to the path of the dependency node.

[0076] After the path of the dependency node is obtained, the dependency node content of the dependency node is read according to the path of the dependency node, for example, if the path of the dependency node is A\q directory\cji file, the dependency node content of A\q directory\cji file is obtained.

[0077] In step S26, the dependency node content and the whole file content are taken as the to-be-processed nodes.

[0078] After the dependency node content is obtained, the dependency node content and the whole file content are taken as the to-be-processed nodes.

[0079] In step S30, the to-be-processed nodes are placed in the processing queue for queuing compilation processing to obtain a compiled file.

[0080] It should be noted that in the embodiment, the processing queue is provided, the processing queue is used to enqueue the to-be-processed nodes, and the enqueued to-be-processed nodes are processed in a queuing manner, specifically, the processing queue is used to process the pages corresponding to the whole file content in a queuing manner, that is, each to-be-processed node can be a page content, and the to-be-processed node can be set as an entry node after being processed in the queue, and all the entry nodes are processed recursively to obtain a compiled file. It should be noted that in the queuing compilation processing of the to-be-processed nodes, if the dependency node content is found, the dependency node content is queued after the whole file content in the queuing queue, for example, the to-be-processed nodes corresponding to the whole file content are x, y, and z, x, y, and z are queued in the processing queue in turn, and if the dependency node s exists in the whole file content, the nodes queued in the processing queue are x, y, z, and s.

[0081] The application is applied to a small program code compiler, and the small program code compiler is provided with a main package configuration file, a sub-package configuration file and a processing queue. When receiving a small program code compiling instruction, the application acquires all file contents corresponding to the main package configuration file and the sub-package configuration file. The sub-package configuration file is provided with branch codes required by different sub-type small programs in the small program, and the main package configuration file is provided with common codes required by different sub-type small programs in the small program. A to-be-processed node is obtained based on the all file contents. The to-be-processed node is placed in the processing queue for queuing compiling processing to obtain a compiling file. In the application, the main package configuration file, the sub-package configuration file and the processing queue are provided, so that when the small program code is compiled, no matter how many customized sub-type programs or sub-type branch codes exist based on the small program, the sub-package configuration file is only changed to correspondingly acquire all file contents corresponding to the main package configuration file and the sub-package configuration file. Therefore, after the sub-package configuration file is changed each time, the file contents corresponding to the main package configuration file, that is, the common codes, are reused, so that the code reusability is improved. In addition, because of the existence of the sub-package configuration file, in the application, the small program is only modified and maintained by modifying and maintaining the sub-package configuration file in the small program code compiling process, that is, the application improves the maintainability and the code reusability in the small program code compiling process.

[0082] Further, the application provides another embodiment of a small program code compiling method, and in the embodiment, the step of placing the to-be-processed node in the processing queue for queuing compiling processing to obtain a compiling file comprises:

[0083] In step S31, a project structure is generated according to the dependency of the dependent node content in the to-be-processed node and the all file contents.

[0084] In the embodiment, the project structure is generated according to the dependency of the dependency node content in the to-be-processed node and the whole file content. The project structure refers to the dependency of the content files. For example, the page content of a1, a2 and a3 pages is included in the whole file content, and the page content of the a1, a2 and a3 pages belongs to the a page. In addition, the dependency node content a4 also belongs to the a page. The dependency between a1, a2, a3 and a4 needs to be determined or generated. Then, the project structure is determined according to the dependency between a1, a2, a3 and a4 and a1, a2 and a3. Specifically, the project structure is generated according to the dependency of the dependency node content in the to-be-processed node and the whole file content corresponding to all pages of the whole file content. The dependency of the page includes the parent-child dependency and the sibling dependency. Specifically, if two pages both belong to another page, the two pages are in the sibling dependency. If one page is derived from the link of another page, the two pages are in the parent-child dependency.

[0085] In step S32, the parameter replacement processing and the queuing compilation processing are performed on the processed dependency node content of the project structure according to the parameter configuration file, and the parameter replacement processing is performed on the whole file content of the project structure to obtain a compiled file.

[0086] In the embodiment, after the project structure is obtained, the small program id, the small program name and the like of the cooperation party can be changed. Therefore, the parameter replacement processing (for example, the change of the small program name) and the queuing compilation processing are performed on the processed dependency node content of the project structure and the whole file content according to the parameter configuration file to obtain a compiled file. The specific compilation process belongs to the prior art, and is not described here.

[0087] The small program code compiler is provided with a packaging configuration file. After the step of placing the to-be-processed node in the processing queue to perform the queuing compilation processing to obtain a compiled file, the following steps are included.

[0088] In step S40, a specified address is obtained from the packaging configuration file, and the compiled file is output to the specified address.

[0089] In the embodiment, the specified address is also obtained from the packaging configuration file. For example, the specified address can be a cji file address. The compiled file is output to the specified address for subsequent query or output.

[0090] After the step of obtaining the specified address from the packaging configuration file and outputting the compiled file to the specified address, the following steps are included.

[0091] Step S50, obtaining the project name of the compiling file from the packaging configuration file, and saving the compiling file, the project name and the specified address in association.

[0092] In this embodiment, the project name of the compiling file is obtained from the packaging configuration file, and the compiling file, the project name and the specified address are saved in association for subsequent output or query.

[0093] In this embodiment, the project structure is generated according to the dependency of the dependency node content in the to-be-processed node and the whole file content; the parameter replacement processing and the queuing compilation processing are performed on the processed dependency node content of the project structure according to the parameter configuration file, and the parameter replacement processing is performed on the processed whole file content of the project structure, so as to obtain the compiling file. In this embodiment, the project structure is also generated in the compilation process, so that the ordered compiling file is generated.

[0094] Further, another embodiment of the small program code compilation method provided by the application is provided. When the whole file content has a dependency node, the step of finding the path of all dependency nodes of the whole file content according to the file suffix includes:

[0095] Step A1, when the whole file content has a dependency node, the dependency file content corresponding to the dependency node is classified according to different file suffix types, and a classification result is obtained.

[0096] In this embodiment, when the whole file content has a dependency node, the dependency file content corresponding to the dependency node is classified according to different file suffix types, and a classification result is obtained. Specifically, for example, the different file suffix types can be js, wxml, css and json, and the classification result of the dependency file content corresponding to the dependency node can be js, wxml file, css file and json file.

[0097] Step A2, according to the classification result, the path of all dependency nodes of the whole file content is found by adopting a corresponding traversal mode, and the traversal mode includes a statement traversal mode, an attribute traversal mode and a regular expression traversal mode.

[0098] According to the classification result, a corresponding traversal mode is adopted to find the path of the dependent nodes of the entire file content, and the traversal mode includes a statement traversal mode, an attribute traversal mode and a regular expression traversal mode. For example, if the dependent file content is a js file (file suffix js), because the Javascript language has only two dependent introduction modes of require and import statements, after the code is converted into an AST (abstract code syntax tree) by using a preset babel compilation tool, all require and import statements are traversed to obtain the path of the dependent nodes. If the dependent file content is a wxml file (file suffix wxml), because the wxml file corresponds to only two attribute introduction modes of src and href attributes, the xmldom tool is used to read the file content of the wxml file type, and the file content of the wxml file type is converted into a DOM (Document Object Model) type, and then all src and href attributes in the DOM element are traversed to obtain the path of the dependent nodes. If the dependent file content is a css file (file suffix css or wxss), the css file can only be introduced into other resources by using a preset regular mode, and therefore, the import and src statements are matched by using a regular matching mode to obtain the path of the dependent nodes. If the dependent file content is a json file (file suffix.json), it is found whether there is a usingComponents (custom component) configuration, and the applet can only introduce other component files (a component file is composed of the js, wxml, css and json files) by using the configuration.

[0099] In the embodiment, if the entire file content has dependent nodes, the dependent nodes are classified according to different file suffix types to obtain a classification result, and according to the classification result, a corresponding traversal mode is adopted to find the path of the dependent nodes of the entire file content, and the traversal mode includes a statement traversal mode, an attribute traversal mode and a regular expression traversal mode. The embodiment can accurately obtain the path of the dependent nodes of the entire file content, and because the path of the dependent nodes of the entire file content is accurately obtained, the applet of different subtypes can be accurately compiled, and the maintainability and code reusability in the applet code compilation are improved.

[0100] Reference Figure 3 , Figure 3 is a device structure schematic diagram of a hardware running environment involved in the embodiment of the application.

[0101] The applet code compiling device can be a PC, a smart phone, a tablet computer, a portable computer, or other terminal device.

[0102] As shown in Figure 3 the applet code compiling device can include a processor 1001, such as a CPU, a memory 1005, and a communication bus 1002. The communication bus 1002 is used to realize the connection and communication between the processor 1001 and the memory 1005. The memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 can also be a storage device independent of the aforementioned processor 1001.

[0103] Optionally, the applet code compiling device can also include a target user interface, a network interface, a camera, an RF (Radio Frequency, radio frequency) circuit, a sensor, an audio circuit, a WiFi module, and the like. The target user interface can include a display screen (Display) and an input unit such as a keyboard (Keyboard). The optional target user interface can also include a standard wired interface and a wireless interface. The network interface can optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).

[0104] Those skilled in the art can understand that Figure 3 the structure of the applet code compiling device shown in the above embodiments does not constitute a limitation on the applet code compiling device, and can include more or fewer components than those shown, or combine certain components, or different component arrangements.

[0105] As shown in Figure 3 the memory 1005 as a computer storage medium can include an operating system, a network communication module, and an applet code compiling program. The operating system is a program that manages and controls the hardware and software resources of the applet code compiling device, supports the running of the applet code compiling program and other software and / or programs. The network communication module is used to realize the communication between the components in the memory 1005, and the communication between other hardware and software in the applet code compiling device.

[0106] In the applet code compiling device shown in Figure 3 the processor 1001 is used to execute the applet code compiling program stored in the memory 1005, and realize the steps of the applet code compiling method described in any of the above embodiments.

[0107] The specific implementation of the applet code compiling device of the present application is basically the same as that of the above-mentioned applet code compiling method, and will not be repeated here.

[0108] Furthermore, the application also provides a small program code compiling device, which is applied to a small program code compiler, wherein a main package configuration file, a subpackage configuration file and a processing queue are arranged in the small program code compiler, and the small program code compiling device comprises:

[0109] a first obtaining module, which is used for obtaining all file contents corresponding to the main package configuration file and the subpackage configuration file when a small program code compiling instruction is received, wherein branch codes required by different sub-type small programs in the small program are arranged in the subpackage configuration file, and common codes required by different sub-type small programs in the small program are arranged in the main package configuration file;

[0110] a second obtaining module, which is used for obtaining a to-be-processed node based on the all file contents;

[0111] a compiling module, which is used for placing the to-be-processed node in the processing queue to perform queuing compiling processing, so as to obtain a compiling file.

[0112] Optionally, a parameter configuration file is arranged in the small program code compiler, and the second obtaining module comprises:

[0113] a determining unit, which is used for determining whether there is a dependent node in the all file contents according to a file suffix in the all file contents;

[0114] an obtaining unit, which is used for obtaining a target parameter from the parameter configuration file and replacing a corresponding parameter in the all file contents with the target parameter if there is no dependent node in the all file contents;

[0115] a first setting unit, which is used for taking the all file contents after the corresponding parameter is replaced as the to-be-processed node.

[0116] Optionally, the second obtaining module further comprises:

[0117] a searching unit, which is used for searching paths of all dependent nodes of the all file contents according to the file suffix if there is a dependent node in the all file contents;

[0118] a reading unit, which is used for reading dependent node contents of the all dependent nodes according to the paths of the all dependent nodes;

[0119] a second setting unit, which is used for taking the dependent node contents and the all file contents as the to-be-processed node.

[0120] Optionally, the compiling module comprises:

[0121] A generation unit is used to generate a project structure based on the dependency relationship between the content of the dependent nodes in the node to be processed and the content of all files.

[0122] The compilation processing unit is used to perform parameter replacement processing and queue compilation processing on the dependent node content after the project structure generation processing according to the parameter configuration file, and to perform parameter replacement processing and queue compilation processing on all file content after the project structure generation processing to obtain a compiled file.

[0123] Optionally, the search unit includes:

[0124] The classification subunit is used to classify the dependent file content corresponding to the dependent node according to different file suffix types when all the file content has dependent nodes, and obtain the classification result.

[0125] The traversal subunit is used to find the paths of all dependent nodes of all file content according to the classification results and the corresponding traversal method. The traversal method includes statement traversal method, attribute traversal method and regular expression traversal method.

[0126] Optionally, the mini-program code compilation device includes:

[0127] The output module is used to obtain a specified address from the packaging configuration file and output the compiled file to the specified address.

[0128] Optionally, the mini-program code compilation device includes:

[0129] The associated storage module is used to obtain the project name of the compiled file from the packaging configuration file, and associate and save the compiled file, the project name, and the specified address.

[0130] The specific implementation of the mini-program code compilation device is basically the same as the embodiments of the mini-program code compilation method described above, and will not be repeated here.

[0131] Furthermore, this embodiment of the invention also proposes a mini-program code compilation device, which includes: a memory 109, a processor 110, and a mini-program code compiler stored on the memory 109 and capable of running on the processor 110. When the mini-program code compiler is executed by the processor 110, it implements the steps of the mini-program code compilation method embodiments described above.

[0132] In addition, the present invention provides a computer medium storing one or more programs, which can be executed by one or more processors to implement the steps of the above-described embodiments of the applet code compilation method.

[0133] The expansion of the specific embodiments of the device and medium (i.e. computer medium) of the present application is basically the same as the above-mentioned each embodiment of the applet code compiling method, and will not be described here.

[0134] It should be noted that in this paper, the term "including", "containing" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or includes elements inherent to such process, method, article or device. Without more limitations, the element defined by the sentence "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0135] The above-mentioned embodiment number of the present application is only for description, not representing the pros and cons of the embodiment.

[0136] Through the above description of the embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment method can be realized by software and necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of software product, which is stored in a storage medium (such as ROM / RAM, magnetic disc, optical disc), including a plurality of instructions for making a terminal (which can be a mobile phone, computer, server, air conditioner, or network equipment, etc.) execute the method described in each embodiment of the present application.

[0137] The embodiments of the present application are described above in combination with the drawings, but the present application is not limited to the above-mentioned specific embodiments, the above-mentioned specific embodiments are only illustrative, not restrictive, and those skilled in the art can make many forms under the inspiration of the present application without departing from the purpose of the present application and the scope protected by the claims, which all belong to the protection of the present application.

Claims

1. A method for compiling WeChat Mini Program code, characterized in that, The mini-program code compilation method is applied to a mini-program code compiler, which sets up a main package configuration file, sub-package configuration files, parameter configuration files, and a processing queue. The mini-program code compilation method includes: When a mini-program code compilation instruction is received, the contents of all files corresponding to the main package configuration file and the sub-package configuration file are obtained. The sub-package configuration file contains the branch code required by different sub-type mini-programs in the mini-program, and the main package configuration file contains the common code required by different sub-type mini-programs in the mini-program. Determine whether there are dependent nodes in the content of all files based on the file extensions in the content of all files; If the contents of all files do not have any dependent nodes, obtain the target parameter from the parameter configuration file and replace the corresponding parameter in the contents of all files with the target parameter; then use the contents of all files after replacing the corresponding parameter as nodes to be processed. If all file contents have dependent nodes, find the paths of all dependent nodes of all file contents based on the file suffix; read the content of the dependent nodes of all dependent nodes based on the paths of all dependent nodes; and treat the content of the dependent nodes and the all file contents as nodes to be processed. The node to be processed is placed in the processing queue for queuing and compilation processing to obtain a compiled file.

2. The method for compiling mini-program code as described in claim 1, characterized in that, The step of placing the node to be processed in the processing queue for queued compilation processing to obtain a compiled file includes: The project structure is generated based on the dependency relationship between the content of the dependent nodes in the node to be processed and the content of all files. Based on the parameter configuration file, parameter replacement and queuing compilation are performed on the dependent node content after the project structure generation process, and parameter replacement and queuing compilation are performed on all file content after the project structure generation process to obtain the compiled file.

3. The method for compiling mini-program code as described in claim 2, characterized in that, The step of finding the paths of all dependent nodes of all file content based on the file extension when all file content has dependent nodes includes: If all the file contents have dependent nodes, the dependent file contents corresponding to the dependent nodes are classified according to different file suffix types to obtain the classification results; Based on the classification results, the paths of all dependent nodes of all file content are found using the corresponding traversal methods. The traversal methods include statement traversal, attribute traversal, and regular expression traversal.

4. The method for compiling mini-program code as described in any one of claims 1-3, characterized in that, The mini-program code compiler sets a packaging configuration file, and after the step of placing the node to be processed in the processing queue for queuing and compilation to obtain the compiled file, the following steps are included: Obtain the specified address from the packaging configuration file and output the compiled file to the specified address.

5. The method for compiling mini-program code as described in claim 4, characterized in that, The step of obtaining the specified address from the packaging configuration file and outputting the compiled file to the specified address includes: Obtain the project name of the compiled file from the packaging configuration file, and save the compiled file, the project name, and the specified address together.

6. A mini-program code compilation device, characterized in that, The mini-program code compilation device is applied to a mini-program code compiler, which includes a main package configuration file, sub-package configuration files, parameter configuration files, and a processing queue. The mini-program code compilation device comprises: The first acquisition module is used to acquire all file contents corresponding to the main package configuration file and the sub-package configuration file when receiving the mini-program code compilation instruction. The sub-package configuration file sets the branch code required by different sub-type mini-programs in the mini-program, and the main package configuration file sets the general code required by different sub-type mini-programs in the mini-program. The second acquisition module is used to obtain the node to be processed based on the content of all files; specifically, it is used to determine whether there are dependent nodes in the content of all files based on the file suffix; if there are no dependent nodes in the content of all files, it obtains the target parameter from the parameter configuration file and replaces the corresponding parameter in the content of all files with the target parameter; it uses the content of all files after replacing the corresponding parameter as the node to be processed; if there are dependent nodes in the content of all files, it finds the path of all dependent nodes in the content of all files based on the file suffix; it reads the content of the dependent nodes of all dependent nodes based on the path of all dependent nodes; it uses the content of the dependent nodes and the content of all files as the node to be processed. The compilation module is used to place the node to be processed in the processing queue for queued compilation processing to obtain a compiled file.

7. A mini-program code compilation device, characterized in that, The device includes: a memory, a processor, and a small program code compiler stored in the memory and executable on the processor. When the small program code compiler is executed by the processor, it implements the steps of the small program code compilation method as described in any one of claims 1 to 5.

8. A medium, characterized in that, The medium stores a mini-program code compiler, which, when executed by a processor, implements the steps of the mini-program code compilation method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and apparatus for test in joint development mode

    CN105302716A

  • Code data management method and system

    CN110134431A