Rapid full-amount construction method and device and storage medium

By generating and using configuration information, the initial sub-application code is filtered using the virtual application scaffolding tool, and the rapid and full construction is achieved, solving the problems of long construction time and large package size in traditional methods, improving efficiency and realizing resource sharing.

CN119917100AActive Publication Date: 2025-05-02GUANGZHOU XUANWU WIRELESS TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411746076.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-05-02
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

Traditional full-scale construction methods lead to long construction time, low efficiency, and large deployment package size. Especially in multi-sub-application systems, it is difficult to achieve resource sharing and code reuse.

Method used

By obtaining public library information and sub-application information, generating corresponding configuration information, using virtual application scaffolding tools to filter the initial sub-application code, obtaining the target sub-application code, and quickly and fully constructing it to realize the co-construction of the main application and multiple sub-applications.

Benefits of technology

Improves construction efficiency, reduces the deployment package size, realizes resource sharing and code reuse between multiple sub-applications, and is suitable for deployment in any environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917100A_ABST
    Figure CN119917100A_ABST
Patent Text Reader

Abstract

The invention discloses a rapid full-amount construction method and device and a storage medium. The method comprises the steps that public library information and sub-application information are acquired; generating public library configuration information according to the public library information; generating micro-application configuration information according to the sub-application information; analyzing a source resource path in the sub-application source code file to obtain a complete path of a resource file; according to the micro-application configuration information and the complete path of the resource file, filtering the initial sub-application code by using a virtual application scaffold tool to obtain a target sub-application code; generating main application configuration information according to the micro-application configuration information; and according to the public library configuration information, the target sub-application code and the main application configuration information, carrying out rapid full-quantity construction to obtain a main application and a plurality of sub-applications. According to the method, rapid full-amount construction is realized, the efficiency is improved, and the volume of a deployment package is reduced. The method can be widely applied to the technical field of front-end construction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of front-end construction technology, and in particular to a fast full-volume construction method, device and storage medium. Background Art

[0002] In many enterprise applications, plug-in is a common software architecture pattern, in which the front-end can achieve the plug-in effect through the micro-front-end concept. Under the micro-front-end technical architecture system, a large application is split into multiple sub-applications. Although each sub-application can be packaged and deployed independently, if the project is delivered to non-front-end developers for maintenance, it is difficult to distinguish which sub-application to package, or if the common code is modified, all sub-applications still need to be packaged. The traditional full-volume build method packages each sub-application in sequence, resulting in a long total build time, low efficiency, and a large deployment package size.

[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention

[0004] The embodiments of the present invention provide a method, device and storage medium for rapid full-scale construction, which effectively improves efficiency and reduces the size of deployment packages.

[0005] On the one hand, an embodiment of the present invention provides a method for fast full-scale construction, comprising the following steps:

[0006] Obtaining public library information and sub-application information, wherein the public library information includes a public library alias and a public library path, and the sub-application information includes a sub-application name, an entry file name, a startup port number, an open resource name, and an open resource path;

[0007] Generate public library configuration information according to the public library information;

[0008] Generate micro-application configuration information according to the sub-application information;

[0009] Parse the resource path in the sub-application source code file to obtain the complete path of the resource file, wherein the resource path includes an alias path or a relative path;

[0010] According to the micro-application configuration information and the complete path of the resource file, the initial sub-application code is filtered using a virtual application scaffolding tool to obtain a target sub-application code, wherein the initial sub-application code includes a business code and a public resource code, and the target sub-application code includes the business code;

[0011] Generate main application configuration information according to the micro application configuration information;

[0012] According to the common library configuration information, the target sub-application code and the main application configuration information, a rapid full build is performed to obtain a main application and multiple sub-applications.

[0013] In some embodiments, generating public library configuration information according to the public library information includes:

[0014] Combining the public library alias and the public library path to obtain a public library alias path combination;

[0015] Add a plurality of the public library alias path combinations to the first preset configuration file to obtain the public library configuration information.

[0016] In some embodiments, generating micro-application configuration information according to the sub-application information includes:

[0017] Combining the open resource name and the open resource path to obtain an open resource key-value pair;

[0018] The sub-application name, the entry file name, the startup port number and multiple open resource key-value pairs are added to the second preset configuration file to obtain the micro-application configuration information.

[0019] In some embodiments, when the source resource path is a path containing an alias, parsing the source resource path in the sub-application source code file to obtain the complete path of the resource file includes:

[0020] According to the preset placeholder root path and the sub-application name, the alias in the alias-containing path is replaced to obtain the complete path of the resource file.

[0021] In some embodiments, when the source resource path is a relative path, parsing the source resource path in the sub-application source code file to obtain the complete path of the resource file includes:

[0022] The complete path of the resource file is generated according to the complete path of the source file and the relative path.

[0023] In some embodiments, the filtering of the initial sub-application code using a virtual application scaffolding tool according to the micro-application configuration information and the complete path of the resource file to obtain the target sub-application code includes:

[0024] Use preset plugin settings to run shared configuration information;

[0025] Creating a plurality of sub-application federated objects according to the micro-application configuration information and the running shared configuration information;

[0026] Adding the plurality of sub-application federated objects to a sub-application plug-in queue;

[0027] Initialize the bucket object;

[0028] Traversing the file collection in the sub-application plug-in queue to add a first resource in the file collection that complies with a preset naming rule to the bucket object, and adding a reference resource of the first resource to the bucket object;

[0029] The initial sub-application code is filtered according to the bucket object and the complete path of the resource file to obtain the target sub-application code.

[0030] In some embodiments, generating main application configuration information according to the micro-application configuration information includes:

[0031] Determine the sub-application entry file loading path according to the micro-application configuration information;

[0032] Create the main application federation object;

[0033] Adding the main application federated object to the main application plug-in queue to configure the shared field and obtain shared field configuration information;

[0034] The main application configuration information is generated according to the sub-application entry file loading path, the sub-application name and the shared field configuration information.

[0035] On the other hand, an embodiment of the present invention provides a fast full-volume construction device, including:

[0036] The first module is used to obtain public library information and sub-application information, wherein the public library information includes a public library alias and a public library path, and the sub-application information includes a sub-application name, an entry file name, a startup port number, an open resource name, and an open resource path;

[0037] The second module is used to generate public library configuration information according to the public library information;

[0038] The third module is used to generate micro-application configuration information according to the sub-application information;

[0039] The fourth module is used to parse the source resource path in the sub-application source code file to obtain the complete path of the resource file, wherein the source resource path includes an alias path or a relative path;

[0040] The fifth module is used to filter the initial sub-application code using a virtual application scaffolding tool according to the micro-application configuration information and the complete path of the resource file to obtain a target sub-application code, wherein the initial sub-application code includes a business code and a public resource code, and the target sub-application code includes the business code;

[0041] The sixth module is used to generate main application configuration information according to the micro application configuration information;

[0042] The seventh module is used to perform a rapid full build based on the common library configuration information, the target sub-application code and the main application configuration information to obtain the main application and multiple sub-applications.

[0043] In another aspect, an embodiment of the present invention provides a computer device, comprising:

[0044] at least one processor;

[0045] at least one memory for storing at least one program;

[0046] When the at least one program is executed by the at least one processor, the at least one processor implements the described method.

[0047] On the other hand, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.

[0048] The beneficial effects of the present invention are as follows:

[0049] The embodiment of the present invention first obtains common library information and sub-application information, then generates common library configuration information based on the common library information, and generates micro-application configuration information based on the sub-application information, and then parses the source resource path in the sub-application source code file to obtain the complete path of the resource file, and uses a virtual application scaffolding tool to filter the initial sub-application code based on the micro-application configuration information and the complete path of the resource file to obtain the target sub-application code, and finally generates the main application configuration information based on the micro-application configuration information, and performs a fast full build based on the common library configuration information, the target sub-application code and the main application configuration information to obtain the main application and multiple sub-applications, so that shared resources can be shared through a variety of configuration information to achieve a fast full build, thereby improving efficiency and reducing the size of the deployment package.

[0050] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0052] Figure 1 A flowchart of a method for quickly building a full volume according to an embodiment of the present invention;

