JavaScript module packaging method, system and device based on artificial intelligence and medium

Through artificial intelligence-based methods, automated configuration and optimization of JavaScript module packaging, the problem of long construction time, complex configuration and insufficient security in large-scale projects is solved, and efficient and secure module management and optimization are achieved, improving the efficiency and security of module management and optimization. Development efficiency and performance.

CN119088380AInactive Publication Date: 2024-12-06GUANGZHOU YINGFENG NETWORK TECH CO LTD

Patent Information

Application Number
CN202411234501.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-04
Publication Date
2024-12-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional JavaScript module packers have problems such as long construction time, cumbersome configuration parameters and insufficient security in large-scale projects, which affect development efficiency and application performance.

Method used

Using an artificial intelligence-based approach, a configuration file is generated through natural language processing, a module dependency graph is established, a dynamic programming optimization algorithm is used to split the code, predict resource requirements, and a combination of static code analysis and dynamic testing is used to ensure security and compatibility.

Benefits of technology

It significantly improves development efficiency and product performance, reduces manual errors in automated configuration, optimizes code redundancy and resource utilization, comprehensively detects and fixes security vulnerabilities, and ensures the stability of applications in different environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088380A_ABST
    Figure CN119088380A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, in particular to a JavaScript module packaging method, system and device based on artificial intelligence and a medium, and the method specifically comprises the steps that according to a configuration file, a module dependency graph is established by analyzing the dependency relationship among multiple JavaScript modules of a development project, and the packaging sequence of the multiple JavaScript modules is determined according to the module dependency graph; based on the module dependency graph, performing module granularity division on each JavaScript module through a dynamic programming optimization algorithm, and determining a code splitting scheme of each JavaScript module; according to the historical access data and the current load condition of each JavaScript module, determining the resource demand quantity of each JavaScript module by adopting a resource demand prediction algorithm; and according to the packaging sequence, the code splitting scheme and the resource demand quantity, a plurality of JavaScript modules are packaged, and a JavaScript code package is generated. According to the method, intelligent management and optimization of the JavaScript module are realized, powerful support is provided for development of large complex projects, and the development efficiency and the product performance are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an artificial intelligence-based JavaScript module packaging method, system, device and medium. Background Art

[0002] In the field of front-end development, JavaScript module bundlers are indispensable tools for building modern web applications. As web applications become increasingly complex, the number and dependencies of JavaScript modules have increased dramatically, which has put forward higher requirements for the performance, flexibility and security of module bundlers. Although traditional bundlers, such as Webpack and Rollup, have solved the problem of module bundling to a certain extent, they still face many challenges when facing large-scale projects, as follows:

[0003] 1. Traditional packagers often take a long time to parse, compile and package JavaScript modules during the build process, which seriously affects development efficiency. Especially in the development stage, frequent code modifications and repackaging will consume a lot of time and reduce the developer experience.

[0004] 2. As the scale of the project expands, the configuration parameters and dependencies of JavaScript modules become complex and diverse. Traditional packagers often require developers to manually configure these parameters, which is not only cumbersome but also prone to errors. In addition, the optimization and adjustment of configuration parameters also rely on the experience and intuition of developers, making it difficult to achieve the best results.

[0005] 3. As the security threats faced by Web applications continue to increase, the security of JavaScript code packages has become a focus of developers. Traditional packagers often have deficiencies in security analysis and it is difficult to fully detect and repair security vulnerabilities in the code. Summary of the invention

[0006] The purpose of the present invention is to provide an artificial intelligence-based JavaScript module packaging method, system, device and medium, which realizes the intelligent management and optimization of JavaScript modules, provides strong support for the development of large and complex projects, significantly improves development efficiency and product performance, and solves at least one of the above-mentioned prior art problems.

[0007] In a first aspect, the present invention provides a JavaScript module packaging method based on artificial intelligence, the method specifically comprising:

[0008] Acquire development project information, analyze the development project information through natural language processing technology, and generate a configuration file;

[0009] According to the configuration file, a module dependency graph is established by analyzing the dependency relationship between multiple JavaScript modules of the development project, and a packaging order of the multiple JavaScript modules is determined according to the module dependency graph;

[0010] Based on the module dependency graph, each JavaScript module is divided into module granularity by a dynamic programming optimization algorithm to determine a code splitting scheme for each JavaScript module;

[0011] According to the historical access data and current load of each JavaScript module, a resource demand prediction algorithm is used to determine the resource demand of each JavaScript module;

[0012] According to the packaging order, the code splitting scheme and the resource demand, multiple JavaScript modules are packaged to generate a JavaScript code package;

[0013] Performing a security analysis on the JavaScript code package to determine whether the JavaScript code package has a security vulnerability;

[0014] Acquire multiple third-party libraries, build different operation simulation environments according to the multiple third-party libraries, and perform compatibility tests on the JavaScript code package through the different operation simulation environments.

[0015] In a second aspect, the present invention provides a JavaScript module packaging system based on artificial intelligence, the system specifically comprising:

[0016] A first packaging module is used to obtain development project information, analyze the development project information through natural language processing technology, and generate a configuration file;

[0017] A second packaging module is used to establish a module dependency graph by analyzing the dependency relationship between multiple JavaScript modules of the development project according to the configuration file, and determine the packaging order of the multiple JavaScript modules according to the module dependency graph;

[0018] A third packaging module is used to divide each JavaScript module into module granularity based on the module dependency graph by a dynamic programming optimization algorithm, and determine a code splitting scheme for each JavaScript module;

[0019] The fourth packaging module is used to determine the resource demand of each JavaScript module by using a resource demand prediction algorithm according to the historical access data and current load of each JavaScript module;

[0020] A fifth packaging module, used to package multiple JavaScript modules according to the packaging order, the code splitting scheme and the resource demand, and generate a JavaScript code package;

[0021] A sixth packaging module, used to perform security analysis on the JavaScript code package to determine whether the JavaScript code package has a security vulnerability;

[0022] The seventh packaging module is used to obtain multiple third-party libraries, build different running simulation environments according to the multiple third-party libraries, and perform compatibility testing on the JavaScript code package through different running simulation environments.

[0023] In a third aspect, the present invention provides a computer device comprising: a memory and a processor and a computer program stored in the memory, and when the computer program is executed on the processor, it implements the artificial intelligence-based JavaScript module packaging method as described in any one of the above methods.

[0024] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the artificial intelligence-based JavaScript module packaging method as described in any one of the above methods is implemented.

[0025] Compared with the prior art, the present invention has at least one of the following technical effects:

[0026] 1. It realizes intelligent management and optimization of JavaScript modules, provides strong support for the development of large and complex projects, and significantly improves development efficiency and product performance.

