Component splitting, docking and loading processing method and device for application project
By generating the configuration files and component libraries of the target project components, registering them to the source warehouse and building a loader, the time-consuming and risk problems in the splitting process of application project components is solved, efficient component stripping and simplifying processing is achieved, and cost reduction is reduced and test time.
Patent Information
- Application Number
- CN202411300378.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-09-18
AI Technical Summary
The existing technology consumes time and effort in the process of splitting components of the application project. The high degree of component coupling leads to difficulty in clarifying dependencies, making errors prone to making, affecting application functions, and the test time is long and costly.
By generating configuration files for target project components, using packaging tools to generate target component libraries, including associated component files for target project components and dependencies, and register them in the source repository. Build a loader to load components dynamically, reducing component docking and testing complexity sex.
It realizes effective peeling of components and simplifies processing processes, reduces costs and risks, avoids direct docking and repeated development between components, and improves testing efficiency.
Smart Images

Figure CN119225857A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of application development, and in particular to a component splitting, docking and loading processing method and device for an application project. Background Art
[0002] In the field of application development, it is usually necessary to create a main project corresponding to the application, and establish various sub-projects in the main project according to the functions to be implemented by the application, and there are various associations between the sub-projects. As the demand increases and improves, it is necessary to add corresponding projects to the application project or optimize the original related projects and iterate the original project. After multiple iterations, the application project will become a monolithic project. For an application that chooses to be built with a component library, the application project contains various components. For a monolithic project, the coupling between its components is high and complex. When adding new functions or improving the original functions, it is only necessary to optimize the project components involved. In order to improve or optimize the related project components, it is usually necessary to split the corresponding project components from the original project and optimize them based on the split project components. The existing general splitting method is to redevelop the component to be split to generate a replacement component, that is, rewrite the code for the function of the component to be split to obtain a new component, and then configure the parameters and release environment of the replacement component. After the development is completed, the original component is deleted and the replacement component is docked to the original project. This project splitting method has the following problems: First, it is time-consuming, labor-intensive and repetitive because the replacement components need to be redeveloped. Second, it is very difficult to clarify the dependencies between components due to the high and complex coupling between components in the original project. Therefore, it is easy to make mistakes when deleting the original components and connecting the new replacement components, which can easily cause adverse potential impacts on other components with dependencies, thereby affecting the application functions and posing a high risk. Furthermore, the disassembled components not only need to configure themselves, but also need to establish relationships with the original project and other components within it, and they need to be released independently after testing is completed, so the process is cumbersome. In addition, after the optimization is completed, not only the replacement component itself needs to be tested, but also the overall regression test of the application needs to be performed, which takes a long time and the cost of the overall test is high. Summary of the invention
[0003] In view of the technical problems existing in the prior art, the present invention proposes a method and device for component splitting, docking and loading processing of application projects, which can effectively strip the original project components, simplify the processing process, and reduce costs and risks.
[0004] In order to solve the above technical problem, according to one aspect of the present invention, the present invention provides a component splitting processing method for an application project, comprising the following steps:
[0005] Generate a configuration file of a target project component based on the application project, wherein the target project component is a component that needs to be separated from the original project, and the configuration file at least includes an identifier of the target project component;
[0006] Providing the application project code and the configuration file to a packaging tool, and generating a target component library through the packaging tool, wherein the target component library includes a target project component file and associated project component files having a dependency relationship with the target project component;
[0007] Generate an entry file of the target component library based on the configuration file;
[0008] Packaging the target component library based on the entry file and generating a version file; and
[0009] Register the packaged target project component library to the source repository accessible to the original project.
[0010] Preferably, the number of the target project components is one or more.
[0011] Preferably, when there are multiple target project components, a respective configuration file and a respective target component library are generated for each target project component.
[0012] Preferably, when there are multiple target project components, based on the business attributes of the target project components, a configuration file is generated for the target project components with the same business attributes, and a corresponding target component library is generated.
[0013] Preferably, the step of generating a target component library by a packaging tool includes:
[0014] The packaging tool analyzes the dependency relationship of all project components of the original project based on the target project component identifier in the configuration file, and determines the associated project components that have a dependency relationship with the target project component;
[0015] The packaging tool references the component code file names of the target project components and the associated project components in the original project to form a project component directory; and
[0016] The packaging tool obtains the project component code files according to the project component directory and compiles them into standard component files for release; wherein the compiled standard component files constitute the target component library.
[0017] Preferably, the step of generating an entry file of a target component library based on the configuration file comprises:
[0018] Configure the common content of the entry file template;
[0019] Traverse the configuration file corresponding to the target component library and obtain the target project component identifier therefrom; and
[0020] The target project component identifier is added to the entry file template to obtain the entry file of the target component library.
[0021] According to another aspect of the present invention, the present invention further provides a component docking processing method for an application project, which is used to dock the application project with the components split according to the above method, comprising the following steps:
[0022] Build a loader in the form of an npm package and register it in the source repository;
[0023] generating an export file for the loader capable of loading a target project component;
[0024] Adding a reference to the loader in the external dependency package configuration file of the application project; and
[0025] In the original application project, modify the reference to the target project component to a reference to the component in the component library.
[0026] Preferably, the step of generating an export file capable of loading a target project component for the loader comprises:
[0027] Configure the common content of export document templates;
[0028] Traversing the configuration files of the target project components corresponding to the target component library, and obtaining the target project component identifier therefrom; and
[0029] The target project component identifier is added to the export file corresponding to the target component library in the export file template.
[0030] According to another aspect of the present invention, the present invention further provides a component loading processing method for an application project, wherein the application project undergoes the aforementioned component docking processing, and the loading processing method comprises the following steps:
[0031] When a reference to a target project component in the running of the application project is a reference to a component in a component library in a source repository, the loader is started based on a reference to the loader in an external dependency package configuration file;
[0032] Determining whether the loader has the ability to load the target project component based on the target project component identifier of the request;
[0033] In response to the loader having the ability to load the target project component, determining whether the target project component exists in the cache resource based on the request;
[0034] In response to the target project component existing in the cache resource, returning the target project component to the application project; and
[0035] In response to the target project component not being present in the cache resource, the target project component is pulled from a target component library of a source warehouse, and the target project component is returned to the application project.
[0036] Preferably, the step of determining whether the loader has the ability to load the target project component further comprises:
[0037] querying the export file based on the target project component identification of the request;
[0038] Determining whether the export file contains the target project component identifier;
[0039] In response to the target project component identifier being included in the export file, it is determined that the target project component has the ability to be loaded.
[0040] Preferably, after the target project component is pulled from the target component library of the source warehouse and the target project component is returned to the application project, the target project component is registered globally.
[0041] Preferably, during the running of the application project, when a reference to a target project component is a reference to a component in a component library, a Promise object is returned to the original project, and the target project component is requested by the loader in an asynchronous process; correspondingly, when the target project component is returned to the application project, the target project component is returned to the original project through the Promise.resolve method.
[0042] Preferably, the step of pulling the target project component from the target component library of the source warehouse includes:
[0043] Get the version file of the target project component based on the identifier of the target project component in the reference;
[0044] Based on the target project component library in the reference, determine the corresponding component library version;
[0045] Concatenate the target project component library ID and component library version in the reference as the resource ID;
[0046] Generate a script element, and add the resource identifier and source warehouse address to the script element attributes; and
[0047] Based on the resource identifier and the source warehouse address in the script element attribute, the target project component corresponding to the resource identifier is obtained from the source warehouse.
[0048] According to another aspect of the present invention, the present invention further provides a component splitting processing device for an application project, comprising:
[0049] A configuration file generating module, configured to generate a configuration file of a target project component based on the application project, wherein the target project component is a component that needs to be separated from the original project, and the configuration file at least includes an identifier of the target project component;
[0050] A component library determination module is configured to provide the application project code and the configuration file to a packaging tool, and generate a target component library through the packaging tool, wherein the target component library includes a target project component file and associated project component files having a dependency relationship with the target project component;
[0051] An entry file generation module, configured to generate an entry file of a target component library based on the configuration file;
[0052] a packaging module configured to package the target component library based on the entry file and generate a version file; and
[0053] The registration module is configured to register the packaged target component library into a source repository accessible to the original project.
[0054] According to another aspect of the present invention, the present invention also provides a component docking processing device for an application project, comprising:
[0055] The loader building module is configured to build a loader in the form of an npm package and register it with the source repository;
[0056] an export file generation module configured to generate an export file capable of loading a target project component for the loader; and
[0057] The reference modification module is configured to add a reference to the loader in the external dependency package configuration file of the application project; and modify the reference to the target project component in the original application project to a reference to the component in the component library in the source warehouse.
[0058] According to another aspect of the present invention, the present invention further provides a component loading processing device for an application project, the loading processing device comprising:
[0059] A request module configured to start the loader based on a reference to the loader in an external dependency package configuration file when a reference to a target project component is a reference to a component in a component library during the running process of the application project;
[0060] a checking module configured to determine whether the loader has the ability to load the target project component based on the target project component identifier; and
[0061] The loading module is configured to return the target project component to the application project in response to the loader having the ability to load the target project component and the target project component existing in the cache resource; in response to the target project component not existing in the cache resource, pull the target project component from the target component library of the source warehouse and return the target project component to the application project.
[0062] According to another aspect of the present invention, the present invention also provides an electronic device, which includes a processor and a memory, wherein a computer program instruction set is stored on the memory, and when the processor executes the computer program instruction set on the memory, the component splitting processing method of the aforementioned application project is implemented, or the component docking processing method of the aforementioned application project is implemented, or the component loading processing method of the aforementioned application project is implemented.
[0063] According to another aspect of the present invention, the present invention also provides a computer-readable storage medium, wherein a computer program instruction set is stored on the computer-readable storage medium, and when the computer program instruction set is executed by a processor, it implements the component splitting processing method of the aforementioned application project, or implements the component docking processing method of the aforementioned application project, or implements the component loading processing method of the aforementioned application project.
[0064] According to another aspect of the present invention, the present invention also provides a computer program product, which includes a computer program instruction set, and when the computer program instruction set is executed by a processor, it implements the component splitting processing method of the aforementioned application project, or implements the component docking processing method of the aforementioned application project, or implements the component loading processing method of the aforementioned application project.
[0065] The embodiments of the present invention can effectively strip the original project components, simplify the processing process, and reduce costs and risks. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] The preferred embodiments of the present invention will be further described in detail below with reference to the accompanying drawings, wherein:
[0067] Figure 1 is a flow chart of a component splitting method for an application project according to an embodiment of the present invention;
[0068] Figure 2 is a flow chart of a component docking processing method for an application project according to an embodiment of the present invention;
[0069] Figure 3 is a flow chart of a component loading processing method for an application project according to an embodiment of the present invention;
[0070] Figure 4is a principle block diagram of a component splitting processing device for an application project according to an embodiment of the present invention;
[0071] Figure 5 is a principle block diagram of a component docking processing device for an application project according to an embodiment of the present invention;
[0072] Figure 6 is a principle block diagram of a component loading processing device for an application project according to an embodiment of the present invention;
[0073] Figure 7 is a complete principle block diagram of an application project processing system according to an embodiment of the present invention; and
[0074] Figure 8 It is a schematic diagram of the hardware structure principle of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0075] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0076] In the following detailed description, reference may be made to the various specification drawings that are part of the present application and are used to illustrate specific embodiments of the present application. In the accompanying drawings, similar reference numerals describe substantially similar components in different figures. The various specific embodiments of the present application are described below in sufficient detail so that a person of ordinary skill in the art with relevant knowledge and skills in the art can implement the technical solutions of the present application. It should be understood that other embodiments may also be used or structural, logical or electrical changes may be made to the embodiments of the present application.
[0077] The present invention provides an application development technology. In order to facilitate the subsequent optimization and improvement of an existing application project, components corresponding to one or more sub-projects are split out from the original project as needed.
[0078] See also Figure 1 , Figure 1 1 is a flow chart of a component splitting method of an application project according to an embodiment of the present invention, wherein the splitting method comprises the following steps:
[0079] Step S11, generating a configuration file of a target project component, wherein the target project component is one or more project components in the original project determined according to the optimization requirements, such as project component A, project component B, and project component C, each of which corresponds to a function. The content in the configuration file includes the target project component identifier and other configuration parameters, such as domain name configuration parameters, proxy configuration parameters, component configuration parameters, etc.
[0080] Step S12, providing the application project code and the configuration file to a packaging tool, and generating a target component library through the packaging tool, wherein the target component library includes a target project component file and associated project component files having a dependency relationship with the target project component.
[0081] Step S13, generating an entry file of the target component library based on the configuration file.
[0082] Step S14: Packaging the target component library based on the entry file and generating a version file.
[0083] Step S15, registering the packaged target project component library into a source repository accessible to the original project.
[0084] Wherein, in step S11, if there are multiple project components, a configuration file can be generated for the multiple project components, thereby generating a target component library in the subsequent processing. However, in order to avoid generating another monolith project, a respective configuration file can also be generated for each target project component, thereby generating a respective target component library in the subsequent processing. In addition, a configuration file can also be generated for multiple target project components with the same business attributes, thereby generating a target component library in the subsequent processing. In this embodiment, since project component A and project component B have the same business attributes, a first configuration file is generated for project component A and project component B, and a second configuration file is generated for project component C. The "first" and "second" here are only used to distinguish two files with the same name, and do not represent sorting. Wherein, these two configuration files are stored in the configuration folder.
[0085] In step S12, the packaging tool is, for example, webpack. After the application project code and the configuration file are provided to webpack, webpack analyzes the dependency relationship of all project components of the original project based on the target project component identifier in the configuration file, and determines the associated project components that have a dependency relationship with the target project component; for example, the associated project components of project component A are component D and component E; the associated project components of project component B are component D, component F, and component G; the associated project components of project component C are component H and component I. Then webpack references the component code file names of the target project component and the associated project component in the original project to form a project component directory.
[0086] For project components A and B, the project component directories are as follows:
[0087] Folder 1 / Component D
[0088] Folder 2 / Component E, Component F
[0089] Folder 3 / Component G
[0090] Component files / project component A, project component B
[0091] For project component C, the project component directory is as follows:
[0092] Folder 2 / Component H
[0093] Folder 3 / Component I
[0094] Component File / Project Component C
[0095] The capital letters are component names, and the slashes indicate directory levels.
[0096] webpack obtains the project component code files according to the project component directory and compiles them into standard component files for release; the compiled standard component files constitute the target component library.
[0097] Therefore, for project component A and project component B, a first target component library is generated, such as named as the first business component library, and for project component C, a second target component library is generated, such as named as the second business component library.
[0098] In step S13, in one embodiment, an entry file can be manually generated for each target component library by a developer. In another embodiment, an entry file can be generated for each target component library by means of a template. This embodiment uses an entry file template (such as json-templater) to generate the entry file of each target component library. In one embodiment, the entry file template includes three contents: "component library version information", "component content" and "global registration capability". Among them, for multiple target component libraries obtained from the same original project, "component library version information" and "global registration capability" are the common contents of the entry file, and all entry files have the same two contents and can be reused, only "component content" is different, so before generating the entry file, the "component library version information" and "global registration capability" of the entry file template are manually set, and then the template function of json-templater and the capabilities of modules such as fs in nodeJS are used to traverse the configuration files in the configuration folder, and the target project component identification is obtained therefrom, and the target project component identification is used as the "component content" of the entry file, and filled in the entry file template, so as to obtain the entry file of each target component library. For example, in order to generate the first entry file of the first business component library, determine the corresponding first configuration file from the configuration folder, read the identifiers of project component A and project component B from the first configuration file, and add their identifiers to the "component content" of the entry file, such as "Import A; Import B;" to obtain the entry file of the first business component library, for example, named "First Business Component Library-Entry File".
[0099] In step S14, based on the entry file, the webpack packages each target component library. After packaging, a version file is generated for each target component library. For example, the version field content in the component file in each target component library is integrated together and stored in a Ver.json file, i.e., a version file. The version file is used to connect to the version control of the loader and to deal with the browser's cache problem.
[0100] In step S15, the packaged target component library is registered in a source repository accessible to the original project.
[0101] The embodiment of the present invention separates the target project components from the application project and registers them as a third party in a source repository accessible to the original project. This eliminates the need to redevelop the target project components, saving time and effort. The separated component library references the component files in the corresponding directory of the original project, and there is no need to adjust the file directory.
[0102] The present invention also provides a component docking processing method for an application project, which is used to dock the original application project with the components split according to the above method, see Figure 2 , Figure 2 The present invention is a flowchart of a component docking processing method for an application project according to an embodiment of the present invention.
[0103] Step S21, build a loader in the form of an npm package and register it in the source repository.
[0104] Step S22, generating an export file capable of loading the target project component for the loader.
[0105] Step S23, adding a reference to the loader in the external dependency package configuration file of the application project.
[0106] Step S24, in the original application project, modify the reference to the target project component to a reference to the component in the component library.
[0107] Since the present invention splits the project components and publishes them in the source warehouse, in order to be able to access the split components for the original application project, the embodiment of the present invention builds a loading tool, i.e., a loader, in step S21. The loader is registered in the form of an npm package in the source warehouse (or package platform) accessible to the original application project. In the .npmrc file, @xxx is added to configure the source address of the source warehouse. When the loader package needs to be pulled, the loader package is pulled from the source warehouse accessed through the source address. The loader has the capabilities of naming isolation, asynchronous loading, and version control.
[0108] In step S22, when the loader generates an export file capable of loading the target project component, it can be generated manually or by a template as in the aforementioned method for generating the import file. For example, configure the common content of the export file template; traverse the configuration file corresponding to the target component library to obtain the target project component identifier therefrom; and add the target project component identifier to the export file template corresponding to the target component library. Corresponding to the aforementioned embodiment, the loader can load components in two component libraries: a first business component library and a second business component library, respectively. The first business component library corresponds to a first export file, and the second business component library corresponds to a second export file. The first export file records "export A; export B", and the second export file records "export C".
[0109] In application projects, references to components are usually made through static file directories, and the reference rule for static file directories is "Import A from 'Folder 1 / Component A File'". For example: Import A from "Disk D / Folder 1 / File 1", which means referencing component A from file 1 in folder 1 on disk D. The present invention modifies the reference rule to reference through the ESM rule, that is, a reference to components in the component library. The ESM rule is "Import A from 'Component Library 1 / Component A'", which means loading component A in component library 1 through package reference. Based on this reference rule, it is necessary to initiate a network request to the npm platform to load component library 1. After successful loading, reference the component A file in component library 1.
[0110] Through the aforementioned docking process, the separated components can be connected to the application project. Although the aforementioned docking process is described in the order of step 21 to step S24, it can be known that the docking process can also be implemented in a different order, and the developer can flexibly perform the aforementioned four steps.
[0111] See also Figure 3 , Figure 3 The present invention is a flow chart of a component loading processing method for an application project according to an embodiment of the present invention. During the running process of the application project, when a reference to a target project component is a reference to a component in a component library, the method comprises the following steps:
[0112] Step S31, starting the loader based on the reference to the loader in the external dependency package configuration file;
[0113] Step S32, based on the requested target project component identifier, determines whether the loader has the ability to load the target project component. If the loader has the ability to load the target project component, executes step S33. If the loader does not have the ability to load the target project component, then reports an error in step S34, waits for processing, and ends the loading processing flow.
[0114] Step S33, based on the request, determine whether the target project component exists in the cache resource. If the target project component exists in the cache resource, execute step S35; if the target project component does not exist in the cache resource, execute step S36.
[0115] Step S35, returning the target project component in the cache resource to the application project and ending the loading process.
[0116] Step S36, pull the target project component from the target component library of the source warehouse, return the target project component to the application project and end the loading process.
[0117] Among them, in step S32, when determining whether the loader has the ability to load the target project component, the export file is queried based on the target project component identifier; it is determined whether the export file contains the target project component identifier; if the export file contains the target project component identifier, it can be determined that the loader has the ability to load the target project component.
[0118] In addition, in step S36, after the target project component is pulled from the target component library of the source warehouse and returned to the application project, the target project component is registered globally, so that after the target project component is pulled, it is stored in the cache for the convenience of the next application.
[0119] In addition, further, when a reference to a target project component during the operation of the application project is a reference to a component in the component library in the source repository, a Promise object is returned to the original project, and the target project component is requested from the loader in an asynchronous process; correspondingly, when the target project component is returned to the application project, the target project component is returned to the original project through the Promise.resolve method.
[0120] In step S36, in one embodiment, the target project component is pulled from the target component library of the source warehouse by means of a script tag. Specifically, firstly, the version file of the target project component is obtained based on the identifier of the target project component in the reference, and the corresponding component library version data is determined based on the target project component library in the reference; the target project component library identifier and the component library version data in the reference are spliced together as a resource identifier; then a script element is generated, and the resource identifier and the source warehouse address are filled in the script element attribute; then, based on the resource identifier and the source warehouse address in the script element attribute, the target project component corresponding to the resource identifier is obtained from the source warehouse.
[0121] Through the aforementioned method, the components that require special processing in the original application project are integrated and extracted according to certain rules and then registered in the source warehouse. They can be independently versioned and have independent publishing capabilities. When applied, they are dynamically loaded according to the configuration through a unified loader, realizing the decoupling and migration of the project, saving time and effort.
[0122] Among them, when the component code is modified, check whether the final implementation effect is consistent with the expectation in the debugging scenario. The debugging process, for example, modifies the component code, then compiles, packages and publishes the new version of the component code file to the package platform, and then the original project requests the latest version of the component at runtime to check the running effect. Since the component files and directories in the split component library in the present invention refer to the original project directory and component files, the path can also be optimized and adjusted to: modify the component, the original project requests the component file, and check the effect after running. It can be seen that the debugging process steps can still be reduced in the debugging scenario, thereby achieving the purpose of improving debugging efficiency.
[0123] In addition, as mentioned earlier, the component files registered to the package platform (i.e., source repository) when the components are split still use the component files in the original project. Therefore, after the split, Git Modules can be used to update the main application project, thereby ensuring the real-time dependency of the component files.
[0124] The project components separated in the embodiment of the present invention are component packages in the umd format, which support pulling component libraries through script tags. The obtained component library content supports registration in the global environment, so it has caching capabilities. The global environment refers to the code running environment. The loader can store the successfully loaded components in the environment. If there is a similar request later, it can be read directly from the environment without creating a script tag to re-pull from the package platform.
[0125] From the foregoing content, it can be seen that the present invention can customize component content, and realize seamless splitting for the base project of the application; it reuses configuration variables such as the environment during splitting, and there is no need for code migration; in addition, it reuses the server and deployment environment to reduce resource usage, and can realize dynamic and asynchronous loading during loading, thereby improving the loading efficiency of the component.
[0126] See also Figure 4 , Figure 4It is a principle block diagram of a component splitting processing device for an application project according to an embodiment of the present invention. The component splitting processing device 10 for an application project in the embodiment of the present invention comprises a configuration file generating module 11, a component library determining module 12, an entry file generating module 13, a packaging module 14 and a registration module 15. Among them, the configuration file generating module 11 generates a configuration file of a target project component based on an application project 100, wherein the target project component is a component that needs to be split out from the original project, and the configuration file at least comprises a target project component identifier. The number of the target project components is one or more. When the number of the target project components is multiple, in one embodiment, a respective configuration file is generated for each target project component so as to generate a respective target component library in subsequent processing; in another embodiment, based on the business attributes of the target project components, a configuration file is generated for the target project components with the same business attributes, and a corresponding target component library is generated based on each business attribute in subsequent processing.
[0127] The component library determination module 12 is configured to provide the code of the application project 100 and the configuration file to a packaging tool, and generate a target component library through the packaging tool, wherein the target component library includes a target project component file and associated project component files having dependencies with the target project component. The packaging tool is, for example, webpack.
[0128] The entry file generation module 13 is configured to generate an entry file of the target component library based on the configuration file. In one embodiment, the entry file is generated by the entry file module, specifically, configuring the common content of the entry file template; traversing the configuration file corresponding to the target project component library to obtain the target project component identifier; and adding the target project component identifier to the entry file template to obtain the entry file of the target component library.
[0129] The packaging module 14 is configured to package the target component library based on the entry file and generate a version file. In one embodiment, the packaging module 14 generates the target component library through a packaging tool, for example, including: the packaging tool analyzes the dependency relationship of all project components of the original project based on the target project component identifier in the configuration file, and determines the associated project components that have a dependency relationship with the target project component; the packaging tool references the component code file names of the target project component and the associated project component in the original project to form a project component directory; and the packaging tool obtains the project component code file according to the project component directory and compiles it into a standard component file for release; wherein the compiled standard component file constitutes the target component library.
[0130] The registration module 15 is configured to register the packaged target component library into a source repository 200 accessible to the original project.
[0131] See also Figure 5 , Figure 5 It is a principle block diagram of a component docking processing device for an application project according to an embodiment of the present invention. The component docking processing device 20 for an application project in the embodiment of the present invention includes a loader construction module 21, an export file generation module 22 and a reference modification module 23, wherein the loader construction module 21 is configured to construct a loader in the form of an npm package and register it to a source warehouse 200; the export file generation module 2 is configured to generate an export file capable of loading a target project component for the loader; further, the export file generation module 2 configures the common content of the export file template, traverses the configuration file of the target project component corresponding to the target component library, obtains the target project component identifier therefrom, and adds the target project component identifier to the export file corresponding to the target component library in the export file template. The reference modification module 23 is configured to add a reference to the loader in the external dependency package configuration file of the application project 100, and modify the reference to the target project component in the original application project 100 to a reference to a component in the component library in the source warehouse.
[0132] See also Figure 6 , Figure 6 1 is a principle block diagram of a component loading processing device for an application project according to an embodiment of the present invention. The component loading processing device 30 for the application project in this embodiment includes a loader module 31, a verification module 32 and a loading module 33. In the running process of the application project, when a reference to a target component is a reference to a component in a component library, the loader module 31 is configured to start the loader based on a reference to the loader in an external dependency package configuration file; the verification module 32 is configured to determine whether the loader has the ability to load the target project component based on a target project component identifier; the loading module 33 returns the target project component to the application project 100 in response to the presence of the target project component in a cache resource when the loader has the ability to load the target project component; and pulls the target project component from the target component library of a source warehouse in response to the absence of the target project component in the cache resource, and returns the target project component to the application project 100.
[0133] See also Figure 7 , Figure 7It is a complete principle block diagram of an application project processing system according to an embodiment of the present invention. The application project processing system 300 in this embodiment includes the aforementioned application project component splitting processing device 10, the application project component docking processing device 20 and the application project component loading processing device 30. The application project component splitting processing device 10 is used to split the project components from the application project 100 and publish them to the source warehouse 200. The application project component docking processing device 20 is used to establish the association between the application project 100 and the split project components. When the split project components are needed during the application process of the application project 100, they are dynamically loaded by the application project component loading processing device 30. Therefore, the method and system provided by the present invention do not need to redevelop the components, which saves time and effort, and avoids the impact on the components with dependencies when accessing the original project, and does not need to re-build the relationship with the original project and other components. Moreover, the test time can be reduced and the test efficiency can be improved by optimizing the test.
[0134] In another aspect, the present invention further provides an electronic device, see Figure 8 , Figure 8 It is a schematic diagram of the hardware structure principle of an electronic device according to an embodiment of the present invention. The electronic device can be implemented as a server or other various terminal devices, such as a desktop personal computer, a tablet computer, a laptop computer, a mobile phone, etc., including a processor 601 and a memory 602. The memory 602 stores a program instruction set. When the processor 601 executes the program instruction set on the memory 602, the component splitting, docking and loading processing methods of the aforementioned application project are implemented.
[0135] Specifically, the processor 601 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiment of the present invention.
[0136] The memory 602 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 602 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 602 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 602 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 602 is a non-volatile solid-state memory.
[0137] The memory may include a read-only memory (ROM), a random access memory (RAM), a disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the component splitting, docking and loading processing methods of the application project provided by the present invention.
[0138] In one example, the electronic device may further include a communication interface 603 and a bus 604. The processor 601, the memory 602, and the communication interface 603 are connected via the bus 604 and communicate with each other.
[0139] The communication interface 603 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiment of the present invention.
[0140] Bus 604 includes hardware, software or both, and the components of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 604 may include one or more buses. Although the embodiment of the present invention describes and shows a specific bus, the present invention considers any suitable bus or interconnection.
[0141] The present invention also provides a computer-readable storage medium having computer program instructions stored thereon, which can be executed by a processor to implement the component splitting, docking and loading processing methods of any application project in the aforementioned embodiments. The computer-readable storage medium can be any medium that can tangibly contain or store computer-executable instructions for use by or in combination with an instruction execution system, device and equipment. The storage medium can be a transient computer-readable storage medium or a non-transient computer-readable storage medium. Non-transient computer-readable storage media may include, but are not limited to, magnetic storage devices, optical storage devices and / or semiconductor storage devices. Examples of corresponding embodiments of such storage devices include, for example, magnetic disks, optical disks based on CD, DVD or Blu-ray technology, and persistent solid-state memories such as flash memory, solid-state drives, and the like.
[0142] The present invention also provides a computer program product, which includes a set of computer program instructions, and when the computer program instruction set is executed by a processor, it implements any of the component splitting, docking and loading processing methods of the application project in the above-mentioned embodiments. The computer program product includes but is not limited to application installation packages published on websites and application stores, application plug-ins, and small programs that can be run in certain applications.
[0143] The above embodiments are only used to illustrate the present invention, but not to limit the present invention. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the scope of the present invention. Therefore, all equivalent technical solutions should also fall within the scope of the present invention.
Claims
1. A component splitting processing method for an application project, characterized in that: include: Generate a configuration file of a target project component based on the application project, wherein the target project component is a component that needs to be separated from the original project, and the configuration file at least includes an identifier of the target project component; Providing the application project code and the configuration file to a packaging tool, and generating a target component library through the packaging tool, wherein the target component library includes a target project component file and associated project component files having a dependency relationship with the target project component; Generate an entry file of the target component library based on the configuration file; Packaging the target component library based on the entry file and generating a version file; as well as Register the packaged target component library in the source repository accessible to the original project.
2. The method according to claim 1, characterized in that The number of the target project components is one or more.
3. The method according to claim 2, characterized in that When there are multiple target project components, a respective configuration file and a respective target component library are generated for each target project component.
4. The method according to claim 2, characterized in that: When there are multiple target project components, based on the business attributes of the target project components, a configuration file is generated for the target project components with the same business attributes, and a corresponding target component library is generated.
5. The method according to claim 1, characterized in that The steps to generate the target component library through the packaging tool include: The packaging tool analyzes the dependency relationship of all project components of the original project based on the target project component identifier in the configuration file, and determines the associated project components that have a dependency relationship with the target project component; The packaging tool references the component code file names of the target project components and the associated project components in the original project to form a project component directory; and The packaging tool obtains the project component code files according to the project component directory and compiles them into standard component files for release; wherein the compiled standard component files constitute the target component library.
6. The method according to claim 1, characterized in that The step of generating an entry file of a target component library based on the configuration file comprises: Configure the common content of the entry file template; Traverse the configuration file corresponding to the target component library and obtain the target project component identifier therefrom; and The target project component identifier is added to the entry file template to obtain the entry file of the target component library.
7. A component docking processing method for an application project, used for docking an original application project with components split out according to any one of the methods of claims 1-6, characterized in that: include: Build a loader in the form of an npm package and register it in the source repository; generating an export file for the loader capable of loading a target project component; Add a reference to the loader in the external dependency package configuration file of the application project; as well as In the original application project, modify the reference to the target project component to a reference to the component in the component library in the source repository.
8. The method according to claim 7, characterized in that The step of generating an export file capable of loading a target project component for the loader comprises: Configure the common content of export document templates; Traverse the configuration files of the target project component and obtain the target project component identifier therefrom; and The target project component identifier is added to the export file template to generate an export file for loading the target project component from the target component library.
9. A component loading processing method for an application project, wherein: The application project is subjected to the component docking process of claim 7 or 8, wherein the loading process method comprises: During the running of the application project, when a reference to a target project component is a reference to a component in a component library in a source repository, the loader is started based on a reference to the loader in an external dependency package configuration file; Determining whether the loader has the ability to load the target project component based on the target project component identifier of the request; In response to the loader having the ability to load the target project component, determining whether the target project component exists in the cache resource based on the request; In response to the target project component existing in the cache resource, returning the target project component to the application project; and In response to the target project component not being present in the cache resource, the target project component is pulled from a target component library of a source warehouse, and the target project component is returned to the application project.
10. The method according to claim 9, characterized in that The step of determining whether the loader has the ability to load the target project component further includes: Query the corresponding export file based on the target project component identifier of the request; Determining whether the export file contains the target project component identifier; In response to the target project component identifier being included in the export file, it is determined that the loader has the ability to load the target project component.
11. The method according to claim 9, characterized in that After pulling the target project component from the target component library of the source warehouse and returning the target project component to the application project, the target project component is registered globally.
12. The method according to any one of claims 9 to 11, characterized in that: During the running process of the application project, when a reference to a target project component is a reference to a component in the component library in the source repository, a Promise object is returned to the original project, and the target project component is requested by the loader in an asynchronous process; correspondingly, when the target project component is returned to the application project, the target project component is returned to the original project through the Promise.resolve method.
13. The method according to claim 9, characterized in that The step of pulling the target project component from the target component library of the source warehouse includes: Get the version file of the target project component based on the identifier of the target project component in the reference; Determine the corresponding component library version data from the version file based on the target component library identifier in the reference; The target project component library identifier and component library version data in the reference are concatenated together as a resource identifier; Generate a script element, and add the resource identifier and source warehouse address to the script element attributes; and Based on the resource identifier and the source warehouse address in the script element attribute, the target project component corresponding to the resource identifier is obtained from the source warehouse.
14. A component splitting processing device for an application project, characterized in that: include: A configuration file generating module, configured to generate a configuration file of a target project component based on the application project, wherein the target project component is a component that needs to be separated from the original project, and the configuration file at least includes an identifier of the target project component; A component library determination module is configured to provide the application project code and the configuration file to a packaging tool, and generate a target component library through the packaging tool, wherein the target component library includes a target project component file and associated project component files having a dependency relationship with the target project component; An entry file generation module, configured to generate an entry file of a target component library based on the configuration file; A packaging module, configured to package the target component library based on the entry file and generate a version file; as well as The registration module is configured to register the packaged target component library into a source repository accessible to the original project.
15. A component docking processing device for an application project, characterized in that: include: The loader building module is configured to build a loader in the form of an npm package and register it with the source repository; An export file generation module, configured to generate an export file capable of loading a target project component for the loader; as well as The reference modification module is configured to add a reference to the loader in the external dependency package configuration file of the application project; and modify the reference to the target project component in the original application project to a reference to the component in the component library in the source warehouse.
16. A component loading processing device for an application project, characterized in that: include: A request module configured to start the loader based on a reference to the loader in an external dependency package configuration file when a reference to a target project component is a reference to a component in a component library in a source repository during the running process of the application project; A verification module configured to determine whether the loader has the ability to load the target project component based on the target project component identifier; as well as The loading module is configured to return the target project component to the application project in response to the loader having the ability to load the target project component and the target project component existing in the cache resource; in response to the target project component not existing in the cache resource, pull the target project component from the target component library of the source warehouse and return the target project component to the application project.
17. An electronic device comprising a processor and a memory, characterized in that: A computer program instruction set is stored in the memory, and when the processor executes the computer program instruction set in the memory, the component splitting processing method of the application project described in any one of claims 1 to 6 is implemented, or the component docking processing method of the application project described in claim 7 or 8 is implemented, or the component loading processing method of the application project described in any one of claims 9 to 13 is implemented.
18. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program instruction set, which, when executed by a processor, implements the component splitting processing method of the application project described in any one of claims 1 to 6, or implements the component docking processing method of the application project described in claim 7 or 8, or implements the component loading processing method of the application project described in any one of claims 9 to 13.
19. A computer program product, comprising a computer program instruction set, which, when executed by a processor, implements the component splitting processing method of the application project described in any one of claims 1 to 6, or implements the component docking processing method of the application project described in claim 7 or 8, or implements the component loading processing method of the application project described in any one of claims 9 to 13.
Citation Information
Patent Citations
Component splitting method and device, electronic equipment and readable storage medium
CN114860250A
Project subpackaging method and system
CN117608640A
Method and device for splitting software project
CN118626141A
Using graph partitioning for software decomposition during modernization processes
US11422797B1
Automated application partitioning system
US20190079756A1