[0053] Figure 2 A schematic diagram of a path resolution process according to an embodiment of the present invention;

[0054] Figure 3 A schematic diagram of an implementation process of a hook function according to an embodiment of the present invention;

[0055] Figure 4 A schematic diagram of a traditional packaging construction process according to an embodiment of the present invention;

[0056] Figure 5 A schematic diagram of a packaging and building process using a virtual application according to an embodiment of the present invention;

[0057] Figure 6 A schematic diagram of a project structure according to an embodiment of the present invention;

[0058] Figure 7 This is a schematic diagram of the structure of a fast full-volume construction device according to an embodiment of the present invention;

[0059] Figure 8 The figure is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.

[0061] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".

[0062] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.

[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0064] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.

[0065] Full build: refers to starting the build process completely from scratch without considering previous build results.

[0066] Scaffolding: refers to development tools and development frameworks that can help developers in the development process. Using scaffolding eliminates the need to build or write underlying software from scratch.

[0067] In the related technology, in many enterprise applications, plug-in is a common software architecture mode, in which the front-end can achieve the plug-in effect through the micro-front-end concept. At present, there are many technical solutions to realize micro-front-end, such as the common "module federation" technical solution to achieve the effect of micro-front-end. Under the technical architecture system of micro-front-end, a large application is split into multiple micro-applications. Although each micro-application can be packaged and deployed independently, it can be done that only the micro-application whose code is changed is packaged. However, if the public code is modified, each micro-application still needs to be packaged. Secondly, if the project is delivered to a non-front-end developer for maintenance, he only changes individual pictures and texts. If he does not know the project architecture, it is difficult to distinguish which micro-application to package. In other words, for a plug-in system, a full build can ensure that the deployment package is correct and up-to-date after each package build, and it does not require the maintenance personnel to understand the project architecture. However, a full build will face a serious problem of too long total system construction time, low efficiency, and too large deployment package size.

[0068] In the packaging method of the prior art micro-frontend system, whether to build a full application or to package several sub-applications is determined according to the configuration parameters. If it is a full build, the main application and each sub-application are packaged separately and output to their respective containers. If it is not a full build, the common library configuration information is obtained, and only the corresponding sub-application is packaged, and the compiled deployment file is output to the container corresponding to the sub-application. In addition, an application configuration file is described that describes the packaging configuration information of each application. The problem that this embodiment can solve is to reduce the total construction time and total package size of the system for the scenario of full build. If it is a system including dozens of sub-applications, then this is a serious problem.