[0027] 2. Analyze development project information through natural language processing technology and automatically generate configuration files, reducing the tediousness and errors of manual configuration. At the same time, the dynamic programming optimization algorithm is used to divide the module granularity to achieve automatic optimization and adjustment of configuration parameters.

[0028] 3. According to the module dependency graph and resource demand prediction algorithm, the optimal packaging order and code splitting scheme are determined, which effectively reduces code redundancy and resource waste, and improves the loading speed and running performance of the application.

[0029] 4. Through the combination of static code analysis and dynamic testing, security vulnerabilities in JavaScript code packages are comprehensively detected and repaired, improving the security of the application.

[0030] 5. Build different running simulation environments to perform compatibility tests on JavaScript code packages to ensure the stability and performance of the application in different environments. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0032] Figure 1 It is a flowchart of a JavaScript module packaging method based on artificial intelligence provided by one embodiment of the present invention;

[0033] Figure 2 It is a structural diagram of a JavaScript module packaging system based on artificial intelligence provided by an embodiment of the present invention;

[0034] Figure 3 It is a structural schematic diagram of a computer device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0035] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0036] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0037] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0038] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0039] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0040] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0041] In the embodiment of the present application, the execution subject of the process includes a terminal device, which includes but is not limited to: a server, a computer, a smart phone, a tablet computer, and other devices capable of executing the method disclosed in the present application. Figure 1 A flowchart of a JavaScript module packaging method based on artificial intelligence disclosed in an embodiment of the present invention is shown, and the details are as follows:

[0042] S101, acquiring development project information, analyzing the development project information by natural language processing technology, and generating a configuration file.

[0043] In this embodiment, in JavaScript development projects, configuration files (such as webpack.config.js, package.json, etc.) play a vital role. They define key information such as project construction, dependency management, and operating environment. However, manually writing and updating these configuration files is tedious and error-prone. In order to simplify this process, natural language processing technology (NLP) is used to automatically analyze project information and generate corresponding configuration files.

[0044] Specifically, relevant information about JavaScript development projects is collected from multiple sources, including but not limited to project documents, source code comments, README files, Git commit records, etc. This information includes the project's dependent libraries, build tools, operating environment requirements, special configuration requirements, etc. The collected information is cleaned and preprocessed to remove irrelevant content, format text, extract key information, etc. Text information is converted into structured data using NLP technologies such as text segmentation, part-of-speech tagging, and named entity recognition. Features related to the configuration file are extracted from the preprocessed information, such as the name and version of the dependent library, build commands, environment variables, etc. These features will be used as input data for generating the configuration file.

[0045] Design a set of configuration file templates and rule engines to generate configuration files based on the extracted features. The template defines the basic structure and format of the configuration file, and the rule engine fills in the placeholders in the template based on the feature data. For example, for webpack.config.js, the template may contain placeholders for the entry file, output directory, loader, and plugin, and the rule engine fills in these placeholders based on the actual dependencies and configuration requirements of the project. Use template matching and rule engines to generate configuration files, perform syntax checking and format beautification on the generated configuration files to ensure that they comply with JavaScript syntax and coding standards.

[0046] In this embodiment, the automatic generation of configuration files reduces the workload of manually writing and updating configuration files, improves development efficiency, and reduces configuration errors caused by human negligence through precise matching of NLP technology and rule engines.

[0047] In some embodiments, in the above step S101, analyzing the development project information by natural language processing technology to generate a configuration file specifically includes:

[0048] Using natural language processing technology to perform semantic analysis on the development project information to obtain multiple configuration parameters, wherein the configuration parameters include name, data type, value range, default value and comment information;

[0049] Build a configuration parameter knowledge graph based on the associations and constraints between different configuration parameters;

[0050] A support vector machine algorithm is used to construct a configuration parameter recommendation model, and recommended values ​​of configuration parameters of the current development project are determined by the configuration parameter recommendation model;

[0051] A configuration file is formed according to the configuration parameter recommended values ​​and the configuration parameter knowledge graph.

[0052] In this embodiment, the text information of the development project is obtained, and the text is preprocessed, including word segmentation, part-of-speech tagging, named entity recognition, etc., to prepare for subsequent semantic analysis. For the preprocessed text information, a semantic analysis is performed using a combination of rule-based and machine learning methods to identify key information related to the configuration parameters, such as parameter name, data type, value range, default value, comments, etc. According to the semantic analysis results, the parameter name attribute is extracted to determine whether it complies with the naming specification, and the parameter name that does not comply with the specification is standardized. The data type attribute of the parameter is obtained and converted into a unified data type representation, such as string, integer, floating point, Boolean, etc., to ensure the standardization of the data type. The value range attribute of the parameter is extracted. For parameters of numerical type, it is determined whether its value is within a reasonable range, and the parameter value outside the range is handled abnormally; for parameters of enumeration type, all possible values ​​are obtained. The default value attribute of the parameter is obtained, and the default value is analyzed to determine whether it is within the value range. If it is not within the value range, it is set to the middle value of the value range or other reasonable values. Extract the annotation information of the parameters, extract keywords and understand the semantics of the annotation text, and automatically generate descriptions of the parameters to facilitate developers to understand and use configuration parameters.

[0053] Analyze the association between configuration parameters, and establish directed association edges between corresponding nodes based on the dependency, mutual exclusion, combination and other relationships between parameters. For the constraints of configuration parameters, extract the parameter nodes involved in the constraints, establish constraint association edges, and annotate the constraint types and conditional expressions. Use a graph database to store the constructed configuration parameter knowledge graph, and represent parameter knowledge through the structured representation of nodes, edges, attributes, etc. of the graph. According to user configuration requirements, perform graph search on the knowledge graph to obtain parameter subgraphs related to the requirements. Solve the constraints of the parameter subgraph, and judge the validity and consistency of the configuration parameters through constraint propagation and condition matching.

[0054] Obtain the historical configuration parameter data of the current development project, preprocess the data, and extract the feature vector. Use the grid search method to optimize the hyperparameters of the support vector machine algorithm, such as the kernel function type and penalty coefficient. Train the optimized support vector machine model to obtain the configuration parameter recommendation model. Extract the feature vector of the current development project. Input the extracted feature vector into the configuration parameter recommendation model. After the model is calculated, output the recommended value of the configuration parameter. Apply the recommended configuration parameter value to the current development project to optimize the project configuration.

