Component packaging method and device, electronic equipment and storage medium
By generating full package artifacts and single package artifacts through component packaging methods, the problem of not being able to load components individually in existing technologies is solved, enabling on-demand loading of components and full loading of the component library, thereby improving loading speed and response performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU SHIYUAN ELECTRONICS CO LTD
- Filing Date
- 2024-10-28
- Publication Date
- 2026-04-28
AI Technical Summary
Existing component packaging methods cannot load individual components, cannot adapt to the needs of different scenarios, and result in unnecessary network transmission burden and performance impact during resource loading.
The entire package and single package products are generated in one packaging process. The component library, components and material files are packaged in parallel using configuration information to generate diverse products. The description files are integrated to support on-demand loading of components and full loading of the component library.
It improves loading speed and response performance, reduces unnecessary overhead in resource loading, simplifies developer operations, and enhances loading efficiency and flexibility.
Smart Images

Figure CN121934876A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a component packaging method and apparatus, electronic device and storage medium. Background Technology
[0002] Component packaging refers to combining one or more components and their related resources (such as styles, images, and other dependencies) into one or more usable files. This typically involves integrating and optimizing the component's source code, stylesheets, and related resource files for use in an application. In front-end development, component packaging usually refers to using code compilation tools to package the component's source code and related resources into one or more final artifact files, which can be used to run in a browser or application.
[0003] Currently, when packaging components, the entire component library is usually integrated and packaged into a single artifact. However, this packaging method can only load all components in full and cannot load a single component individually, making it unsuitable for scenarios that require a single component. Summary of the Invention
[0004] This application provides a component packaging method and apparatus, electronic device and storage medium. The product obtained by the packaging method provided by this application can fully load all components or load a single component during loading, which can improve the scope of applicable scenarios.
[0005] In a first aspect, embodiments of this application provide a component packaging method, which includes: obtaining configuration information of a component library to be packaged, the configuration information including the component library, multiple components in the component library, and material files corresponding to the components; packaging the component library, each component, and each material file in parallel based on the configuration information to obtain a complete package product corresponding to the component library, a single package product corresponding to each component, a material package product corresponding to each material file, a first description file corresponding to the complete package product, a second description file corresponding to each single package product, and a third description file corresponding to each material package product; uploading the complete package product, each single package product, and each material package product to a cloud server; integrating the first description file, each second description file, and each third description file into a fourth description file; and uploading the fourth description file to the cloud server.
[0006] In this embodiment, a single packaging process can simultaneously produce diverse products, including single-package products for each component and full-package products for the entire component library. Subsequent component loading not only satisfies on-demand component loading but also full-package loading of the entire component library, meeting various loading requirements. This allows for dynamic loading of required components based on actual needs, avoiding unnecessary resource loading and thus improving loading speed and response performance. Furthermore, in existing technologies, different types of products typically have their own independent description files, which may be stored in different directories or paths. Developers need to consult multiple scattered description files individually to understand the information of the full-package product or a single-package product of a specific component, increasing operational complexity and time costs. In this embodiment, however, by integrating the scattered description files into a comprehensive fourth description file, which clearly presents detailed information about all component products, users only need to consult the fourth description file to understand the detailed information of each packaged product when loading resources. The fourth description file allows for direct and rapid acquisition of the packaged products of a single component or the entire component library, improving loading efficiency.
[0007] In some embodiments, the step of parallel packaging the component library, each component, and each material file based on the configuration information to obtain the complete package product corresponding to the component library, the single package product corresponding to each component, the material package product corresponding to each material file, and the first description file corresponding to the complete package product, the second description file corresponding to each single package product, and the third description file corresponding to each material package product includes: obtaining the folder of the component library based on the configuration information; analyzing all files in the folder to obtain the material file corresponding to each component; analyzing the material file corresponding to each component to obtain the first entry file of the component library, the first entry file corresponding to each component, and the third description file corresponding to each material package product. The second entry file is used; based on the first entry file, a first compilation instance corresponding to the component library is generated; based on the second entry file, a second compilation instance corresponding to each component is generated; based on the file path of each material file, a third compilation instance corresponding to each material file is generated; the first compilation instance, each of the second compilation instances, and each of the third compilation instances are executed in parallel to obtain the complete package product, each of the single package products, and each of the material package products, wherein the first description file is generated when the complete package product is generated, the corresponding second description file is generated when the single package product is generated, and the corresponding third description file is generated when the material package product is generated.
[0008] In this embodiment, the component library structure is automatically obtained by configuring information, which can reduce the workload of manual configuration, reduce the possibility of human error, improve the reliability of the packaging process, and increase the packaging speed by performing various packaging tasks at the same time.
[0009] In some embodiments, analyzing the material files corresponding to each component to obtain a first entry file of the component library and a second entry file corresponding to each component includes: analyzing the material files corresponding to each component to obtain the first entry file corresponding to different versions of the component library and the second entry file corresponding to different versions of each component.
[0010] In this embodiment, by analyzing the material files, different versions of the component library and all components are packaged. Subsequently, the corresponding version of the packaged product can be loaded as needed, or all versions of the packaged product can be loaded, so that the system can more flexibly adapt to different usage scenarios and needs.
[0011] In some embodiments, the component method further includes: analyzing the second entry file to obtain the dependency projects corresponding to each component; and packaging the dependency projects corresponding to each component to obtain the dependency package artifacts corresponding to each component.
[0012] In this embodiment, by packaging dependent projects to generate dependency package artifacts, the corresponding dependency package artifacts can be loaded when loading a single component or component library, ensuring that the component can be loaded normally.
[0013] In some embodiments, packaging the dependency projects corresponding to each component to obtain the dependency package artifacts corresponding to each component includes: analyzing the dependency projects corresponding to each component to obtain at least one common dependency project, wherein the common dependency project is the dependency project that at least two components depend on; packaging one of the common dependency projects into a dependency package artifact, and adding the information of the corresponding dependency package artifact to the second description file of the component corresponding to the common dependency project.
[0014] In this embodiment, by identifying and packaging common dependency projects as separate dependency package artifacts, duplicate dependency package artifacts can be avoided in the package artifacts of multiple components, thereby reducing the size of the final package artifact.
[0015] In some embodiments, obtaining the configuration information of the component library to be packaged includes: obtaining preset first configuration sub-information and user-input second configuration sub-information; integrating the first configuration sub-information and the second configuration sub-information to obtain the configuration information.
[0016] In this embodiment, by separating the general first configuration sub-information and the custom second configuration sub-information, and integrating the two to obtain complete configuration information, firstly, the configuration information of the component library is reusable, allowing developers to share and reuse the same general configuration information across different projects, reducing repetitive work and improving development efficiency and quality; secondly, it allows users to customize the input of the second configuration sub-information according to the specific needs of the project, enabling the configuration information to be personalized according to the user's specific needs, thereby better adapting to different project requirements and improving the applicability and flexibility of the packaging tool.
[0017] In a second aspect, embodiments of this application provide an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method as described in any one of the first aspects.
[0018] In this embodiment, the electronic device can produce a variety of products simultaneously through a single packaging process. When loading components subsequently, it can not only satisfy the on-demand loading of components, but also the full loading of the component library, thus meeting different loading requirements.
[0019] Thirdly, embodiments of this application also provide a component packaging device. An acquisition device is configured to acquire configuration information of a component library to be packaged, the configuration information including the component library, multiple components in the component library, and material files corresponding to the components. The packaging device is configured to package the component library, each component, and each material file in parallel based on the configuration information, obtaining a complete package product corresponding to the component library, a single package product corresponding to each component, a material package product corresponding to each material file, a first description file corresponding to the complete package product, a second description file corresponding to each single package product, and a third description file corresponding to each material package product. The first description file, each second description file, and each third description file are then integrated into a fourth description file. A first uploading device is configured to upload the complete package product, each single package product, and each material package product to a cloud server. A second uploading device is configured to upload the fourth description file to the cloud server.
[0020] In this embodiment, the component packaging device can produce a variety of products simultaneously through a single packaging process. When loading components subsequently, it can not only satisfy the on-demand loading of components, but also the full loading of the component library, thus meeting different loading requirements.
[0021] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method described in the first aspect above.
[0022] Fifthly, embodiments of this application also provide a computer program product, the computer program product including a computer program stored on a computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the method described in the first aspect above. Attached Figure Description
[0023] One or more embodiments are illustrated by way of example with reference to the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements / modules and steps with the same reference numerals in the drawings are represented as similar elements / modules and steps. Unless otherwise stated, the figures in the drawings do not constitute a limitation on scale.
[0024] Figure 1 This is a flowchart of a component packaging method provided in an embodiment of this application;
[0025] Figure 2 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0026] The present application will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present application, but do not limit the present application in any way. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application. These all fall within the protection scope of the present application.
[0027] To facilitate understanding of this application, a more detailed description is provided below with reference to the accompanying drawings and specific embodiments. Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.
[0028] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram, in some cases, they can be divided differently from those in the device. In addition, the terms "first" and "second" used herein do not limit the data or execution order, but only distinguish between identical or similar items with essentially the same function and effect.
[0029] There are several current methods for packaging components. The first method integrates all components into a single web application package, loading it along with the page. However, this packaging mechanism has a drawback: packaging all components into a single file means that even components that may not be used on the current page will still be loaded, undoubtedly increasing unnecessary network transmission burden and affecting page loading speed and overall performance. The second method is to independently encapsulate components as npm packages. While this method achieves modularity and allows on-demand loading, it still has limitations. Specifically, when attempting to load only a specific component, the npm package management mechanism often cannot precisely control this, resulting in loading not only the component but also all its common dependencies, which may exceed actual needs. Furthermore, it does not support more flexible lazy loading strategies, limiting further performance optimization. The third approach is to package the components and deploy them to a cloud server, then dynamically load them in the web application by referencing cloud resources. While this approach offers flexibility, its implementation is currently polarized: either it adopts a full-package strategy, requiring users to download all components every time they visit, resulting in resource waste; or it only supports on-demand packaging and loading of a single component, making it difficult to meet the complex scenarios that require loading multiple components simultaneously, thus limiting its wide applicability under different application needs.
[0030] To address the aforementioned technical issues, embodiments of this application provide a component packaging method and apparatus, an electronic device, and a storage medium. A single packaging process can simultaneously produce diverse products, including single-package products for each component and full-package products for the entire component library. Subsequent component loading not only satisfies on-demand component loading but also full loading of the component library, meeting various loading requirements. This allows for dynamic loading of required components based on actual needs, avoiding unnecessary resource loading and significantly improving loading speed and response performance.
[0031] In a first aspect, embodiments of this application provide a component packaging method, which can be applied to electronic devices, see [reference]. Figure 1 The component packaging method includes:
[0032] Step S100: Obtain the configuration information of the component library to be packaged. The configuration information includes the component library, multiple components in the component library, and the material files corresponding to the components.
[0033] In a configurable page environment, a component is an independent, reusable unit that constitutes the basic structure of these pages. These components typically have well-defined functions and interfaces, can be placed in different locations on the page, and can be configured to adapt to different layout and style requirements.
[0034] A material file is a configuration file for a corresponding component. It describes the configuration data of the component's detailed information, including the component name, entry file, and request definitions. The component name is the name of the corresponding component, used to uniquely identify it within the system, facilitating search and reference by developers and administrators. The component's entry file is the entry file, and the request definitions describe how the component interacts with external data sources, including but not limited to the data source location, request format, parameter names, and types. Through the request definitions in the material file, the component can flexibly request and receive external data, enabling dynamic data updates and display.
[0035] The component library is a collection of multiple components and the corresponding material files for each component.
[0036] The configuration information includes the file address of the component library to be packaged, the configuration information of the name of the packaged artifact corresponding to the component, the configuration information of the external dependencies corresponding to the component, the splitting rules, and other configuration information. Specifically, the electronic device can obtain the configuration information through user input.
[0037] Step S200: Based on the configuration information, package the component library, each component, and each material file in parallel to obtain the complete package product corresponding to the component library, the single package product corresponding to each component, the material package product corresponding to each material file, as well as the first description file corresponding to the complete package product, the second description file corresponding to each single package product, and the third description file corresponding to each material package product.
[0038] The output refers to the files or data packages generated through the packaging process.
[0039] A complete package artifact refers to the artifact obtained by packaging the entire component library, its components, and all material files as a whole, based on the configuration information of the entire component library. The complete package artifact contains all the content of the component library, forming a complete, deployable software package. The first description file is a file that describes the detailed information and configuration of the complete package artifact. The first description file may contain the name of the complete package artifact, version information, a list of dependent files, and any other possible deployment or configuration instructions.
[0040] A single-package artifact refers to the artifact obtained by packaging each component separately based on the configuration information of each independent component in the component library. Each single-package artifact contains a complete and independent component, including the component's code, resource files, dependency files, and necessary configuration files (but excluding the content of other components). The second description file is a file that describes the detailed information and configuration of the corresponding single-package artifact. The second description file may contain the name of the corresponding single-package artifact, version information, a list of dependency files, and any other possible deployment or configuration instructions.
[0041] A material package artifact refers to the artifact obtained by packaging each material file individually based on its configuration information in the component library. While the material files themselves may not contain executable code or complete component logic, they do contain component configuration, dependency declarations, or other information crucial to component operation. A third-party description file, on the other hand, describes the detailed information of the corresponding material package artifact. This description file can specify the material file's type, content, purpose, and any other relevant information.
[0042] It is understandable that if the component library includes M components, then the number of generated complete package products and the number of first description files is 1, the number of single package products, the number of second description files, the number of material package products and the number of third description files are M, where M is an integer greater than or equal to 2.
[0043] In this step, after obtaining the configuration information of the component library, i.e., the entire component library file, the electronic device can use a packaging tool to analyze the entire component library file. This yields the packaging configuration of the component library, the packaging configuration of each component, and the packaging configuration of each material file. Then, based on the packaging configurations of the component library, each component, and each material file, packaging tasks are performed simultaneously: packaging the component library, packaging each component, and packaging each material file. This results in the overall package output, each individual package output, and each material package output. Furthermore, upon completion of packaging the component library, a first description file, each second description file, and each third description file are generated. The packaging tool can be a static module bundler for modern JavaScript applications, i.e., Webpack. In practice, other suitable packaging tools can also be used to execute the packaging process.
[0044] Step S300: Upload the entire package of products, each individual package of products, and each material package of products to the cloud server.
[0045] After packaging is complete, each packaged product is uploaded to the cloud server, so that all packaged products can be centrally managed in one place. When users load them later, they can simply load the resources from the cloud server.
[0046] Step S400: Integrate the first description file, each of the second description files, and each of the third description files into a fourth description file.
[0047] Step S500: Upload the fourth description file to the cloud server.
[0048] Specifically, the first description file, each of the second description files, and each of the third description files can be temporary files. After packaging, these description files can be integrated into a total description file, i.e., the fourth description file, according to the preset rules in the configuration information. After integration is complete and the fourth description file is successfully uploaded to the cloud server, the first description file, each of the second description files, and each of the third description files can be deleted. The preset rules in the configuration information can be the arrangement rules of each description file, etc.
[0049] In this embodiment, a variety of products can be produced simultaneously through a single packaging process, including single-package products corresponding to each component and full-package products corresponding to the entire component library. When loading components subsequently, not only can the on-demand loading of components be satisfied, but also the full loading of the component library can be satisfied, which can meet different loading requirements. In this way, the required components can be dynamically loaded according to actual needs, avoiding unnecessary resource loading, thereby significantly improving loading speed and response performance.
[0050] Furthermore, in existing technologies, different types of products typically have their own independent description files, which may be stored in different directories or paths. When developers want to understand the information of the entire package product or a single package product of a specific component, they need to consult multiple scattered description files one by one, which increases the complexity and time cost of the operation. However, in this embodiment, by integrating the scattered description files into a comprehensive description file, since the fourth description file is a complete JSON file, it includes files describing the detailed information and configuration of the entire package product, files describing the detailed information and configuration of all single package products, and files describing the detailed information of all material package products. When loading resources, users only need to consult the fourth description file to understand the information of the entire component library. Moreover, through the fourth description file, the packaged products of a single component or all components can be obtained directly and quickly, which facilitates users to consult information, reduces operation and time costs, and improves loading efficiency and accuracy.
[0051] In some embodiments, step S200 may include the following steps:
[0052] Step S210: Based on the configuration information, obtain the folder of the component library.
[0053] The component library folder is the folder that contains all the files in the component library, including folders corresponding to multiple components. After obtaining the configuration information, the component library folder can be analyzed from it.
[0054] Step S220: Analyze all files in the folder to obtain the material files corresponding to each component.
[0055] The component library contains folders corresponding to multiple components. Each component's folder contains a material file, which follows a specific naming convention, such as a uniform config.ts file. Therefore, by traversing and analyzing all files in the component library's folders, all config.ts files can be found, thus obtaining the material file corresponding to each component.
[0056] Step S230: Analyze the material files corresponding to each component to obtain the first entry file of the component library and the second entry file corresponding to each component.
[0057] The first entry file refers to the file that marks the starting point for the component library's startup and operation, while the second entry file refers to the file that marks the starting point for the corresponding component's startup and operation.
[0058] After obtaining the material files for each component, the material files can be analyzed to obtain the first entry file of the component library and the second entry file corresponding to each component, which means obtaining the packaging entry configuration of the component library and the packaging entry configuration of all components.
[0059] Step S240: Based on the first entry file, generate the first compilation instance corresponding to the component library. Step S250: Based on the second entry file, generate the second compilation instance corresponding to each component. Step S260: Based on the file paths of each material file, generate the third compilation instance corresponding to each material file.
[0060] The first compilation instance refers to all the compilation parameters required to compile the entire component library. The packaging tool can use the first compilation instance to package the entire component library. The second compilation instance refers to all the compilation parameters required to compile the corresponding component. The packaging tool can use the second compilation instance to package the corresponding component. The third compilation instance refers to all the compilation parameters required to compile the corresponding material file. The packaging tool can use the third compilation instance to package the corresponding material file.
[0061] Understandably, after obtaining the material file corresponding to each component, which is also the file path corresponding to each material file, this file path is configured as the entry file for each material file. Therefore, in this step, processing the packaging entry configuration (first entry file) for the component library, the packaging entry configuration (second entry file) for each component, and the file path for each material file respectively generates the corresponding compilation instance.
[0062] In some embodiments, if the configuration information also includes configuration information from the packaging process, the above steps further include generating a first compilation instance corresponding to the component library based on the first entry file and configuration information of the component library; generating a second compilation instance corresponding to each component based on the second entry file and configuration information of each component; and generating a third compilation instance corresponding to each material file based on the file path and configuration information of each material file. The specific generation process can be found in existing technologies and is not limited here.
[0063] Step S270: Execute the first compilation instance, each of the second compilation instances, and each of the third compilation instances in parallel to obtain the complete package product, each of the single package products, and each of the material package products. Specifically, when generating the complete package product, a first description file is generated; when generating the single package product, a corresponding second description file is generated; and when generating the material package product, a corresponding third description file is generated.
[0064] After obtaining each compilation instance, the first compilation instance can be used as the first packaging task, each second compilation instance as a second packaging task, and each third compilation instance as a third packaging task. Parallel execution of the first, second, and third compilation instances means simultaneously executing the first, second, and third packaging tasks, thus improving packaging speed. Furthermore, upon completion of the first packaging task (i.e., after generating the entire package artifact), a first description file is generated. Upon completion of one second compilation instance in the second packaging task (i.e., after generating a single package artifact), a second description file for the corresponding component is generated. Upon completion of one third compilation instance in the third packaging task (i.e., after generating a material package artifact), a third description file for the corresponding material file is generated. This allows the completion status of the packaging task to be confirmed based on the generation status of the description files, and subsequent processes can be executed upon completion.
[0065] In this embodiment, the component library structure is automatically obtained by configuring information, which can reduce the workload of manual configuration, reduce the possibility of human error, improve the reliability of the packaging process, and increase the packaging speed by performing various packaging tasks at the same time.
[0066] In some embodiments, step S230 may include the following steps: Step S231: Analyze the material files corresponding to each component to obtain the first entry file corresponding to different versions of the component library and the second entry file corresponding to each component in different versions.
[0067] Specifically, the component library has render, edit, and preview versions, and the components also have render, edit, and preview versions.
[0068] For a component, its folder contains not only a material file but also component files for different versions. For example, for component A, the folder for component A contains the material file for component A, the file for component A in its rendered state, the file for component A in its edit state, and the file for component A in its preview state. The locations of the component files for different versions can be stored in the material file for component A, that is, the locations of the files for component A in its rendered state, edit state, and preview state. Then, by analyzing the material file, the entry files for all different versions of the component can be obtained. After finding the entry files for all different versions of the component, the entry files for different versions of the component library are obtained. Subsequently, the component library and all components can be packaged according to these entry files. The first packaged product contains the packaged products for different versions of the component library, and the second packaged product contains the packaged products for different versions of the corresponding component.
[0069] In this embodiment, by analyzing the material files, different versions of component libraries and all components are packaged. Subsequently, the corresponding version of the packaged product can be loaded as needed, or all versions of the packaged product can be loaded, so that the system can more flexibly adapt to different usage scenarios and needs. For example, in the editing page, the corresponding edit-state component or component library can be loaded without loading the other versions of components or component libraries, thus improving the loading flexibility.
[0070] In some embodiments, the component method further includes the following steps: Step S500: Analyze the second entry file to obtain the dependency projects corresponding to each component. Step S600: Package the dependency projects corresponding to each component to obtain the dependency package artifacts corresponding to each component.
[0071] A dependency is another component or library that a component needs to rely on in order to function properly or provide specific functionality. Dependencies can provide necessary support, services or functions to a component, enabling the component to achieve its design goals.
[0072] Specifically, the component's dependencies can be obtained by parsing the component's package.json file, yarn.lock file, or other dependency management files. After obtaining the dependencies for each component, a packaging tool can be used to package these dependencies according to the configured rules to obtain the dependency package artifacts for each component. After these dependency package artifacts are generated, they can be integrated into the single package artifacts of the corresponding component so that the dependency package can be loaded directly when the component is loaded.
[0073] In this embodiment, by packaging dependent projects to generate dependency package artifacts, the corresponding dependency package artifacts can be loaded when loading a single component or component library, ensuring that the component can be loaded normally.
[0074] In some embodiments, step S600 may include the following steps: Step S610: Analyze the dependency items corresponding to each component to obtain at least one common dependency item, wherein the common dependency item is a dependency item that at least two components depend on.
[0075] Different components may depend on the same external library or project; these projects that multiple components commonly depend on are called common dependencies. By comparing the dependencies of each component, at least one common dependency can be identified.
[0076] Step S620: Package a public dependency project into a dependency package artifact, and add the corresponding dependency package artifact information to the second description file of the component corresponding to the public dependency project.
[0077] Specifically, after obtaining the common dependency project C of components A and B, the common dependency project C can be packaged into a dependency package artifact, independent of the single package artifacts of components A and B. Both the second description files of components A and B describe that the components depend on the common dependency project C at runtime. Thus, after packaging, users can intuitively know from the second description files of either component A or component B that the dependency package artifact of the common dependency project C needs to be loaded first. Therefore, when users subsequently need to load components A or B, the dependency package artifact of the common dependency project C will be loaded first, followed by the single package artifacts of components A or B, thereby improving the loading speed of components A or B.
[0078] In this embodiment, by identifying and packaging common dependency projects as separate dependency package artifacts, duplicate dependency package artifacts can be avoided in the package artifacts of multiple components, thereby reducing the size of the final package artifact.
[0079] In some embodiments, step S100 may include the following steps:
[0080] Step S110: Obtain the preset first configuration sub-information and the second configuration sub-information input by the user.
[0081] The first configuration sub-information refers to some general configuration information pre-selected within the bundling tools of electronic devices. This may include Babel compilation configuration, Loader configuration, Webpack plugin configuration, etc. Babel is a widely used JavaScript compiler that can convert newer versions of JavaScript code into backward-compatible versions so that they can run in older browsers or environments. Babel compilation configuration refers to settings specific to Babel, specifying the transformation rules, plugins, and presets to use, as well as the target environment for the transformation. These configurations allow developers to customize the behavior of code transformation to meet specific project needs. In Webpack, Loaders are used to transform different types of files during the bundling process, such as converting Sass files to CSS or ES6 code to ES5. Loader configuration refers to specifying the loaders and related configurations for different file types in the Webpack configuration. Through Loader configuration, developers can define how different file types are processed, including which transformation tools to use and how to handle file dependencies. Webpack plugin configuration refers to specifying the plugins to use and their related configurations in the Webpack configuration, such as specifying plugins to optimize the size of dependent package artifacts. Through plugin configuration, developers can have finer-grained control and customization of the bundling process to meet specific project needs.
[0082] The second configuration sub-information refers to the configuration information determined based on user input. This sub-information can include the component's entry directory, the global mount name when referencing the packaged component library, and other configuration information. The component's entry directory refers to the entry folder of the entire component library. The global mount name when referencing the packaged component library refers to the name under which the component is mounted in the global namespace; this name determines the identifier used when referencing the component. The second configuration sub-information may also include Babel compilation configuration, Loader configuration, Webpack plugin configuration, and other configuration information.
[0083] Step S120: Integrate the first configuration sub-information and the second configuration sub-information to obtain configuration information.
[0084] Once the electronic device receives the first and second configuration sub-information, it merges the information to obtain the final configuration information. During this merging process, it intelligently resolves and prioritizes any potential conflicts between the two sub-information sets to ensure successful integration and the desired configuration. For example, if the user specifies a particular Babel compilation configuration in the second configuration sub-information, the system will check for conflicts with the Babel compilation configuration in the first configuration sub-information, such as differences in target environment version, plugins used, or presets. Based on these differences, the system determines the final Babel compilation configuration, ensuring that user-defined configuration information is integrated into the final compilation configuration without affecting the smooth progress of the overall packaging process.
[0085] In this embodiment, by separating the general first configuration sub-information and the custom second configuration sub-information, and integrating the two to obtain complete configuration information, firstly, the configuration information of the component library is reusable, allowing developers to share and reuse the same general configuration information across different projects, reducing repetitive work and improving development efficiency and quality; secondly, it allows users to customize the input of the second configuration sub-information according to the specific needs of the project, enabling the configuration information to be personalized according to the user's specific needs, thereby better adapting to different project requirements and improving the applicability and flexibility of the packaging tool.
[0086] Secondly, this application provides an electronic device, Figure 2 This illustrates a hardware structure of the electronic device 100. Please refer to... Figure 2 The electronic device 100 includes a processor 10, a memory 20, and a communication interface 30. The processor 10, memory 20, and communication interface 30 are connected by lines. Figure 2 In the illustrated embodiment, the processor 10, memory 20, and communication interface 30 are interconnected via a bus. The memory 20 stores instructions executable by the processor 10, which, when executed, enables the processor 10 to perform the component packaging method as described in any embodiment of this application.
[0087] The memory 20 is used to store software programs, computer-executable program instructions, etc. The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the electronic device 100, etc.
[0088] The memory 20 can be a read-only memory (ROM), or other types of static storage devices that can store static information and instructions, or random access memory (RAM), or other types of dynamic storage devices that can store information and instructions, or electrically erasable programmable read-only memory (EEPROM), and the specific type is not limited here.
[0089] For example, the aforementioned memory 20 can be a double-data-rate synchronous dynamic random access memory (DRAM). This memory 20 can exist independently but is connected to the processor 10. Optionally, the memory 20 can also be integrated with the processor 10, for example, integrated within one or more chips.
[0090] In some embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and this remote memory may be connected to the electronic device 100 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0091] The processor 10 connects various parts of the electronic device 100 using various interfaces and lines. By running or executing software programs stored in the memory 20 and calling data stored in the memory 20, it performs various functions of the electronic device 100 and processes data, such as implementing the methods described in any embodiment of this application.
[0092] The processor 10 can be a field programmable gate array (FPGA), a digital signal processor (DSP), a central processing unit (CPU), or the like.
[0093] Processor 10 can be a single-core processor or a multi-core processor. For example, processor 10 can be composed of multiple FPGAs or multiple DSPs. Furthermore, processor 10 can refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions). Processor 10 can be a standalone semiconductor chip or integrated with other circuits into a single semiconductor chip. For example, it can form a system-on-a-chip (SoC) with other circuits (such as codec circuits, hardware acceleration circuits, or various bus and interface circuits), or it can be integrated as a built-in processor within an application-specific integrated circuit (ASIC). This ASIC with integrated processor can be packaged separately or together with other circuits.
[0094] The communication interface 30 can use a transceiver device, such as a transceiver, to enable communication between the electronic device 100 and other devices or communication networks.
[0095] The electronic device 100 described above can execute the method provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in this embodiment can be found in the method provided in the embodiments of this application.
[0096] Thirdly, embodiments of this application provide a component packaging apparatus, including an acquisition device, a packaging device, a first uploading device, and a second uploading device. The acquisition device is configured to acquire configuration information of a component library to be packaged, the configuration information including the component library, multiple components in the component library, and material files corresponding to the components. The packaging device is configured to package the component library, each component, and each material file in parallel based on the configuration information, obtaining a complete package product corresponding to the component library, a single package product corresponding to each component, a material package product corresponding to each material file, a first description file corresponding to the complete package product, a second description file corresponding to each single package product, and a third description file corresponding to each material package product, and integrating the first description file, each second description file, and each third description file into a fourth description file. The first uploading device is configured to upload the complete package product, each single package product, and each material package product to a cloud server. The second uploading device is configured to upload the fourth description file to the cloud server.
[0097] In this embodiment, the component packaging device can produce a variety of products simultaneously through a single packaging process. When loading components subsequently, it can not only satisfy the on-demand loading of components, but also the full loading of the component library, thus meeting different loading requirements.
[0098] In some embodiments, the packaging device is specifically configured to: obtain a folder of the component library based on configuration information; analyze all files in the folder to obtain material files corresponding to each component; analyze the material files corresponding to each component to obtain a first entry file of the component library and a second entry file corresponding to each component; generate a first compilation instance corresponding to the component library based on the first entry file; generate a second compilation instance corresponding to each component based on the second entry file; generate a third compilation instance corresponding to each material file based on the file path of each material file; and execute the first compilation instance, each second compilation instance, and each third compilation instance in parallel to obtain a complete package product, each single package product, and each material package product. Specifically, a first description file is generated when generating a complete package product, a corresponding second description file is generated when generating a single package product, and a corresponding third description file is generated when generating a material package product.
[0099] In some embodiments, the packaging device is further configured to analyze the material files corresponding to each component to obtain a first entry file corresponding to different versions of the component library and a second entry file corresponding to each component in different versions.
[0100] In some embodiments, the packaging device is further configured to analyze the second entry file to obtain the dependency items corresponding to each component; and to package the dependency items corresponding to each component to obtain the dependency package artifact corresponding to each component.
[0101] In some embodiments, the packaging device is further configured to analyze the dependency items corresponding to each component to obtain at least one common dependency item, wherein the common dependency item is a dependency item that at least two components depend on; package a common dependency item into a dependency package artifact, and add the information of the corresponding dependency package artifact to the second description file of the component corresponding to the common dependency item.
[0102] In some embodiments, the acquisition device is specifically configured to acquire preset first configuration sub-information and user-input second configuration sub-information; and to integrate the first configuration sub-information and the second configuration sub-information to obtain configuration information.
[0103] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions for causing an electronic device to execute the component packaging method provided in embodiments of this application.
[0104] In some embodiments, the storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0105] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0106] As an example, executable instructions may, but do not necessarily, correspond to files in the file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborative files (e.g., a file that stores one or more modules, subroutines, or code sections).
[0107] As an example, executable instructions can be deployed to execute on a single computing device (including devices such as smart terminals and servers), or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0108] Fifthly, embodiments of this application also provide a computer program product, the computer program product including a computer program stored on a computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the component packaging method as described in the foregoing embodiments.
[0109] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0110] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general-purpose hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for at least one computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments.
[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A component packaging method, characterized in that, include: Obtain the configuration information of the component library to be packaged, the configuration information including the component library, multiple components in the component library, and the material file corresponding to the component; Based on the configuration information, the component library, each component, and each material file are packaged in parallel to obtain the complete package product corresponding to the component library, the single package product corresponding to each component, the material package product corresponding to each material file, and the first description file corresponding to the complete package product, the second description file corresponding to each single package product, and the third description file corresponding to each material package product. Upload the complete package product, each of the individual package products, and each of the material package products to the cloud server; The first description file, each of the second description files, and each of the third description files are integrated into a fourth description file; The fourth description file is uploaded to the cloud server.
2. The component packaging method according to claim 1, characterized in that, The step of parallel packaging the component library, each component, and each material file based on the configuration information to obtain the complete package product corresponding to the component library, the single package product corresponding to each component, the material package product corresponding to each material file, and the first description file corresponding to the complete package product, the second description file corresponding to each single package product, and the third description file corresponding to each material package product includes: Based on the configuration information, the folder of the component library is obtained; Analyze all files in the folder to obtain the material files corresponding to each component; By analyzing the material files corresponding to each component, the first entry file of the component library and the second entry file corresponding to each component are obtained. Based on the first entry file, a first compilation instance corresponding to the component library is generated; Based on the second entry file, generate a second compilation instance corresponding to each component; Based on the file paths of each material file, a third compilation instance corresponding to each material file is generated; The first compilation instance, each of the second compilation instances, and each of the third compilation instances are executed in parallel to obtain the complete package product, each of the single package products, and each of the material package products. The first description file is generated when the complete package product is generated, the corresponding second description file is generated when the single package product is generated, and the corresponding third description file is generated when the material package product is generated.
3. The component packaging method according to claim 2, characterized in that, The analysis of the material files corresponding to each component yields a first entry file for the component library and a second entry file corresponding to each component, including: By analyzing the material files corresponding to each component, the first entry file corresponding to different versions of the component library and the second entry file corresponding to each component in different versions are obtained.
4. The component packaging method according to any one of claims 2-3, characterized in that, The component method also includes: Analyze the second entry file to obtain the dependency projects corresponding to each component; The dependency projects corresponding to each component are packaged to obtain the dependency package products corresponding to each component.
5. The component packaging method according to claim 4, characterized in that, The step of packaging the dependency projects corresponding to each component to obtain the dependency package product corresponding to each component includes: Analyze the dependency items corresponding to each component to obtain at least one common dependency item, wherein the common dependency item is the dependency item that at least two components depend on. Package a public dependency project into a dependency package artifact, and add the information of the corresponding dependency package artifact to the second description file of the component corresponding to the public dependency project.
6. The component packaging method according to claim 1, characterized in that, The process of obtaining the configuration information of the component library to be packaged includes: Obtain the preset first configuration sub-information and the second configuration sub-information input by the user; The configuration information is obtained by integrating the first configuration sub-information and the second configuration sub-information.
7. An electronic device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method as described in any one of claims 1 to 6.
8. A component packaging device, characterized in that, The acquisition device is configured to acquire configuration information of a component library to be packaged, the configuration information including the component library, multiple components in the component library, and material files corresponding to the components; The packaging device is configured to package the component library, each component, and each material file in parallel based on the configuration information, to obtain a whole package product corresponding to the component library, a single package product corresponding to each component, a material package product corresponding to each material file, a first description file corresponding to the whole package product, a second description file corresponding to each single package product, and a third description file corresponding to each material package product. The first uploading device is configured to upload the whole package product, each of the single package products, and each of the material package products to the cloud server. The packaging device is further configured to integrate the first description file, each of the second description files and each of the third description files into a fourth description file; The second uploading device is configured to upload the fourth description file to the cloud server.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the method as described in any one of claims 1 to 6.