[0069] The prior art also describes how to split a large single application into a micro-application system composed of multiple small applications, how to manage projects containing multiple micro-applications after splitting, and how to configure code sharing between multiple micro-applications to reduce repetitive work. It adopts the micro-frontend technical solution of "Qiankun", splits a large single application into multiple small applications, and uses Monorepo / yarn to manage the code of multiple micro-applications. One of the functions of Monorepo is to facilitate the sharing of common code between multiple applications. "Qiankun" can achieve the effect of micro-frontend. The underlying principle is to distribute through routing, and use "Qiankun" and "Monorepo" two technical tools to make a micro-frontend architecture, splitting a single application into multiple micro-applications. In the concept of sharing, code sharing is divided into three layers. The first layer of code is shared at the physical level. For example, if two projects A and B share a method F, not sharing means writing the code implementation of the same method F in projects A and B. The first layer of physical sharing means that this common method F is implemented in only one place, and both projects A and B can reference this method. The second level of sharing is to realize runtime sharing on the basis of the first level of physical sharing. The non-sharing at runtime means that although the two projects A and B refer to the same code, they will each create an instance object in memory when they start the runtime. The runtime sharing means that the same instance object is referenced by the A and B projects after they are running. The third level of sharing is to realize full sharing of the production environment on the basis of the second level of sharing. The non-sharing of the production environment means that after the A and B projects are packaged, the deployment files generated by the compilation contain the code of the common method F. When the A project is running, the file containing the F code is first loaded and the instance object of the F code is created. When the B project is running, it is found that the F method's actual object already exists and it is used. If not, the code file containing the F method in the B project is loaded and the instance object is created. If it is shared in the production environment, only the deployment file generated by the A project after the A project is packaged and compiled contains the code of the common method F, and the file generated by the B project after the B project is packaged and compiled does not contain the F method code. When the B project is running, it must use the instance object corresponding to the F method created in the A project. Even if the B project is running and there is no such instance object in the program, the F method code file is loaded and the instance object is created through the A project. Traditional code sharing and reuse usually uses the Monorepo tool to achieve the first-level physical sharing of code.The sharing described in this embodiment is to achieve complete sharing of the third-tier production environment. In addition to code reuse and reduced repetitive development, complete sharing of the production environment has two other benefits: ① The file generated by the compilation of project B after packaging does not contain public methods, so the size of the deployment package is naturally reduced; ② When the system starts running, it must use the instance objects of the common methods created by project A, so the memory space occupied is small, which can reduce the rendering time of the page.

[0070] The prior art also describes the problem of resource sharing between various micro-applications under the micro-front-end system, and adopts the following scheme: ① Use CDN / Webpack externals to configure the three packages of vue, vue-router, and vuex to be shared. After the packaged construction, the files generated after the compilation of all micro-applications do not contain the code of these three shared packages, so that the third-layer production environment is fully shared. However, this method has obvious limitations and problems. This method is only suitable for third-party libraries, that is, third-party libraries that the package.json file depends on, and third-party manufacturers provide CDN links. Some manufacturers do not provide CDN resource links, and if the CDN link fails, it will cause the entire system to fail to run. It cannot be applied to projects running on the intranet. CDN is an external network link. The sharing described in this embodiment is to solve the sharing of all public resources between micro-applications, which may include more than a dozen third-party libraries and public libraries implemented internally in the project. There is no CDN restriction, it does not depend on the external network, and it is suitable for deployment in any environment. ② The main application encapsulates a limited number of public components such as AlarmControl and CompareControl for use by sub-applications. It is also necessary to export the webpack configuration of the main application to the sub-applications, and import them in the sub-applications before using them. On the one hand, this way of sharing public components is very troublesome, so there can only be a limited number of public components; and it is not applicable in the micro-front-end system with vite as the scaffold. In the vite scaffold, the main application cannot export public components for sub-applications to use. This embodiment can solve this problem. Dozens of business public components are stored in an independent directory and are not implemented in a specific micro-application. These dozens of business public components can be conveniently referenced and shared by all micro-applications without tedious import and export. The business public components implemented within the project can be configured and shared in the same way as third-party libraries. ③ Public resources include styles, fonts, icons, images, and Theme variables. These resources are shared with sub-applications by placing them under the pulibc of the main application. However, there is a problem with this method. The resources under public will not be optimized by the program after packaging and building, and will be output as is. For example, some resources under public have not been used, and they will still be output as is after packaging and building. However, the files in other directories will be automatically optimized by the program when they are packaged and built, and the resources that are not referenced will be automatically deleted.The sharing scope involved in this embodiment is wider, including not only the limited third-party libraries that provide CDN links in package.json, but also all third-party resources (maybe more than a dozen) and public libraries implemented within several projects. The public libraries implemented within the project may contain dozens of business public components. It is a simpler way to achieve resource sharing between micro-applications, without the need for cumbersome import and export between micro-applications. All resources, whether components, pictures, fonts, or styles, can be packaged and optimized, and are also suitable for intranet environments without CDN. In addition to resource sharing, this embodiment also solves the problem of too long total packaging time and too large total volume for plug-in systems containing many sub-applications.

[0071] A fast full-volume construction method provided in an embodiment of the present application relates to the field of front-end construction technology. A fast full-volume construction method provided in an embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The cloud server, the server can also be a node server in a blockchain network; the software can be an application that implements a fast full-volume construction method, etc., but is not limited to the above forms.

[0072] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0073] The following is a detailed explanation of the embodiments of the present application in conjunction with the accompanying drawings:

[0074] Figure 1 This is an optional flowchart of a fast full-volume construction method provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S107.

[0075] Step S101, obtaining public library information and sub-application information, the public library information includes the public library alias and the public library path, and the sub-application information includes the sub-application name, entry file name, startup port number, open resource name and open resource path;

[0076] Step S102: Generate public library configuration information according to the public library information;

[0077] Step S103: Generate micro-application configuration information according to the sub-application information;

[0078] Step S104, parsing the source resource path in the sub-application source code file to obtain the complete path of the resource file, the source resource path including an alias path or a relative path;

[0079] Step S105: According to the micro-application configuration information and the complete path of the resource file, the initial sub-application code is filtered using a virtual application scaffolding tool to obtain a target sub-application code, wherein the initial sub-application code includes a business code and a public resource code, and the target sub-application code includes a business code;

[0080] Step S106: Generate main application configuration information according to the micro application configuration information;

[0081] Step S107: Perform a quick full build based on the common library configuration information, the target sub-application code and the main application configuration information to obtain the main application and multiple sub-applications.

[0082] Steps S101 to S107 shown in the embodiment of the present application realize rapid full-scale construction, improve efficiency, and reduce the size of the deployment package.

[0083] In step S101 of some embodiments, the public library information can be obtained through the public resource platform, and the sub-application information can be obtained by parsing the sub-application to be packaged. The public library information and the sub-application information can also be obtained by other means, not limited thereto. Among them, the public library information includes the public library alias and the public library path, and the sub-application information includes the sub-application name, the entry file name, the startup port number, the open resource name, and the open resource path.

[0084] In some embodiments, in step S102, generating public library configuration information according to the public library information may include but is not limited to the following steps:

[0085] Combine the public library alias and the public library path to obtain a public library alias path combination;

[0086] Add multiple public library alias path combinations to the first preset configuration file to obtain public library configuration information.

[0087] In some embodiments, all public libraries within the project are configured to be shared (can be referenced by all sub-applications) at the physical code level. The public library alias and the public library path can be combined first to obtain a public library alias path combination, and then multiple public library alias path combinations are added to the first preset configuration file to obtain public library configuration information. By configuring the public library alias and public library path in the tsconfig.json (first preset configuration file) and vite scaffolding of each sub-application. In each sub-application, the methods, components, instructions, etc. provided by the public library can be referenced by aliases. Exemplarily, the program code of the public library alias path combination can be expressed as: {find: "@icc / utils", replacement: resolve (projectsDir, ". / icc-ui / packages / utils")}, where find represents the public library alias and replacement represents the public library path.

[0088] In some embodiments, in step S103, micro-application configuration information is generated according to the sub-application information, which may include but is not limited to the following steps:

[0089] Combine the open resource name and the open resource path to obtain an open resource key-value pair;

[0090] The sub-application name, entry file name, startup port number and multiple open resource key-value pairs are added to the second preset configuration file to obtain micro-application configuration information.

[0091] In some embodiments, the open resource name and the open resource path can be combined to obtain an open resource key-value pair, and then the sub-application name (name field), the entry file name (filename field), the startup port number (port field) and multiple open resource key-value pairs are added to the second preset configuration file to obtain micro-application configuration information. Exemplarily, the program code of the open resource key-value pair can be expressed as: "patchAuditCheck": "src / views / patch-audit / check.vue", and there can be multiple open resource key-value pairs in this form, all of which are stored in the exposes field, indicating that they can be opened to other applications for use, wherein "patchAuditCheck" represents the open resource name, and "src / views / patch-audit / check.vue" represents the open resource path. It can be understood that the information related to all sub-applications is defined in a microinfo.json configuration file (the second preset configuration file), so that the main application can read this file to obtain the relevant data of all sub-applications, and the virtual application can also read this configuration file to batch obtain the code files exported by all sub-applications for a build. More importantly, the sub-application data configuration format can be: In the Federation micro-frontend architecture mode, exposes is used to specify which resources in the current sub-application can be used by the main application. Exposes are defined in the form of key-value pairs, where the key (key) represents the name of the resource and the value (value) corresponds to the path where the resource is located. In the main application, you can find the corresponding path (value) according to the resource name (key) through dynamic import, so as to load and display these resources.

[0092] In some embodiments, in step S104, when the source resource path is a path containing an alias, the source resource path in the sub-application source code file is parsed to obtain the complete path of the resource file, which may include but is not limited to the following steps:

[0093] According to the preset placeholder root path and sub-application name, replace the alias in the alias path to get the full path of the resource file.