[0055] The extracted configuration parameter information is matched with the recommended values ​​to obtain configuration parameters with a high degree of match; based on the matching results, the final configuration parameter values ​​are determined; the determined configuration parameter values ​​are filled into the preset configuration file template to generate an initial configuration file; the initial configuration file is checked and optimized using a rule-based method to determine whether there are conflicts or unreasonable parameter settings, and if so, adjustments are made to obtain an optimized configuration file; the optimized configuration file is further verified and improved through the expert knowledge base to form a final configuration file for guiding system operation.

[0056] S102, establishing a module dependency graph by analyzing the dependency relationship between multiple JavaScript modules of the development project according to the configuration file, and determining a packaging order of the multiple JavaScript modules according to the module dependency graph.

[0057] In this embodiment, in a JavaScript project, as the project scale expands, the dependencies between modules become complicated. In order to optimize the loading speed and execution efficiency of the project, it is usually necessary to package multiple JavaScript modules into one or more bundle files. Correctly determining the packaging order of the modules can ensure that the dependencies are correctly handled and avoid runtime errors.

[0058] Specifically, use tools (such as Webpack, Rollup, Parcel, etc.) or custom scripts to analyze JavaScript modules in the project, identify import and require statements, and build dependencies between modules. Based on the analyzed dependencies, build a module dependency graph, which is represented by a directed graph in graph theory, where nodes represent modules and directed edges represent dependencies between modules. Perform topological sorting on the module dependency graph to determine the order in which the modules should be packaged. Topological sorting is a sorting method for directed acyclic graphs (DAGs), which ensures that for any directed edge u->v, u appears before v in the sorting result. If there is a loop (i.e., circular dependency) in the dependency graph, you need to solve the loop problem first (such as by merging modules, refactoring code, etc.), and then perform topological sorting. Determine the order in which the modules should be packaged based on the results of topological sorting. Usually, the entry module (i.e., the module directly introduced by the HTML file) is placed at the beginning of the packaging order, and then other modules are added in sequence according to the results of topological sorting.

[0059] According to the determined packaging order, configure the entry, output and other options of the packaging tool (such as Webpack), and you can also configure optimization strategies such as Code Splitting and Lazy Loading to further improve the loading speed and performance of the project. Use the configured packaging tool to perform packaging operations and generate optimized bundle files.

[0060] In this embodiment, a reasonable packaging order is used to ensure that dependent modules have been loaded before they are needed, thereby reducing the loading time and the complexity of dependency resolution. Dependencies are correctly handled, avoiding runtime errors caused by incorrect module loading order. At the same time, automatic processing of module dependencies and packaging order reduces the burden on developers, allowing them to focus more on code development and maintenance.

[0061] In some embodiments, in the above step S102, establishing a module dependency graph by analyzing the dependency relationship between multiple JavaScript modules of the development project according to the configuration file, and determining the packaging order of multiple JavaScript modules according to the module dependency graph specifically includes:

[0062] Obtain dependency data between multiple JavaScript modules of the development project according to the configuration file, and construct a module dependency graph through the dependency data;

[0063] Grouping each JavaScript module in the module dependency graph by using a K-means clustering algorithm to obtain multiple JavaScript module groups;

[0064] Using the Kruskal minimum spanning tree algorithm to determine the dependency topology of multiple JavaScript modules in each JavaScript module group, and determining the packaging order of multiple JavaScript modules in each JavaScript module group according to the dependency topology;

[0065] By analyzing the dependencies between the various JavaScript module groups, the packaging order of multiple JavaScript module groups is determined.

[0066] In this embodiment, the configuration file of the development project is read and parsed to obtain the JavaScript module information and the dependency data between modules defined therein. According to the obtained module dependency data, a directed graph data structure is constructed as the internal representation of the module dependency graph. By traversing the module definitions in the configuration file, each module is used as a node in the dependency graph, and directed edges are established between the nodes according to the dependency relationship. The constructed module dependency graph is preprocessed to extract the feature vector of the node for subsequent clustering analysis. The feature vector may include indicators such as the code complexity and call frequency of the module. According to the preset cluster quantity parameter, the K-means clustering algorithm is used to cluster the feature vectors of the module nodes. During the clustering process, the cluster center is continuously iterated and optimized until the convergence condition is reached. For each module group obtained by clustering, the correlation between the modules in the group is analyzed. If the correlation of the modules in the group is high, the module group is retained; if the correlation is low, further subdivision or merging of the module group is considered. The clustering results of the module group are evaluated, and the clustering effect is measured by indicators such as the silhouette coefficient. If the clustering effect is not ideal, the clustering parameters are adjusted and the clustering grouping is performed again. According to the clustering results of the module groups, each module group is functionally divided and named. Combined with domain knowledge, the main functions implemented by each module group are determined and the corresponding functional labels are assigned. A report on the division results of the JavaScript module group is generated, including the member modules of each module group, the distinguishing features between groups, and the functional labels of the module group.

[0067] According to the established JavaScript module dependency graph, the Kruskal minimum spanning tree algorithm is used to determine the minimum dependency topology between multiple JavaScript modules in each JavaScript module group. For each JavaScript module group, multiple JavaScript modules inside it are obtained, and according to the minimum dependency topology of the module group obtained in the previous step, the depth-first search algorithm is used to determine the packaging order of each JavaScript module in the module group. If the dependency topology of a JavaScript module group is not connected, the module group is further split into multiple connected subgraphs, and each connected subgraph is used as an independent packaging unit to determine the packaging order of the JavaScript modules inside it. When determining the packaging order of JavaScript modules, for the case of circular dependencies, a topological sorting algorithm is used to determine whether there is a circular dependency. If so, an error is reported and the user is prompted to eliminate the circular dependency before packaging.

[0068] Get the information of all JavaScript module groups, including the module group name, the module files included, the dependencies between modules, etc. Construct a JavaScript module group dependency graph, and determine the dependencies between module groups by analyzing the reference relationships between modules in the module group. According to the module group dependency graph, a topological sorting algorithm is used to generate the initial packaging order of the module group. For the initial packaging order, factors such as the file size of the module group after packaging and the communication overhead between module groups are evaluated, and a packaging order evaluation model is constructed. Using a simulated annealing algorithm, with the packaging order evaluation model as the optimization target, the optimal packaging order is obtained by randomly exchanging the module group packaging order and iteratively optimizing. If the evaluation result of the current optimal packaging order is better than the preset threshold, the current packaging order is determined as the final JavaScript module group packaging order.

