Code packaging method and device, project execution method and device, medium and equipment
By sharing target modules and modifying packaging tools in different operating environments, the problem of repetitive work in cross-platform development is solved, cross-platform code sharing and function synchronization are achieved, and development efficiency and consistency are improved.
Patent Information
- Application Number
- CN202311631037.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-30
- Publication Date
- 2026-02-06
AI Technical Summary
In existing technologies, the same application requires the development of different projects in different operating environments, which leads to developers having to do repetitive work and low efficiency.
By acquiring information about the target module and modifying the packaging tool, the same code can be called in different runtime environments, thus enabling cross-platform code sharing and packaging using module federation technology.
It reduces repetitive work for developers, improves development efficiency, and achieves cross-platform functionality synchronization and consistency through centralized updates.
Smart Images

Figure CN121478271A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of software development technology, and in particular to a code packaging, project execution method, apparatus, medium and device. Background Technology
[0002] In the existing technology, the same application (such as a shopping application) is run on a mobile phone and a computer as two different application packages (hereinafter referred to as two application projects), namely: application A on the mobile phone and application B on the computer. Both applications can provide the same service to users.
[0003] This means that developers need to develop different application projects for different runtime environments, but in reality, the only difference between these different application projects is the runtime environment, and the services they provide are the same.
[0004] This development approach, which requires organizing multiple sets of code to run the same service in different operating environments, is quite troublesome for developers. Summary of the Invention
[0005] To overcome the problems existing in related technologies, this specification provides a code packaging, project execution method, apparatus, medium, and device.
[0006] According to a first aspect of the embodiments of this specification, a code packaging method is provided, the method comprising:
[0007] Obtain information to configure a target module for a first project; the target module is also configured in a second project, the first project and the second project are used to provide the same service to users in different operating environments, the first project and the second project execute the same code through the target module, the code is used to implement at least part of the service;
[0008] A first packaging tool is obtained, and its configuration is partially modified to obtain a target packaging tool. The first packaging tool is used to package the target module and the second project, so that the packaged second project can call the packaged target module. The modification is matched with the running environment of the first project, so that the packaged first project can successfully call the packaged target module.
[0009] The target packaging tool is invoked to package the first project, resulting in the packaged first project.
[0010] According to a second aspect of the embodiments of this specification, a project execution method is provided, the method comprising:
[0011] In response to a service instruction received by the mobile terminal, a target module is invoked through a pre-configured application programming interface; the service instruction is generated when the user operates a first item in the mobile terminal, and the service instruction is used to instruct the first item to provide a target service, which is executed by a target module configured in the first item.
[0012] Receive execution information fed back by the target module;
[0013] The execution information is output on the mobile terminal.
[0014] According to a third aspect of the embodiments of this specification, a code packaging apparatus is provided, the apparatus comprising:
[0015] A configuration unit is used to obtain information for configuring a target module for a first project; the target module is also configured in a second project, the first project and the second project are used to provide the same service to users in different operating environments, the first project and the second project execute the same code through the target module, the code is used to implement at least part of the service;
[0016] The modification unit is used to obtain a first packaging tool and partially modify the configuration of the first packaging tool to obtain a target packaging tool; the first packaging tool is a tool used to package the target module and the second project, so that the packaged second project can call the packaged target module, and the modification is matched with the running environment of the first project, so that the packaged first project can successfully call the packaged target module;
[0017] The first calling unit is used to call the target packaging tool to package the first project to obtain the packaged first project.
[0018] According to a third aspect of the embodiments of this specification, a project execution apparatus is provided, the apparatus comprising:
[0019] The second invocation unit is used to invoke the target module through a pre-configured application programming interface in response to the mobile terminal receiving a service instruction; the service instruction is generated when the user operates the first item in the mobile terminal, and the service instruction is used to instruct the first item to provide the target service, and the target service is executed by the target module configured in the first item.
[0020] A receiving unit is used to receive execution information fed back by the target module;
[0021] An output unit is used to output the execution information to the mobile terminal.
[0022] According to a fifth aspect of the embodiments of this specification, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the methods described in the embodiments provided in the first aspect.
[0023] According to a sixth aspect of the embodiments of this specification, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor; wherein the processor is configured to perform steps of the method as described in any of the embodiments provided in the first aspect.
[0024] The technical solutions provided in the embodiments of this specification may include the following beneficial effects:
[0025] In the embodiments of this specification, a target module is configured in the first project. Since the target module is also configured in the second project, both the first and second projects can execute the same code through the target module. This way, it is only necessary to edit and update the code in the target module, without having to edit the corresponding code in the first and second projects separately, which helps to reduce repetitive work for developers.
[0026] Furthermore, since the first and second projects operate in different environments, their packaging tools are typically different as well. If the first packaging tool, which is matched to the second project, is directly used to package the first project, the packaged first project may be unable to call the target module. Therefore, the first packaging tool can be modified accordingly to obtain the target packaging tool.
[0027] In this way, since the first and second projects are packaged using the same packaging tool (only the configurations are different), the two packaged projects are usually able to call the same target module, and there will be no situation where the first project cannot call the target module while the second project can.
[0028] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0029] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this specification and, together with the description, serve to explain the principles of this specification.
[0030] Figure 1 A flowchart of a code packaging method provided in an embodiment of this specification is shown.
[0031] Figure 2 The diagram illustrates an application scenario of a code packaging method provided in an embodiment of this specification.
[0032] Figure 3 This diagram illustrates an application scenario of a project execution method provided in an embodiment of this specification.
[0033] Figure 4 A schematic diagram of a code packaging device provided in an embodiment of this specification is shown.
[0034] Figure 5 A schematic diagram of the structure of a project execution device provided in an embodiment of this specification is shown.
[0035] Figure 6 This specification is a hardware structure diagram of a computer device in which an apparatus is located, according to an exemplary embodiment. Detailed Implementation
[0036] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification as detailed in the appended claims.
[0037] The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0038] It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0039] In the existing technology, the same application (such as a shopping application) is run on a mobile phone and a computer as two different application packages (hereinafter referred to as two application projects), namely: application A on the mobile phone and application B on the computer. Both applications can provide the same service to users.
[0040] This means that developers need to develop different application projects for different runtime environments, but in reality, the only difference between these different application projects is the runtime environment, and the services they provide are the same.
[0041] This development approach, which requires organizing multiple sets of code to run the same service in different operating environments, is quite troublesome for developers.
[0042] This application provides a solution that can solve the above problems. Before going into detail, let's first introduce the prerequisites for applying the following method:
[0043] 1. Two application projects are used to provide the same service to users in different operating environments, such as the mobile version of the reading software and the web version of the reading software.
[0044] 2. Two application projects share at least some of the same service functionalities, which can be provided by the same code. For example, the web application uses React (a JavaScript library for building user interfaces), primarily used for building web applications by rendering the user interface in the browser. The mobile application uses React Native (RN, an open-source framework based on React), primarily used for building native mobile applications. In this case, the shared parts of the RN code in the mobile application project and the React code in the web application project can be considered as common code.
[0045] Under this premise, a detailed explanation will be provided:
[0046] Figure 1 A flowchart of a code packaging method provided in an embodiment of this specification is shown, such as... Figure 1 As shown, the method includes the following steps:
[0047] Step 101: Obtain information on configuring a target module for the first project; the target module is also configured in the second project, the first project and the second project are used to provide the same service to users in different operating environments, the first project and the second project execute the same code through the target module, the code is used to implement at least part of the service.
[0048] The target module can be manually configured by the user, or it can be automatically configured into the first project after the target module is packaged and the first project is selected. When the first project is detected to have a target module configured, the information for configuring the target module for the first project is determined.
[0049] The first and second projects operate in different environments, mainly because they run on different platforms.
[0050] The following explanation uses the example of the first project running on a mobile terminal platform (equipped with a mobile operating system) and the second project running on a terminal equipped with a web platform (usually equipped with a computer operating system):
[0051] For example, the first project might be used to run on mobile devices, including smartphones, tablets, and other portable devices, which may run operating systems such as Android or iOS.
[0052] The second project may be used to run on terminals such as personal computers, servers, workstations, and embedded systems. Common computer operating systems include Windows, Linux, and macOS. The Web platform is an internet-based software system used to build, deploy, and run web applications. It provides a suite of tools, frameworks, and technologies that enable developers to create and publish various types of web applications, such as websites, e-commerce platforms, and social media applications.
[0053] In this way, when the first and second projects need to provide at least part of the service, there is no need to edit the code in the first or second project; the first or second project can simply execute the code in the target module.
[0054] Step 102: Obtain a first packaging tool and partially modify its configuration to obtain a target packaging tool. The first packaging tool is used to package the target module and the second project, so that the packaged second project can call the packaged target module. The modification matches the operating environment of the first project, so that the packaged first project can successfully call the packaged target module.
[0055] The first packaging tool is compatible with the runtime environment of the second project, so that the packaged second project obtained by calling the first packaging tool can directly call the packaged target module.
[0056] The following example illustrates this:
[0057] The first packaging tool is Webpack5, a static resource bundler; the second packaged project is a web project to be run on a web platform; the target module is a module federation; and the first packaged project runs on a mobile terminal platform.
[0058] Webpack 5 (the 5th generation static resource bundler, a static module bundler for modern JavaScript applications) is primarily used to process front-end resource files, such as JavaScript, stylesheets, and images, and bundle these files into static resources according to their dependencies for use in the browser. Module Federation is a new feature provided by Webpack 5 that allows modules to be shared between different static resource bundler builds.
[0059] Therefore, it can be seen that when the second project is a web project applied to the web platform and the target module is a module federation, the first packaging tool is matched with the second project. The packaged second project obtained by directly packaging the second project with the first packaging tool can directly call the packaged module federation.
[0060] However, since the first project and the second project have different runtime environments (or runtime platforms), if the first project is directly bundled using Webpack 5, the bundled first project will not be able to directly call the bundled module federation.
[0061] Therefore, the Webpack 5 configuration needs to be modified appropriately according to the runtime environment of the first project, and the modified Webpack 5 should be used as the target bundling tool.
[0062] Step 103: Call the target packaging tool to package the first project to obtain the packaged first project.
[0063] Based on the foregoing, the target bundling tool is compatible with the runtime environment of the first project. Therefore, after the modified Webpack 5 bundles the first project, the bundled first project can successfully call the bundled target module.
[0064] By configuring the target module in the first project, and since the target module is also configured in the second project, both the first and second projects can execute the same code through the target module. This way, the code only needs to be edited and updated in the target module, without having to edit the corresponding code in the first and second projects separately, which helps reduce repetitive work for developers.
[0065] Furthermore, since the first and second projects operate in different environments, their packaging tools are typically different as well. If the first packaging tool, which is matched to the second project, is directly used to package the first project, the packaged first project may be unable to call the target module. Therefore, the first packaging tool needs to be modified accordingly to obtain the target packaging tool.
[0066] In this way, since the first and second projects are packaged using the same packaging tool (only the configurations are different), the two packaged projects are usually able to call the same target module, and there will be no situation where the first project cannot call the target module while the second project can.
[0067] Optionally, when performing step 102 to obtain the first packaging tool and partially modifying its configuration to obtain the target packaging tool, the following steps are included:
[0068] Obtain a first packaging tool, modify the first packaging tool, and obtain the target packaging tool.
[0069] The modification includes at least: setting a method for calling the target application programming interface in the first packaging tool, so that the first project packaged by the target packaging tool can call the packaged target module through the application programming interface; the target application programming interface is compatible with the running platform of the first project.
[0070] The following example illustrates how Metro (a JavaScript module bundler primarily used for packaging React Native applications) is used as the second packaging tool for packaging the first project. When Metro is used to package the first project, the packaged first project will call the API (Application Programming Interface) configured by React Native, but will not call the Web API, and therefore cannot directly call the module federation.
[0071] Therefore, when the primary bundling tool is Webpack 5, it's necessary to configure the API call methods within Webpack 5 to match the runtime environment of the first project. For example, when the first project is applied to an Android mobile terminal (running the Android operating system), the `catalystInstance.loadScriptFromAssets` method (a React Native method used to load and run JavaScript files from a specified directory; this method is primarily used to load the application's main business logic or the definition of React Native components into the React Native environment for execution; it's a way to customize the loading of JS files) can be configured to load specified scripts (such as scripts in the target module). When the first project is applied to an iOS mobile terminal (running the iOS operating system), the `executeApplicationScript` method (a core React Native method primarily responsible for starting the specific business logic of the React Native application) can be configured to load specified scripts (such as scripts in the target module).
[0072] In addition, the modifications may also include:
[0073] Obtain a second packaging tool for packaging the first project; obtain the target script in the second packaging tool; the first packaging tool is compatible with the target script; configure the target script into the first packaging tool.
[0074] For example, Metro scripts can be automatically retrieved, such as Polyfill scripts, which are scripts used to fill in differences in browser compatibility support for new standards or APIs.
[0075] Then, the Polyfill script (a compatibility script) is automatically configured into the first packaging tool, which can better complete the packaging of the first project without having to rewrite it in the first packaging tool.
[0076] Using the above method, the first packaging tool can be modified to be a target packaging tool that can successfully package the first project and enable the packaged first project to successfully execute the target module (federated module).
[0077] It should be noted that since the first and second projects will run in different operating environments (platforms), the parameters or content in the target module can be modified to be general or compatible to successfully support multiple operating environments and provide better user service.
[0078] Furthermore, the features of the federated module allow the first and second projects to be updated in real time with the latest functionality the next time a user visits (by directly executing the latest code in the federated module), without the need to modify or redeploy the first or second project.
[0079] This feature is extremely convenient for developers, allowing them to update and improve without service interruption. This means they can deliver new features and fix known issues to users much faster. Furthermore, because updates are performed through a centralized, federated module, all projects are updated simultaneously, avoiding version control issues and ensuring all users have the same functionality and experience. Finally, this approach significantly reduces development and maintenance costs, as changes only need to be made in one place, rather than requiring separate modifications and releases on each individual project.
[0080] For example, if the first and second projects share a common search function, then during the module federation bundling process, the Webpack 5 official plugin ModuleFederationPlugin (used to implement the concept of module federation. It allows developers to split applications into independent modules and dynamically load these modules at runtime. Through this plugin, modules can be shared and communication and integration between modules can be achieved) can be generated to produce a common JavaScript code block that exposes a search method for use by both the first and second projects. A key point here is that ModuleFederationPlugin needs to be modified to ensure that the generated common JavaScript code block is compatible with the loading methods of React Native on both web and mobile devices. On the web, the default method is used to load and execute the code in the module federation. On mobile devices, the process is synchronized with the above: on Android, the code in the module federation is executed using the `catalystInstance.loadScriptFromAssets` method, and on iOS, the code in the module federation is executed using the `executeApplicationScript` method.
[0081] Figure 2 This specification illustrates an application scenario diagram of a code packaging method provided in an embodiment, such as... Figure 2 As shown, the first and second projects are each configured with module federation, as detailed below:
[0082] Step 201: The module federation first bundles the module federation using webpack5.
[0083] Step 202, Configure Module Federation: Configure module federation for the first project. After this, bundle the first project using the aforementioned method (using a modified webpack 5 for bundling).
[0084] Step 203, Configure Module Federation: Configure module federation for the second project. After this, package the second project according to the aforementioned method.
[0085] Step 204: The user accesses the first project (e.g., project A running on the mobile terminal) and generates a service instruction.
[0086] In step 205, the first project will request the module federated execution service.
[0087] Step 206: The module federation returns execution information.
[0088] Step 207: The first project outputs execution information via the mobile terminal.
[0089] Step 208: The user accesses the second project (e.g., project B on the web platform) and generates a service instruction.
[0090] In step 209, the second project will request the module federated execution service.
[0091] Step 210: The module federation returns execution information.
[0092] Step 211: The second project outputs execution information through the web platform.
[0093] The relevant content of steps 201-211 above has been described in the foregoing embodiments and will not be repeated here.
[0094] Figure 3 This specification illustrates an application scenario diagram of a project execution method provided in an embodiment, such as... Figure 3 As shown, the method includes the following steps:
[0095] Step 301: In response to the mobile terminal receiving a service instruction, the target module is invoked through a pre-configured application programming interface; the service instruction is generated when the user operates the first item in the mobile terminal, and the service instruction is used to instruct the first item to provide the target service, which is executed by the target module configured in the first item.
[0096] This method is applied to mobile terminals, where users execute the first item.
[0097] For example, after a user installs the first packaged item onto their mobile device, they can interact with the first item on the mobile device. If the first item is a shopping app, the user can open the first item to browse shopping products and place orders.
[0098] Suppose the service instruction is that the user requests to view the product details of product B, and the service of viewing the product details of product B is provided by the target module (similarly, when the user wants to view the product details of product B on the web, this service is also provided by the target module).
[0099] At this point, the target module can be called through a pre-configured application interface (such as the catalystInstance.loadScriptFromAssets method mentioned above on the Android side), and the corresponding execution information will be returned.
[0100] The execution information includes playback information for product details of product B, such as visual display and audio playback.
[0101] Step 302: Receive the execution information fed back by the target module.
[0102] Step 303: Output the execution information on the mobile terminal.
[0103] Figure 4 A schematic diagram of a code packaging device provided in an embodiment of this specification is shown. Figure 4 As shown, the device includes:
[0104] Configuration unit 401 is used to obtain information for configuring a target module for a first project; the target module is also configured in a second project, the first project and the second project are used to provide the same service to users in different operating environments, the first project and the second project execute the same code through the target module, the code is used to implement at least part of the service.
[0105] Modification unit 402 is used to obtain a first packaging tool and partially modify the configuration of the first packaging tool to obtain a target packaging tool; the first packaging tool is a tool used to package the target module and the second project, so that the packaged second project can call the packaged target module, and the modification is matched with the running environment of the first project, so that the packaged first project can successfully call the packaged target module.
[0106] The first calling unit 403 is used to call the target packaging tool to package the first project to obtain the packaged first project.
[0107] Optionally, the packaging tool is the static resource bundler Webpack5, the packaged second project is a Web project to be run on the Web platform, and the target module is a module federation.
[0108] Optionally, the packaged first project runs on a mobile terminal platform.
[0109] Optionally, when the modification unit 402 is used to obtain the first packaging tool and partially modify the configuration of the first packaging tool to obtain the target packaging tool, it is used to:
[0110] Obtain the first packaging tool.
[0111] The first packaging tool is modified to obtain the target packaging tool; the modification includes at least:
[0112] The first packaging tool is configured to call the target application programming interface (API). The first project, after being packaged by the target packaging tool, can call the packaged target module through the API. The target API is compatible with the operating platform of the first project.
[0113] Optionally, the modification unit 402, during modification, is further configured to:
[0114] Obtain a second packaging tool for packaging the first project.
[0115] Obtain the target script from the second packaging tool; the first packaging tool is compatible with the target script.
[0116] Configure the target script into the first packaging tool.
[0117] Figure 5 This specification shows a schematic diagram of a project execution device according to an embodiment, the device comprising:
[0118] The second invocation unit 501 is used to invoke the target module through a pre-configured application programming interface in response to the mobile terminal receiving a service instruction; the service instruction is generated when the user operates the first item in the mobile terminal, and the service instruction is used to instruct the first item to provide the target service, which is executed by the target module configured in the first item.
[0119] The receiving unit 502 is used to receive the execution information fed back by the target module.
[0120] The output unit 503 is used to output the execution information on the mobile terminal.
[0121] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0122] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0123] Figure 6 A hardware structure diagram of a computer device is shown, which may include: a processor 601, a memory 602, an input / output interface 603, a communication interface 604, and a bus 605. The processor 601, memory 602, input / output interface 603, and communication interface 604 are interconnected internally via the bus 605.
[0124] The processor 601 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the steps of the methods provided in the embodiments of this specification.
[0125] The memory 602 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 602 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 602 and is called and executed by the processor 601.
[0126] The input / output interface 603 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.
[0127] Communication interface 604 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0128] Bus 605 includes a pathway for transmitting information between various components of the device (e.g., processor 601, memory 602, input / output interface 603, and communication interface 604).
[0129] It should be noted that although the above-described device only shows the processor 601, memory 602, input / output interface 603, communication interface 604, and bus 605, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.
[0130] This specification also provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of any of the methods described in this specification.
[0131] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0132] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0133] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
Claims
1. A code packaging method, characterized in that, include: Obtain information to configure the target module for the first project; The target module is also configured in a second project. The first project and the second project are used to provide the same service to users in different operating environments. The first project and the second project execute the same code through the target module. The code is used to implement at least part of the service. A first packaging tool is obtained, and its configuration is partially modified to obtain a target packaging tool. The first packaging tool is used to package the target module and the second project, so that the packaged second project can call the packaged target module. The modification is matched with the running environment of the first project, so that the packaged first project can successfully call the packaged target module. The target packaging tool is invoked to package the first project, resulting in the packaged first project.
2. The method according to claim 1, characterized in that, The first packaging tool is Webpack5, a static resource bundler; the second packaged project is a Web project to be run on a Web platform; and the target module is a module federation.
3. The method according to claim 2, characterized in that, The first packaged item runs on a mobile terminal platform.
4. The method according to any one of claims 1-3, characterized in that, The step of obtaining a first packaging tool and partially modifying its configuration to obtain a target packaging tool includes: Obtain the first packaging tool; The first packaging tool is modified to obtain the target packaging tool; the modification includes at least: The first packaging tool is configured to call the target application programming interface (API). The first project, after being packaged by the target packaging tool, can call the packaged target module through the API. The target API is compatible with the operating platform of the first project.
5. The method according to claim 4, characterized in that, The modifications also include: Obtain a second packaging tool for packaging the first project; Obtain the target script from the second packaging tool; the first packaging tool is compatible with the target script. Configure the target script into the first packaging tool.
6. A project execution method, characterized in that, The method includes: In response to a service instruction received by the mobile terminal, a target module is invoked through a pre-configured application programming interface; the service instruction is generated when the user operates a first item in the mobile terminal, and the service instruction is used to instruct the first item to provide a target service, which is executed by a target module configured in the first item. Receive execution information fed back by the target module; The execution information is output on the mobile terminal.
7. A code packaging device, characterized in that, The device includes: A configuration unit is used to obtain information for configuring a target module for a first project; the target module is also configured in a second project, the first project and the second project are used to provide the same service to users in different operating environments, the first project and the second project execute the same code through the target module, the code is used to implement at least part of the service; The modification unit is used to obtain a first packaging tool and partially modify the configuration of the first packaging tool to obtain a target packaging tool; the first packaging tool is a tool used to package the target module and the second project, so that the packaged second project can call the packaged target module; the modification is matched with the running environment of the first project, so that the packaged first project can successfully call the packaged target module; The first calling unit is used to call the target packaging tool to package the first project to obtain the packaged first project.
8. A project execution device, characterized in that, The device includes: The second invocation unit is used to invoke the target module through a pre-configured application programming interface in response to the mobile terminal receiving a service instruction; the service instruction is generated when the user operates the first item in the mobile terminal, and the service instruction is used to instruct the first item to provide the target service, and the target service is executed by the target module configured in the first item. A receiving unit is used to receive execution information fed back by the target module; An output unit is used to output the execution information to the mobile terminal.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it implements the steps of the method according to any one of claims 1-6.
10. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method according to any one of claims 1-6.