[0094] In some embodiments, a vite.config.ts scaffolding configuration file is created in the root directory of the project, and the project includes multiple sub-applications, a main application, and multiple public libraries. During the packaging and building process, the entire project is treated as a virtual application, which includes the business codes of all sub-applications and the codes of public libraries. The vite.config.ts scaffolding configuration file in the root directory of the project is the scaffolding configuration of the virtual application. This embodiment implements code sharing between sub-applications at the physical level through alias configuration. In addition to configuring aliases for all public libraries, you can also give an alias to the code somewhere within a single application, which can simplify the reference path of the code within a single application. For example, the alias of the path where the source code src of a single application is located is configured as the "@" symbol. In the scaffolding configuration file of the virtual application, special processing needs to be done on the aliases within a single application, by setting placeholders for replacement (placeholder replacement) and overriding the implementation of path resolution in the customResolver (custom resolution resource) method. The ${microName} placeholder is used in replacement to represent a sub-application root path, and microName represents the sub-application name. The path resolution process is as follows Figure 2As shown, the customResolver method first determines whether the referenced resource file path updatedId contains the placeholder ${microName}, and uses regular expressions to parse the current sub-application from the source resource file path, and replaces the placeholder with the name of the sub-application, so that the referenced resource path updatedId is completely determined, and finally returns the loaded resource through the resolve method provided by the scaffolding. When the source resource path is an alias path, the alias in the alias path can be replaced according to the preset placeholder root path and the sub-application name to obtain the complete path of the resource file. For example, in the sub-application source code file projects / standard / src / views / passport / login / index.vue, there is an alias path: "@ / router / modules / msgs". When parsing this line of code, the alias @ symbol is encountered. You can use the preset placeholder root path ". / projects / ${microName} / src" to replace the @ symbol to get the referenced resource path ". / projects / ${microName} / src / router / modules / msgs", and then use the sub-application name standard to replace the placeholder ${microName} to get the full path of the resource file ". / projects / standard / src / router / modules / msgs". In addition, you can read the file under the full path of the resource file, parse the file through the resolve method, and then obtain the methods provided by the file.

[0095] In some embodiments, in step S104, when the source resource path is a relative path, the source resource path in the sub-application source code file is parsed to obtain the complete path of the resource file, which may include but is not limited to the following steps:

[0096] Generate a complete resource file path based on the source file's complete path and relative path.

[0097] In some embodiments, when the source resource path is a relative path, the complete path of the resource file can be generated according to the complete path of the source file and the relative path. Exemplarily, in the sub-application source code file, the methods provided by other files are not referenced with the @ symbol, but directly referenced through the relative path, and the relative path is: ".. / .. / .. / router / modules / msgs", then the prefix path "projects / standard / src / " can be found directly through the complete path of the source file "projects / standard / src / views / passport / login / index.vue", and the ".. / .. / .. / " symbol is replaced to obtain the complete path of the resource file "project / standard / src / router / modules / msgs", and then the resource is resolved and returned through the resolve method. It can be understood that a ".. / " represents a return to the previous file level.

[0098] In some embodiments, in step S105, according to the micro-application configuration information and the complete path of the resource file, the initial sub-application code is filtered using a virtual application scaffolding tool to obtain the target sub-application code, which may include but is not limited to the following steps:

[0099] Use preset plugin settings to run shared configuration information;

[0100] Create multiple sub-application federation objects based on the micro-application configuration information and the running shared configuration information;

[0101] Add multiple sub-application federated objects to the sub-application plugin queue;

[0102] Initialize the bucket object;

[0103] Traverse the file collection in the sub-application plug-in queue to add the first resource in the file collection that complies with the preset naming rule to the bucket object, and add the reference resource of the first resource to the bucket object;

[0104] According to the bucket object and the complete path of the resource file, the initial sub-application code is filtered to obtain the target sub-application code.

[0105] In some embodiments, the preset plug-in settings can be used to run shared configuration information. For example, the "@originjs / vite-plugin-federation" plug-in configuration shared (shared field) can be used to realize the sharing of all public codes at runtime, including the public library introduced in the third-party package.json (including providing a CDN link or not providing a CDN link) and the public library implemented within the project (including any number). These public codes are configured as shared through the shared field provided by the plug-in, so that when running, the sub-application will give priority to the instance object created by the public code provided by the main application. For example, third-party public libraries may include: vue, vue-router, vuex, @vueuse / core, @vueuse / rxjs, ant-design-vue, @ant-design / icon-vue, lodash, tiny-emitter, axios, echarts, core-js, dayjs, pinia, date-fns, rxjs, etc. The internal public libraries of the project may include: @icc / store, @icc / api, @icc / hooks, @icc / utils, @icc / msg, @icc / directives, @icc / components, @icc / apppush, @icc / jy, @icc / email, @icc / rcs5g, @icc / sms, @icc / isms, @icc / tiktok, @icc / videoSms, @icc / voice, @icc / wechat, @icc / workwx, etc.

[0106] Then, according to the micro-application configuration information and the running shared configuration information, multiple sub-application federation objects are created, and multiple sub-application federation objects are added to the sub-application plug-in queue. For example, the effect of batch packaging of sub-applications can be achieved by adding the federation provided by the "@originjs / vite-plugin-federation" plug-in to the plug-in queue of the vite scaffold. Read the micro-application configuration information in the microinfo.json configuration file (micro-information configuration file), obtain all sub-application information, create a federation object (sub-application federation object) for each sub-application, and add it to the sub-application plug-in queue. Then initialize the bucket object, traverse the file collection in the sub-application plug-in queue, and add the first resource in the file collection that meets the preset naming rules to the bucket object, and add the reference resource of the first resource to the bucket object. Finally, according to the bucket object and the complete path of the resource file, the initial sub-application code is filtered to obtain the target sub-application code. For example, the custom plug-in "patch:federation" can be used to achieve full sharing of all public codes (third-party libraries, internal public libraries of the project) in the production environment. Create a custom plugin "patch:federation" and implement filtering of all public resource files in the generateBundle hook function. Add this custom plugin "patch:federation" to the plugin queue. The implementation process of the generateBundle hook function is as follows: Figure 3 As shown, create a "bucket" (also called a bucket object), traverse the bundles (file collections) of all resources, add the resources starting with federation_expose (i.e. the preset naming rule) to the "bucket", and add the references related to the resource (i.e. reference resources) such as css, pictures, chunk (js) and references in recursive processing references to the "bucket", and finally traverse the bundle again as the initial sub-application code, and delete the resources that are not in the "bucket". Through this process, the generated target sub-application code only contains business code, and all other public resources are filtered out. It can be understood that in the packaging process, bundle refers to the result of integrating multiple independent files and modules into one or several separate files. Through the processing of the build tool, the bundle is the final static file generated and can be directly loaded by the browser. In short, a bundle is a file or a collection of files containing application code and resources, which is the product that will eventually be deployed to the server and used by the browser. The final stage of package analysis will output many file collections (also called bundles). The resources exported by the sub-applications will have their file names starting with federation_expose after packaging.