[0069] Exemplarily, firstly, the dependency data of each JavaScript module in the project is extracted according to the configuration file, and a module dependency graph is constructed. Each node in the dependency graph represents a module, and the directed edges between the nodes represent the dependency relationship between the modules. The weight of the edge can be expressed by the closeness of the dependency. For example, if module A depends on module B, a directed edge is connected from node A to B, and the weight is set to 1. Then, the K-means clustering algorithm is used to group the modules, and the number of clusters k is set to 5. By calculating the Euclidean distance between each module and the cluster center, the cluster center is iteratively optimized until the clustering result of the module is stable, and the module is finally divided into 5 groups. Then, the Kruskal minimum spanning tree algorithm is used in each module group to determine the topological dependency structure between modules. First, the dependency edges between all modules in the group are sorted from small to large according to the weight, and the edges with the smallest weight are selected in turn to be added to the spanning tree until all modules are connected and there is no loop. The packaging order of the modules in the group can be determined by the edges in the spanning tree. The module with an in-degree of 0 is packaged first, and then the modules it depends on are packaged, and so on. Finally, the dependencies between module groups are analyzed. If the modules in group A depend on the modules in group B, then A needs to be packaged after B. The packaging order between groups is determined by topological sorting. The group with out-degree 0 is packaged first, and then the group that depends on it is packaged. By combining the packaging order within and between module groups, the final packaging plan for the entire project module can be obtained, realizing automated packaging and deployment.

[0070] S103, based on the module dependency graph, divide each JavaScript module into module granularity by a dynamic programming optimization algorithm, and determine a code splitting scheme for each JavaScript module.

[0071] In this embodiment, in a large JavaScript project, in order to improve the loading speed and performance of the application, it is usually necessary to split the code into multiple smaller modules or chunks, which can be dynamically loaded according to the user's request or the state of the application. Module granularity partitioning and code splitting are key links in this process. Through the dynamic programming optimization algorithm, the splitting scheme of each module can be determined more intelligently to achieve the optimal loading performance and resource utilization.

[0072] Specifically, first, determine the optimization goal, such as minimizing the initial loading time, reducing repeated resource downloads, and improving cache efficiency. Then, convert the module dependency graph into a form suitable for dynamic programming. Each state can be represented as a collection of one or more modules, as well as the number and size of chunks into which these modules are split. According to the optimization goal, design the dynamic programming transfer equation. This equation needs to be able to calculate the impact on the optimization goal when transferring from one state to another (that is, adding or reducing a module to a chunk). Take into account the dependencies between modules and ensure that these dependencies are not destroyed during the splitting process.

[0073] Use a dynamic programming algorithm to traverse all possible states and record the optimal solution in each state. Ultimately, the algorithm will output one or more optimal splitting solutions that can maximize loading performance and resource utilization while satisfying dependencies. Configure the splitting strategy of the packaging tool (such as Webpack, Rollup, etc.) based on the splitting solution derived from the dynamic programming algorithm. Set options such as entry point, split point, lazy loading strategy, etc. to ensure that the packaging tool can generate the split code as expected. Use the configured packaging tool to perform packaging operations and generate the split code. Perform sufficient testing to ensure that the split code is functionally consistent with the original code and that loading performance is improved.

[0074] In this embodiment, for large projects containing a large number of modules and complex dependencies, the dynamic programming optimization algorithm can provide a more accurate and efficient splitting solution. Through intelligent module granularity division and code splitting, the amount of code that needs to be downloaded during initial loading can be reduced, thereby improving the loading speed of the application. A reasonable splitting solution can reduce repeated downloading of resources and cache waste, and improve resource utilization.

[0075] In some embodiments, in the above step S103, the module granularity division of each JavaScript module based on the module dependency graph is performed by a dynamic programming optimization algorithm, specifically including:

[0076] According to the module dependency graph, the total code volume, reuse degree and number of network requests of each JavaScript module are obtained;

[0077] The total amount of code after splitting each JavaScript module is used as the optimization objective function, and the dynamic programming optimization algorithm is used to divide each JavaScript module into module granularity;

[0078] In the process of dividing each JavaScript module into module granularity, the optimal split position and the total amount of code after splitting of each JavaScript module are recorded, and the split granularity and the number of splits are adjusted according to the reuse degree and the number of network requests of each JavaScript module.

[0079] In this embodiment, the dependency relationship between modules is analyzed through the module dependency graph to obtain the number of times each module is referenced by other modules. The internal code of each module is traversed, the number of code lines of the module is counted, and the total code volume of the module is obtained. When the module is running, the network requests initiated by the module are monitored, and the number of network requests of each module is counted. According to the number of references of the module, the reuse of the module is calculated, and the modules with high reuse can be considered for optimization or splitting.

[0080] Get the set of JavaScript modules to be split. For each module, use the dynamic programming algorithm and take the total amount of code after splitting as the optimization objective function to perform module granularity division. During the division process, record the optimal split position and the corresponding total amount of code after splitting for each module at different splitting granularities. According to the historical reuse of each module, use the weighted average algorithm to obtain the comprehensive reuse index of the module. According to the comprehensive reuse index of each module, use the classification algorithm to divide the module into two categories: high reuse modules and low reuse modules. For high reuse modules, appropriately reduce the split granularity and reduce the number of module splits; for low reuse modules, appropriately increase the split granularity and increase the number of module splits. According to the number of network requests for each module, use the clustering algorithm to divide the module into two categories: high request number modules and low request number modules. For high request number modules, appropriately increase the split granularity and reduce the number of network requests; for low request number modules, appropriately reduce the split granularity and increase the transmission volume of a single request.

[0081] Exemplarily, firstly, the number of lines of code of each JavaScript module, the number of times it is referenced by other modules, and the number of network requests initiated are counted according to the module dependency graph. For example, module A has 200 lines of code, which is referenced by other 5 modules and has 3 requests; module B has 150 lines of code, which is referenced by other 2 modules and has 1 request. Then, the total amount of code after the module split is minimized as the optimization goal, and the dynamic programming algorithm is used to divide the granularity of each module. Specifically, let dp represent the minimum amount of code to split the first i statements into j modules, then the state transition equation is: dp = min (dp, dp + cost), where cost represents the amount of code that constitutes a module from the k+1th to the ith statements. By filling the two-dimensional dp array, the optimal amount of code for each module at different split granularities can be obtained. At the same time, the split position of each module under the optimal division and the amount of code after splitting are recorded. Next, consider the impact of the module's reuse and the number of network requests on the split granularity, set an empirical threshold, and when the module's reuse exceeds 10, split it into 2-3 sub-modules with finer granularity; when the number of network requests for a module exceeds 5, split it into 3-4 sub-modules to reduce the number of requests. For example, module A is split at lines 50 and 120, and can be divided into 3 sub-modules, with code volumes of 50, 70, and 80, respectively, and the number of requests becomes 1. Module B, on the other hand, has a low reuse rate and can remain unsplit, with a code volume of 150. Finally, a split plan for each module is obtained, which minimizes the overall code volume of the project, while taking into account module reuse and request optimization, facilitating subsequent packaging and deployment.

[0082] S104, according to the historical access data and current load of each JavaScript module, a resource demand prediction algorithm is used to determine the resource demand of each JavaScript module.

[0083] In this embodiment, in a Web application, the resource requirements of the JavaScript module (such as CPU time, memory usage, network bandwidth, etc.) directly affect the user experience and application performance. In order to allocate and manage resources more efficiently, it is necessary to accurately predict the resource requirements of each JavaScript module, which can be achieved by analyzing the historical access data of the module and the current system load.

[0084] Specifically, collect the historical access data of each JavaScript module, including the number of visits, access time, access duration, resource consumption (such as CPU time, memory usage, network transmission volume), etc. At the same time, monitor the current system load, including CPU usage, memory usage, network bandwidth usage, etc. Clean and organize the collected historical access data to remove outliers and noise data. Convert the data into a form suitable for prediction model input, such as time series data, feature vectors, etc. Select a suitable prediction algorithm based on the characteristics of the problem and the nature of the data. Commonly used algorithms include time series analysis (such as ARIMA, LSTM), regression analysis, machine learning models (such as random forest, gradient boosting tree), etc. For the resource demand prediction of JavaScript modules, considering that resource usage may show periodic changes over time (such as user access peak hours) and is immediately affected by the current system load, a method combining time series analysis and machine learning is adopted.

[0085] Use historical access data as a training set to train the prediction model. During the training process, you may need to adjust the model parameters to optimize the prediction accuracy and generalization ability. Combine the current system load and the latest collected access data to use the trained model for real-time prediction. The prediction results will give the resource requirements of each JavaScript module in the future. According to the prediction results, formulate resource allocation and scheduling strategies. For example, when it is predicted that a module is about to usher in a peak in access, you can increase the resource quota of the server where it is located in advance, or deploy it to a server with a lower load.

[0086] In this embodiment, accurate resource demand forecasting can be used to more reasonably allocate and manage resources, avoiding resource waste and overload. Predicting the changing trend of resource demand in advance helps to take timely measures to deal with potential system load problems and enhance the stability and reliability of the system.

[0087] In some embodiments, in the above step S104, the resource demand amount of each JavaScript module is determined by using a resource demand prediction algorithm according to the historical access data and current load of each JavaScript module, specifically including:

[0088] Obtain historical access data and current load conditions of each JavaScript module, construct time series features based on the historical access data, and construct resource utilization features based on the current load conditions;

[0089] Based on the time series characteristics, a long short-term memory neural network is used for training to obtain a visit volume prediction model;

[0090] Based on the resource utilization characteristics, a support vector regression model is used for training to obtain a resource demand prediction model;

[0091] According to the output result of the access volume prediction model, the output result of the resource demand prediction model and the current system available resources, the optimal resource demand of each JavaScript module is determined by a multi-objective optimization algorithm.

[0092] In this embodiment, the historical access data of each JavaScript module is obtained, and a time series feature vector is constructed, which includes dimensions such as the number of visits and the time of visit. The current load of each JavaScript module is obtained, and a resource utilization feature vector is constructed, which includes dimensions such as CPU occupancy and memory occupancy. The time series feature vector is input into the long short-term memory neural network model for training, and the model parameters are adjusted so that the model can better fit the historical access data, thereby obtaining a visit volume prediction model. The resource utilization feature vector is input into the support vector regression model for training, and the model parameters are adjusted so that the model can better fit the current load situation, thereby obtaining a resource demand prediction model. According to the visit volume prediction model and the resource demand prediction model, the visit volume and resource demand of each JavaScript module in the future period of time are predicted.

[0093] According to the pre-established visit volume prediction model, the estimated visit volume of each JavaScript module in the future period is obtained; according to the pre-established resource demand prediction model, the resource demand of each JavaScript module under different visit volumes is obtained; the total available resources of the current system are obtained, including resource indicators such as CPU, memory, and bandwidth; the visit volume prediction results, resource demand prediction results, and current available resources are used as inputs of the multi-objective optimization algorithm to construct the optimization objective function and constraints; the genetic algorithm is used to solve the multi-objective optimization problem to obtain the optimal resource allocation plan for each JavaScript module to maximize the overall resource utilization of the system; it is determined whether the optimal resource allocation plan meets the minimum resource demand of each JavaScript module. If not, the weight coefficient in the optimization objective function is adjusted and the optimization algorithm is re-executed; the optimal resource allocation plan output by the multi-objective optimization algorithm is applied to the resource management module of the system, and the resource quota of each JavaScript module is dynamically adjusted to ensure the smooth operation of the system.

[0094] S105, packaging multiple JavaScript modules according to the packaging sequence, the code splitting scheme and the resource requirement to generate a JavaScript code package.

[0095] In this embodiment, the relevant parameters of the packaging tool (such as Webpack, Rollup, etc.) are configured according to the packaging order, code splitting scheme and resource requirements. Set the entry point, output directory, splitting strategy, lazy loading options, etc. to ensure that the packaging tool can generate code packages as expected. Use the configured packaging tool to perform the packaging operation. The packaging tool will package multiple JavaScript modules into multiple code packages according to the specified order and splitting scheme. Then, the generated code packages are verified and tested to ensure that they meet the functional requirements and performance requirements of the project, and check whether the loading order, dependencies, resource usage, etc. of the code packages meet expectations.

[0096] In this embodiment, through a reasonable packaging order and code splitting scheme, the amount of code that needs to be downloaded during initial loading can be reduced, and the loading speed of the application can be improved. Packaging according to resource requirements can ensure that key modules are loaded and executed first in a resource-constrained environment, thereby improving resource utilization.

[0097] S106: Perform security analysis on the JavaScript code package to determine whether the JavaScript code package has a security vulnerability.

[0098] In this embodiment, in Web development, the security of JavaScript code packages is crucial because they run directly on the user's browser and may process sensitive data or perform critical operations. Therefore, security analysis of JavaScript code packages to discover and fix potential security vulnerabilities is an important part of ensuring the security of Web applications.

[0099] Specifically, use static code analysis tools (such as ESLint, JSHint, SonarQube, etc.) to scan JavaScript code packages. These tools can identify common errors, bad practices, and potential security vulnerabilities in the code, such as SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF), etc. Configure the tool to include a specific set of security rules to ensure that the latest security threats can be detected.