[0107] Furthermore, by creating vite.config.ts in the project root directory as the scaffolding configuration of the virtual application, the packaging tasks of all sub-application business codes can be processed in batches. In the scaffolding configuration of the virtual application, the aliases from each sub-application or the full paths of all referenced resource files in the sub-application are processed through placeholders and custom resource resolution methods; multiple federation objects are added to the plug-in queue to process and parse the business code exported by each sub-application; finally, a custom path:federation plug-in is added to the plug-in queue to filter out the files generated after compilation and parsing from the public library (including third-party libraries and public libraries within the project), and only the files containing the keyword federation_expose in the file name are retained, that is, the files generated by the sub-application business code, to ensure full sharing of the production environment and minimize the size of the deployment package.

[0108] In some embodiments, in step S106, generating main application configuration information according to micro-application configuration information may include but is not limited to the following steps:

[0109] Determine the sub-application entry file loading path based on the micro-application configuration information;

[0110] Create the main application federation object;

[0111] Add the main application federated object to the main application plug-in queue to configure the shared field and obtain the shared field configuration information;

[0112] Generate the main application configuration information based on the sub-application entry file loading path, sub-application name and shared field configuration information.

[0113] In some embodiments, a vite.config.ts file (main application configuration file) is created in the root directory of the main application for packaging and building the main application. The sub-application entry file loading path can be determined first according to the micro-application configuration information. Exemplarily, the micro-application configuration information can be read, and all sub-applications can be traversed to determine the entry file loading path of the sub-application. Then a main application federation object is created, and the main application federation object is added to the main application plug-in queue to configure the shared field and obtain the shared field configuration information. Exemplarily, a federation plug-in object (i.e., the main application federation object) can be created, and the federation plug-in object is added to the main application plug-in queue. For the shared field (shared field), it is configured to generate corresponding shared resource files after packaging and building, and shared field configuration information is generated, so that the shared resource object loaded by the main application can be directly used in the sub-application. Finally, according to the sub-application entry file loading path, the sub-application name and the shared field configuration information, the main application configuration information is generated. Exemplarily, the mapping object of remotes (remote warehouse), the sub-application name and the sub-application entry file loading path can be configured so that the resource file corresponding to the sub-application can be found by name in the main application. It is understandable that since there can be multiple sub-applications, there can also be multiple sub-application federated objects, but there is only one main application, so there is only one main application federated object, and the attribute states of the sub-application federated object are different from those of the main application federated object.

[0114] In some embodiments, in step S107, a fast full build can be performed based on the common library configuration information, the target sub-application code, and the main application configuration information to obtain the main application and multiple sub-applications. For example, this embodiment optimizes the full build from the traditional 1+N (sub-application) build execution commands to 1+1 build execution commands. Even if the functions of the later projects are continuously iterated and the number of sub-applications in the plug-in system continues to increase, the packaged build still executes 1+1 build commands. Among them, the traditional packaged build process is as follows: Figure 4 As shown in the figure, the packaging and building process of the virtual application is as follows Figure 5 As shown in the figure, because executing multiple build commands in parallel consumes a lot of server CPU resources and is prone to the problem of the entire packaging task failing due to insufficient memory, each build command can be executed in serial mode.

[0115] In some embodiments, the project structure is as follows: Figure 6As shown, in the plug-in system, the sample project has a main application (standard) and 10 sub-application plug-ins, each of which contains source code src and scaffolding configuration vite.config.ts, and all sub-applications rely on the third-party library node_modules and the internal shared public library icc-ui. When using the traditional full-scale build method, the more complex the plug-in system, the more sub-applications it contains, the more public libraries it contains, the longer the total build time of the full-scale build, and the larger the total volume of the deployment package. When using the method of this embodiment, as the number of sub-applications increases, the total time of the package build and the total volume of the deployment package remain unchanged, which is more efficient than the traditional method.