[0100] Run the JavaScript code package in a simulated or real user environment and monitor its behavior using dynamic analysis tools (such as OWASP ZAP, Burp Suite, etc.), which can capture security vulnerabilities generated by the code at runtime, such as unvalidated user input, insecure API calls, sensitive information leakage, etc. Set up appropriate test scenarios and test cases to cover the main functions and boundary conditions of the code package.

[0101] Check all third-party libraries and frameworks used in JavaScript code packages to confirm whether they contain known security vulnerabilities. Use dependency review tools (such as npm audit, Snyk, etc.) to automatically scan dependencies and obtain detailed information on security vulnerabilities. Update or replace dependencies with security vulnerabilities in a timely manner.

[0102] In this embodiment, through comprehensive security analysis, potential security vulnerabilities in JavaScript code packages can be discovered and repaired, thereby improving the security of Web applications. Timely discovery and repair of security vulnerabilities can reduce the risks of data leakage, service interruption, etc. caused by the exploitation of security vulnerabilities.

[0103] In some embodiments, in the above step S106, the security analysis of the JavaScript code package to determine whether the JavaScript code package has a security vulnerability specifically includes:

[0104] Using a static code analysis tool to perform syntax analysis and semantic analysis on the source code file of the JavaScript code package to determine whether there are potential security risks in the source code file of the JavaScript code package;

[0105] If there are potential security risks in the source code file of the JavaScript code package, an automated testing tool is used to perform dynamic testing to obtain dynamic testing results;

[0106] According to the dynamic test results, the overall security risk level of the JavaScript code package and whether there are security vulnerabilities are determined.

[0107] In this embodiment, the source code file of the JavaScript code package is obtained, and the source code file is used as the input of the static code analysis. The syntax analysis technology is used to perform lexical analysis and syntax analysis on the JavaScript source code file, and an abstract syntax tree is constructed to determine whether the code complies with the JavaScript language specification. If it does not comply with the specification, the syntax error information is recorded. On the basis of the syntax analysis, a semantic analysis is performed, and through the symbol table and type checking and other technologies, it is determined whether there are semantic errors such as undefined variables, type mismatch, function parameter mismatch, etc. in the code. If so, the semantic error information is recorded. According to the characteristics of the JavaScript code, the data flow analysis technology is used to track the data flow in the code, and it is determined whether there are potential runtime error hazards such as uninitialized variables, null pointer references, and division by zero. If so, the data flow error information is recorded. Through the control flow analysis technology, the control flow graph of the JavaScript code is constructed to determine whether there are control flow anomalies such as dead code and infinite loops in the code. If so, the control flow error information is recorded. According to the common security vulnerability characteristics of JavaScript, such as SQL injection, cross-site scripting, etc., the pattern matching technology is used to determine whether there are corresponding security risks in the code. If so, the security risk information is recorded. Based on the analysis results of syntax errors, semantic errors, data flow errors, control flow errors and security risks, a static analysis report of the JavaScript code is generated, which identifies various potential problems in the code and provides an evaluation basis for the security of the code.

[0108] For JavaScript code packages marked as potentially having security risks, dynamic testing is performed using automated testing tools to simulate various possible attack scenarios and obtain dynamic test result data. Based on the obtained dynamic test result data, a security risk assessment model is trained through machine learning algorithms such as support vector machines and random forests to assess the overall security risk level of the JavaScript code package. The source code files of the JavaScript code package and the data collected during the dynamic test are input into the trained security risk assessment model, and the model determines the security risk level of the JavaScript code package and whether there are security vulnerabilities. If the judgment result is a high risk level or a security vulnerability is detected, the early warning mechanism is automatically triggered, a security risk report is generated, the relevant responsible persons are notified, and the JavaScript code package is marked. According to the security risk level of the JavaScript code package and whether there are security vulnerabilities, corresponding countermeasures are taken, code audits are conducted on high-risk code packages, and vulnerabilities are repaired on code packages with security vulnerabilities. A JavaScript code package security risk database is established to continuously collect and update the security risk level and vulnerability information of each code package, monitor the security status of the entire JavaScript ecosystem, and provide data support for subsequent risk prevention and control.

[0109] S107, obtaining multiple third-party libraries, constructing different operation simulation environments according to the multiple third-party libraries, and performing compatibility testing on the JavaScript code package through the different operation simulation environments.

[0110] In this embodiment, in Web development, JavaScript code packages need to run on different browsers, operating systems, and devices, so compatibility testing is a key step to ensure that the code packages can run stably. By using multiple third-party libraries to build different running simulation environments, various actual usage scenarios can be simulated, thereby comprehensively evaluating the compatibility of JavaScript code packages.

[0111] Specifically, identify and collect multiple third-party libraries related to web development. These libraries should be able to simulate the operating environments of different browsers, operating systems, and devices. Common third-party libraries include browser automation testing tools (such as Selenium, Puppeteer), tools that simulate different browsers (such as BrowserStack, Sauce Labs), and tools that simulate specific devices or operating systems (such as Emulators, Simulators). Use the collected third-party libraries to build multiple operating simulation environments according to test requirements. Each environment should be able to simulate a specific browser (such as Chrome, Firefox, Safari, Edge, etc.), operating system (such as Windows, macOS, Linux, iOS, Android, etc.) or device (such as mobile phones, tablets, desktop computers, etc.). Configure the environment to include necessary browser plug-ins, extensions, system settings, etc. to be as close to the real user's usage environment as possible.

[0112] Then, write a test script to execute the JavaScript code package in the built running simulation environment and verify its functionality and performance. The test script contains multiple test cases that cover the main functions and boundary conditions of the code package. You can use test frameworks (such as Jest, Mocha) and assertion libraries (such as Chai, Assert) to assist in writing and running test scripts. Execute the test script in each built running simulation environment, observe and record the operation of the code package and the test results. Pay special attention to the performance differences of the code package in different environments, such as layout problems, functional failures, performance degradation, etc. Use logging, screenshots, video recording, etc. to collect detailed test data and evidence.

[0113] Finally, analyze the test results to determine the compatibility issues of the code package in different environments. Assess the severity and scope of the problem and determine the priority of repair. Write a detailed test report, including the test environment, test cases, test results, and problem analysis. Fix the compatibility issues in the code package based on the test results and perform necessary optimizations. Re-execute the test script in the constructed running simulation environment to verify the repair effect and performance optimization results.

[0114] In this embodiment, by performing compatibility testing in different running simulation environments, compatibility issues of JavaScript code packages on different browsers, operating systems and devices can be discovered and repaired, thereby improving the compatibility and stability of the code. Timely discovery and repair of compatibility issues can reduce the risks of user complaints and service interruptions caused by compatibility issues.

[0115] In some embodiments, in the above step S107, the compatibility test of the JavaScript code package through different running simulation environments specifically includes:

[0116] Import the JavaScript code package into each operation simulation environment respectively, and use a performance analysis tool to obtain operation log information and resource occupancy information of each operation simulation environment;

[0117] Determine, based on the running log information, whether the JavaScript code package has a compatibility problem in the current running simulation environment, and the specific code segment with the compatibility problem;

[0118] According to the resource occupancy information, the performance indicators of the JavaScript code package in different running simulation environments are compared to obtain performance difference results.

[0119] In this embodiment, at least two different operation simulation environments are determined according to the characteristics of the JavaScript code package to evaluate the performance of the code package. For each operation simulation environment, an adapted performance analysis tool is used to obtain detailed log information and resource usage data when the code package is running in the environment. The obtained log information is parsed to extract key performance indicators, such as execution time, memory usage, etc., to form structured performance data. The resource usage data is statistically analyzed to determine the resource consumption of the code package in each environment and identify whether there is abnormal resource usage.

[0120] By analyzing the error information, warning information, etc. in the log information, it is determined whether the code package has compatibility problems. If it is determined that there is a compatibility problem, the file name, line number, and other location information of the specific code segment with the compatibility problem are determined based on the error stack information in the running log information. For the specific code segment with compatibility problems, static code analysis technology is used to analyze the JavaScript syntax characteristics, browser API, etc. used in the code segment to determine whether it has compatibility problems with the JavaScript engine version, browser version, etc. of the current running simulation environment. If it is determined that there is a compatibility problem, the code conversion technology is used to convert the code segment with compatibility problems into equivalent code compatible with the current running simulation environment based on the compatibility information of JavaScript syntax characteristics and browser API. The converted compatibility code segment replaces the original code segment with compatibility problems to obtain a repaired JavaScript code package file. The repaired JavaScript code package is redeployed to the current running simulation environment, and its running log information is re-obtained. By analyzing the log information, it is determined whether the repaired code package has solved the compatibility problem. If it is determined that the compatibility problem has been solved, it is determined that the repaired JavaScript code package can run normally in the current running simulation environment, and it is saved and recorded. Related compatibility problem repair information is for subsequent code maintenance and problem tracing.

[0121] Based on the obtained resource usage information, compare and analyze the differences in various performance indicators of JavaScript code packages in different running simulation environments; based on the performance indicator differences obtained from the comparative analysis, determine whether there are obvious performance differences in the JavaScript code package in different running simulation environments; if there are obvious performance differences, further analyze the reasons for the performance differences, such as running environment configuration, code package size, code logic complexity and other factors; based on the reasons for the performance differences obtained from the analysis, propose improvement measures to optimize the performance of JavaScript code packages, such as optimizing code logic, compressing code package size, adjusting running environment configuration, etc.; test the optimized JavaScript code package in different running simulation environments to obtain the optimized resource usage information and performance indicators; compare the performance indicator difference results before and after optimization, determine the performance optimization effect of the JavaScript code package, and form a final performance difference analysis report.

[0122] Reference Figure 2 An embodiment of the present invention provides a JavaScript module packaging system based on artificial intelligence, and the system specifically includes:

[0123] A first packaging module is used to obtain development project information, analyze the development project information through natural language processing technology, and generate a configuration file;

[0124] A second packaging module is used to establish a module dependency graph by analyzing the dependency relationship between multiple JavaScript modules of the development project according to the configuration file, and determine the packaging order of the multiple JavaScript modules according to the module dependency graph;

[0125] A third packaging module is used to divide each JavaScript module into module granularity based on the module dependency graph by a dynamic programming optimization algorithm, and determine a code splitting scheme for each JavaScript module;

[0126] The fourth packaging module is used to determine the resource demand of each JavaScript module by using a resource demand prediction algorithm according to the historical access data and current load of each JavaScript module;

[0127] A fifth packaging module, used to package multiple JavaScript modules according to the packaging order, the code splitting scheme and the resource demand, and generate a JavaScript code package;

[0128] A sixth packaging module, used to perform security analysis on the JavaScript code package to determine whether the JavaScript code package has a security vulnerability;

[0129] The seventh packaging module is used to obtain multiple third-party libraries, build different running simulation environments according to the multiple third-party libraries, and perform compatibility testing on the JavaScript code package through different running simulation environments.

[0130] It is understandable that if Figure 1 The contents of the embodiment of the JavaScript module packaging method based on artificial intelligence shown in the figure are all applicable to the embodiment of the JavaScript module packaging system based on artificial intelligence. The functions specifically implemented by the embodiment of the JavaScript module packaging system based on artificial intelligence are similar to those in the embodiment of the JavaScript module packaging method based on artificial intelligence shown in the figure. Figure 1 The embodiment of the artificial intelligence-based JavaScript module packaging method shown is the same as that shown in FIG. Figure 1 The beneficial effects achieved by the artificial intelligence-based JavaScript module packaging method embodiment shown are also the same.

[0131] It should be noted that the information interaction, execution process and other contents between the above-mentioned systems are based on the same concept as the embodiment of the method of the present invention. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0132] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0133] Reference Figure 3 The embodiment of the present invention further provides a computer device 3, comprising: a memory 302 and a processor 301 and a computer program 303 stored in the memory 302. When the computer program 303 is executed on the processor 301, the artificial intelligence-based JavaScript module packaging method as described in any one of the above methods is implemented.

[0134] The computer device 3 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The computer device 3 may include, but is not limited to, a processor 301 and a memory 302. Those skilled in the art will appreciate that Figure 3 It is only an example of computer device 3 and does not constitute a limitation on computer device 3. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, for example, it may also include input and output devices, network access devices, etc.

[0135] The processor 301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0136] In some embodiments, the memory 302 may be an internal storage unit of the computer device 3, such as a hard disk or memory of the computer device 3. In other embodiments, the memory 302 may also be an external storage device of the computer device 3, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device 3. Further, the memory 302 may also include both an internal storage unit of the computer device 3 and an external storage device. The memory 302 is used to store an operating system, an application program, a boot loader (Boot Loader), data, and other programs, such as the program code of the computer program, etc. The memory 302 may also be used to temporarily store data that has been output or is to be output.

[0137] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the artificial intelligence-based JavaScript module packaging method as described in any one of the above methods is implemented.

[0138] In this embodiment, if the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0139] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0140] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0141] In the embodiments disclosed in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0142] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

Claims