[0116] In some embodiments, for a normal full build of a plug-in system, each sub-application and the main application need to execute the build command, and each sub-application will output shared public resource files after being built. The final results are: (1) total packaging construction time: (one main application + N sub-application plug-ins) * packaging construction time for a single application; (2) total deployment package size: (one main application + N sub-application plug-ins) * single application deployment package size; (3) Although the build time and deployment package size of each sub-application are different, these differences are usually not significant. However, as the number of sub-application plug-ins increases, the total construction time and the total size of the deployment package will increase linearly. This embodiment uses a virtual application to carry the business code parsing and compilation tasks exported by all sub-applications. In this way, only one main application and one virtual application need to be packaged, and multiple sub-applications need not be packaged separately. And shared public resources are only output in the main application. In the virtual application construction plug-in queue, the patch: federation plug-in finally filters out all public library files and only outputs files generated by its own business code. When the production environment is reached, it is fully shared, thereby solving the problem of excessive size of the deployment package after the plug-in system is built. The size of the final output deployment package is close to the size of a single application. In addition, this superimposed packaging mode has little impact on the total build time and total package size when the number of sub-applications increases, avoiding the disadvantage of linear growth. The beneficial effects include: (1) No matter how many sub-applications are included in the project, the total build time is to package a main application and a virtual container application that carries the sub-applications, which is equivalent to the time to package and build two single applications. (2) The total size of the deployment package: the files generated corresponding to the business code + a file generated by a public shared resource, is close to the size of the deployment package generated after the single application is packaged. (3) As the number of sub-application plug-ins increases in the later stage, the impact on the total packaging build time and total size will be very limited. This embodiment has been experimentally tested. The plug-in system includes 1 main application and 10 sub-applications. In the test results, for the total local build time, the traditional packaging method takes about 700 seconds, and the method of this embodiment takes about 120 seconds; for the total automated packaging build time, the traditional packaging method takes about 35 minutes, and the method of this embodiment takes about 12 minutes; for the total size of the deployment package, the traditional packaging method is about 200M, and the method of this embodiment is about 16.7M.

[0117] The beneficial effects of implementing the embodiments of the present invention include: the embodiments of the present invention first obtain common library information and sub-application information, then generate common library configuration information based on the common library information, and generate micro-application configuration information based on the sub-application information, and then parse the source resource path in the sub-application source code file to obtain the complete path of the resource file, and filter the initial sub-application code using a virtual application scaffolding tool based on the micro-application configuration information and the complete path of the resource file to obtain the target sub-application code, and finally generate the main application configuration information based on the micro-application configuration information, and perform a rapid full build based on the common library configuration information, the target sub-application code and the main application configuration information to obtain the main application and multiple sub-applications, so that shared resources can be shared through a variety of configuration information to achieve a rapid full build, thereby improving efficiency and reducing the size of the deployment package.

[0118] In some embodiments, this embodiment only needs to package the common resources once to package the sub-applications, without having to repeatedly package the common resources each time the sub-applications are packaged, thereby reducing the total time of the full build. At the same time, only the business code of the sub-application exists in the file after the sub-application is packaged, and the common resource code is not included, thereby reducing the total size of the deployment package, and maximizing the impact of the increase in the number of sub-applications on the packaged build, avoiding the linear growth of the build time and volume with the number of sub-applications. At the same time, the present invention creates a vite configuration file in the project root directory as a scaffolding of the virtual application to carry the batch packaging tasks of all sub-applications. In the vite scaffolding, on the one hand, it is necessary to solve the problem of inconsistent alias path mapping defined within a single sub-application, and on the other hand, create a federation object provided by the vite-plugin-federation plug-in for each sub-application and add it to the plug-in queue to process the code files exported from each sub-application, and at the same time, add a custom patch:federation plug-in at the end of the plug-in queue, filter the files in the generateBundle hook function, and only output the files generated by the business code compilation. This can effectively solve the problems of long full build time and large deployment package size in the plug-in system. The original need to execute 1+N build commands is optimized to only need to execute 1+1 build commands, and the deployment package size is close to that of a single application.

[0119] In addition, by creating a virtual application, configuring a vite scaffold in the system root directory, and customizing the parsing path through placeholders, the problem of inconsistent alias path mapping defined within a single sub-application can be solved, and then all sub-applications can be put into the virtual application for batch packaging, thereby achieving a superimposed packaging effect. This method integrates multiple sub-applications that originally need to be packaged into only one virtual application, that is, the original need to execute 1+N (sub-application) build commands is optimized to only need to execute 1+1 (virtual application) build commands, greatly shortening the overall build time of the system. Even if the number of sub-applications increases in the later stage, the impact on the packaging and building effect is very small. By customizing the patch:federation plug-in, add the plug-in at the end of the build plug-in queue, and implement the filtering of files generated after all public code compilation in the generateBundle hook function of the plug-in, only including the files compiled by the business code (the file name contains federate_expose), and fully sharing in the production environment, not only for third-party libraries that provide or do not provide CDN links, but also for multiple public libraries defined within the project, simple sharing method, unified process processing, without the need for cumbersome import and export. On the one hand, it can minimize the size of the plug-in system deployment package, making it close to the effect of a single application; and it is also suitable for deployment in an intranet environment. Even if the project becomes more complex and the number of public components increases, the sharing method only needs to configure the alias and shared fields, and only one copy of the shared file will be generated after packaging.

[0120] like Figure 7 As shown, the embodiment of the present invention also provides a fast full-volume construction device, including:

[0121] The first module 801 is used to obtain public library information and sub-application information, the public library information includes the public library alias and the public library path, and the sub-application information includes the sub-application name, entry file name, startup port number, open resource name and open resource path;

[0122] The second module 802 is used to generate public library configuration information according to the public library information;

[0123] The third module 803 is used to generate micro-application configuration information according to the sub-application information;

[0124] The fourth module 804 is used to parse the source resource path in the sub-application source code file to obtain the complete path of the resource file, where the source resource path includes an alias path or a relative path;