1. A JavaScript module packaging method based on artificial intelligence, characterized in that: The method specifically comprises: Acquire development project information, analyze the development project information through natural language processing technology, and generate a configuration file; According to the configuration file, a module dependency graph is established by analyzing the dependency relationship between multiple JavaScript modules of the development project, and a packaging order of the multiple JavaScript modules is determined according to the module dependency graph; Based on the module dependency graph, each JavaScript module is divided into module granularity by a dynamic programming optimization algorithm to determine a code splitting scheme for each JavaScript module; According to the historical access data and current load of each JavaScript module, a resource demand prediction algorithm is used to determine the resource demand of each JavaScript module; According to the packaging order, the code splitting scheme and the resource demand, multiple JavaScript modules are packaged to generate a JavaScript code package; Performing a security analysis on the JavaScript code package to determine whether the JavaScript code package has a security vulnerability; Acquire multiple third-party libraries, build different operation simulation environments according to the multiple third-party libraries, and perform compatibility tests on the JavaScript code package through the different operation simulation environments.

2. The method according to claim 1, characterized in that The step of analyzing the development project information by natural language processing technology to generate a configuration file specifically includes: Using natural language processing technology to perform semantic analysis on the development project information to obtain multiple configuration parameters, wherein the configuration parameters include name, data type, value range, default value and comment information; Build a configuration parameter knowledge graph based on the associations and constraints between different configuration parameters; A support vector machine algorithm is used to construct a configuration parameter recommendation model, and recommended values ​​of configuration parameters of the current development project are determined by the configuration parameter recommendation model; A configuration file is formed according to the configuration parameter recommended values ​​and the configuration parameter knowledge graph.

3. The method according to claim 1, characterized in that The step of establishing a module dependency graph by analyzing the dependency relationships between multiple JavaScript modules of the development project according to the configuration file, and determining the packaging order of the multiple JavaScript modules according to the module dependency graph specifically includes: Obtain dependency data between multiple JavaScript modules of the development project according to the configuration file, and construct a module dependency graph through the dependency data; Grouping each JavaScript module in the module dependency graph by using a K-means clustering algorithm to obtain multiple JavaScript module groups; Using the Kruskal minimum spanning tree algorithm to determine the dependency topology of multiple JavaScript modules in each JavaScript module group, and determining the packaging order of multiple JavaScript modules in each JavaScript module group according to the dependency topology; By analyzing the dependencies between the various JavaScript module groups, the packaging order of multiple JavaScript module groups is determined.

4. The method according to claim 1, characterized in that: Based on the module dependency graph, each JavaScript module is divided into module granularity by a dynamic programming optimization algorithm, specifically including: According to the module dependency graph, the total code volume, reuse degree and number of network requests of each JavaScript module are obtained; The total amount of code after splitting each JavaScript module is used as the optimization objective function, and the dynamic programming optimization algorithm is used to divide each JavaScript module into module granularity; In the process of dividing each JavaScript module into module granularity, the optimal split position and the total amount of code after splitting of each JavaScript module are recorded, and the split granularity and the number of splits are adjusted according to the reuse degree and the number of network requests of each JavaScript module.

5. The method according to claim 1, characterized in that The resource demand prediction algorithm is used to determine the resource demand of each JavaScript module according to the historical access data and current load of each JavaScript module, specifically including: Obtain historical access data and current load conditions of each JavaScript module, construct time series features based on the historical access data, and construct resource utilization features based on the current load conditions; Based on the time series characteristics, a long short-term memory neural network is used for training to obtain a visit volume prediction model; Based on the resource utilization characteristics, a support vector regression model is used for training to obtain a resource demand prediction model; According to the output result of the access volume prediction model, the output result of the resource demand prediction model and the current system available resources, the optimal resource demand of each JavaScript module is determined by a multi-objective optimization algorithm.

6. The method according to claim 1, characterized in that The performing security analysis on the JavaScript code package to determine whether the JavaScript code package has a security vulnerability specifically includes: Using a static code analysis tool to perform syntax analysis and semantic analysis on the source code file of the JavaScript code package to determine whether there are potential security risks in the source code file of the JavaScript code package; If there are potential security risks in the source code file of the JavaScript code package, an automated testing tool is used to perform dynamic testing to obtain dynamic testing results; According to the dynamic test results, the overall security risk level of the JavaScript code package and whether there are security vulnerabilities are determined.

7. The method according to claim 1, characterized in that The compatibility test of the JavaScript code package through different running simulation environments specifically includes: Import the JavaScript code package into each operation simulation environment respectively, and use a performance analysis tool to obtain operation log information and resource occupancy information of each operation simulation environment; Determine, based on the running log information, whether the JavaScript code package has a compatibility problem in the current running simulation environment, and the specific code segment with the compatibility problem; According to the resource occupancy information, the performance indicators of the JavaScript code package in different running simulation environments are compared to obtain performance difference results.

8. A JavaScript module packaging system based on artificial intelligence, characterized in that: The system specifically comprises: A first packaging module is used to obtain development project information, analyze the development project information through natural language processing technology, and generate a configuration file; A second packaging module is used to establish a module dependency graph by analyzing the dependency relationship between multiple JavaScript modules of the development project according to the configuration file, and determine the packaging order of the multiple JavaScript modules according to the module dependency graph; A third packaging module is used to divide each JavaScript module into module granularity based on the module dependency graph by a dynamic programming optimization algorithm, and determine a code splitting scheme for each JavaScript module; The fourth packaging module is used to determine the resource demand of each JavaScript module by using a resource demand prediction algorithm according to the historical access data and current load of each JavaScript module; A fifth packaging module, used to package multiple JavaScript modules according to the packaging order, the code splitting scheme and the resource demand, and generate a JavaScript code package; A sixth packaging module, used to perform security analysis on the JavaScript code package to determine whether the JavaScript code package has a security vulnerability; The seventh packaging module is used to obtain multiple third-party libraries, build different running simulation environments according to the multiple third-party libraries, and perform compatibility testing on the JavaScript code package through different running simulation environments.

9. A computer device, characterized in that: include: A memory, a processor, and a computer program stored in the memory. When the computer program is executed on the processor, the artificial intelligence-based JavaScript module packaging method as described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the artificial intelligence-based JavaScript module packaging method as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Code processing method and device, electronic equipment and storage medium

    CN113296797A

  • Data processing method, device and system and computer storage medium

    CN114519095A

  • Word segmentation method and device, electronic equipment and readable storage medium

    CN114692630A

  • Recommendation method based on knowledge graph and deep learning

    CN114861070A

  • Template representation-based container mirror image configuration file automatic generation method and device

    CN116578389A

Cited By

  • Resource management method, system and equipment for PLC program downloading and medium

    CN121151382A

  • Atomized multi-resource data transmission optimization method

    CN121486480A