[0125] The fifth module 805 is used to filter the initial sub-application code using the virtual application scaffolding tool according to the micro-application configuration information and the complete path of the resource file to obtain the target sub-application code, where the initial sub-application code includes the business code and the public resource code, and the target sub-application code includes the business code;

[0126] The sixth module 806 is used to generate main application configuration information according to the micro application configuration information;

[0127] The seventh module 807 is used to perform a fast full build based on the common library configuration information, the target sub-application code and the main application configuration information to obtain the main application and multiple sub-applications.

[0128] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0129] like Figure 8 As shown, an embodiment of the present invention further provides a computer device, including:

[0130] at least one processor 901;

[0131] At least one memory 902, used to store at least one program;

[0132] When at least one program is executed by at least one processor, the at least one processor implements Figure 1 The method shown.

[0133] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0134] The embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, Figure 1 The method shown.

[0135] The contents of the above method embodiments are all applicable to the present storage medium embodiments. The functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0136] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A fast full-volume construction method, characterized in that: The following steps are involved: Obtaining public library information and sub-application information, wherein the public library information includes a public library alias and a public library path, and the sub-application information includes a sub-application name, an entry file name, a startup port number, an open resource name, and an open resource path; Generate public library configuration information according to the public library information; Generate micro-application configuration information according to the sub-application information; Parse the resource path in the sub-application source code file to obtain the complete path of the resource file, wherein the resource path includes an alias path or a relative path; According to the micro-application configuration information and the complete path of the resource file, the initial sub-application code is filtered using a virtual application scaffolding tool to obtain a target sub-application code, wherein the initial sub-application code includes a business code and a public resource code, and the target sub-application code includes the business code; Generate main application configuration information according to the micro application configuration information; According to the common library configuration information, the target sub-application code and the main application configuration information, a rapid full build is performed to obtain a main application and multiple sub-applications.

2. The method according to claim 1, characterized in that The generating of public library configuration information according to the public library information includes: Combining the public library alias and the public library path to obtain a public library alias path combination; Add a plurality of the public library alias path combinations to the first preset configuration file to obtain the public library configuration information.

3. The method according to claim 1, characterized in that The generating micro-application configuration information according to the sub-application information includes: Combining the open resource name and the open resource path to obtain an open resource key-value pair; The sub-application name, the entry file name, the startup port number and multiple open resource key-value pairs are added to the second preset configuration file to obtain the micro-application configuration information.

4. The method according to claim 1, characterized in that: When the source resource path is a path containing an alias, the source resource path in the sub-application source code file is parsed to obtain the complete path of the resource file, including: According to the preset placeholder root path and the sub-application name, the alias in the alias-containing path is replaced to obtain the complete path of the resource file.

5. The method according to claim 1, characterized in that When the resource path is a relative path, the resource path in the sub-application source code file is parsed to obtain the complete path of the resource file, including: The complete path of the resource file is generated according to the complete path of the source file and the relative path.

6. The method according to claim 1, characterized in that The method of filtering the initial sub-application code using a virtual application scaffolding tool according to the micro-application configuration information and the complete path of the resource file to obtain the target sub-application code includes: Use preset plugin settings to run shared configuration information; Creating a plurality of sub-application federated objects according to the micro-application configuration information and the running shared configuration information; Adding the plurality of sub-application federated objects to a sub-application plug-in queue; Initialize the bucket object; Traversing the file collection in the sub-application plug-in queue to add a first resource in the file collection that complies with a preset naming rule to the bucket object, and adding a reference resource of the first resource to the bucket object; The initial sub-application code is filtered according to the bucket object and the complete path of the resource file to obtain the target sub-application code.

7. The method according to claim 1, characterized in that The generating main application configuration information according to the micro application configuration information includes: Determine the sub-application entry file loading path according to the micro-application configuration information; Create the main application federation object; Adding the main application federated object to the main application plug-in queue to configure the shared field and obtain shared field configuration information; The main application configuration information is generated according to the sub-application entry file loading path, the sub-application name and the shared field configuration information.

8. A fast full-volume construction device, characterized in that: include: The first module is used to obtain public library information and sub-application information, wherein the public library information includes a public library alias and a public library path, and the sub-application information includes a sub-application name, an entry file name, a startup port number, an open resource name, and an open resource path; The second module is used to generate public library configuration information according to the public library information; The third module is used to generate micro-application configuration information according to the sub-application information; The fourth module is used to parse the source resource path in the sub-application source code file to obtain the complete path of the resource file, wherein the source resource path includes an alias path or a relative path; The fifth module is used to filter the initial sub-application code using a virtual application scaffolding tool according to the micro-application configuration information and the complete path of the resource file to obtain a target sub-application code, wherein the initial sub-application code includes a business code and a public resource code, and the target sub-application code includes the business code; The sixth module is used to generate main application configuration information according to the micro application configuration information; The seventh module is used to perform a rapid full build based on the common library configuration information, the target sub-application code and the main application configuration information to obtain the main application and multiple sub-applications.

9. A computer device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Resource integration method and electronic equipment

    CN114816732A

  • Public code resource sharing method and device, equipment and storage medium

    CN115373731A

  • Program fusion method and device, equipment, storage medium and computer program product

    CN116991411A

  • MDF-based micro-front-end resource sharing method and system, and storage medium

    CN117149301A

  • Multi-project shared dependency package packaging method and device, electronic equipment and storage medium

    CN118377524A