Accelerated construction method and device for front-end development, equipment and storage medium
Through intelligent dependency management and building cache mechanism, the performance bottlenecks caused by repeated compilation of front-end construction tools in large-scale projects are solved, and the construction speed and efficiency are significantly improved.
Patent Information
- Application Number
- CN202411153855.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-11-22
AI Technical Summary
Existing front-end build tools, duplicate compilation, lead to slow build speeds and waste of time and resources when dealing with large-scale projects.
By obtaining the historical usage data and code logic of the project, determining the dependency modules on the critical path, monitoring file changes, recompiling the affected modules, cache the compilation results, and using the build cache expiration and failure mechanism to update the dependency modules and their compilation results. Priority is given to obtaining compiled results from local storage for construction.
It effectively avoids duplicate compilation problems, significantly improves the speed and efficiency of front-end construction, and shortens the build time.
Smart Images

Figure CN119002926A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of front-end development, and in particular to an accelerated construction method, device, equipment and storage medium for front-end development. Background Art
[0002] As the complexity of web applications increases, the front-end build process becomes more and more time-consuming. Although existing front-end build tools (such as Webpack, Parcel, etc.) are powerful, the build speed often becomes a bottleneck in the development process when dealing with large-scale projects. Common performance bottlenecks include: A large number of dependent packages and modules increase the time for parsing and compilation. During the development process, frequent changes to files require efficient incremental builds. Repeated compilation of unchanged code wastes a lot of time and resources.
[0003] It can be seen that the existing technology still needs to be improved and enhanced. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the purpose of the present invention is to provide an accelerated construction method, device, equipment and storage medium for front-end development, aiming to solve the technical problem in the prior art that repeated compilation occurs during large-scale project development, resulting in slow front-end construction speed.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A first aspect of the present invention provides an accelerated construction method for front-end development, comprising the following steps:
[0007] Obtain the historical usage data and code logic of the project, and determine the dependent modules on the critical path based on the historical usage data and code logic; monitor file changes in the project directory, and recompile the affected dependent modules based on the file change results to obtain compilation results; cache the compilation results to local storage, and update the dependent modules and their compilation results through the build cache expiration and invalidation mechanism; obtain the compilation results from local storage, and build the project based on the compilation results.
[0008] Optionally, in a first implementation method of the first aspect of the present invention, the acquiring of historical usage data and code logic of the project, and determining dependent modules on the critical path based on the historical usage data and code logic, specifically includes: acquiring historical usage data and code logic of the project, and predicting dependent modules that may be used based on the historical usage data and code logic; preloading the dependent modules using threads to obtain loading results, and analyzing the loading results using a dependency analysis tool to obtain a dependency graph; determining the dependent modules on the critical path based on the dependency graph, setting a higher loading priority for the dependent modules on the critical path, and managing the dependent modules on the critical path using a priority queue.
[0009] Optionally, in a second implementation of the first aspect of the present invention, the acquiring of historical usage data and code logic of the project, and predicting dependent modules that may be used based on the historical usage data and code logic, specifically includes: acquiring historical usage data and code logic of the project, cleaning and preprocessing the historical usage data and code logic of the project to obtain standardized data; constructing a prediction model, evaluating model performance using cross-validation, and optimizing the prediction model based on the evaluation results; and inputting the standardized data into the prediction model to obtain dependent modules that may be used.
[0010] Optionally, in a third implementation method of the first aspect of the present invention, the file changes under the monitored project directory are recompiled according to the file change results to obtain the compilation results, specifically including: determining the project directory and file type to be monitored, and setting the initialization file system monitoring tool to monitor whether there are changed files; if a changed file is found, obtaining the path and type of the changed file, and judging whether the dependent modules related to the changed file need to be recompiled according to the dependency graph; if recompilation is required, marking the dependent modules that need to be recompiled, obtaining the marked module, and putting the marked module into the compilation queue for recompilation to obtain the compilation result.
[0011] Optionally, in a fourth implementation of the first aspect of the present invention, if recompilation is required, the dependent modules that need to be recompiled are marked to obtain a marked module, and the marked module is placed in a compilation queue for recompilation to obtain a compilation result, which specifically includes: if recompilation is required, the dependent modules that need to be recompiled are marked, and the dependent modules include direct dependent modules and indirect dependent modules related to the changed files; the marked direct dependent modules and indirect dependent modules are sorted according to the dependency graph to obtain a sorting result; according to the sorting result, the marked direct dependent modules and indirect dependent modules are placed in the compilation queue in sequence for recompilation to obtain a compilation result.
[0012] Optionally, in a fifth implementation of the first aspect of the present invention, the compilation results are cached to local storage, and the dependent modules and their compilation results are updated by building a cache expiration and invalidation mechanism, specifically including: storing the compilation result output in a local cache, fingerprinting the compilation result using a hash algorithm to generate a unique identifier, and using the unique identifier as a cache key value; setting a validity period for each cached compilation result, and expiring and eliminating the compilation results according to the set validity period; obtaining file change results, and invalidating the compilation results corresponding to the dependent modules that need to be recompiled in the cache according to the file change results.
[0013] Optionally, in a sixth implementation method of the first aspect of the present invention, obtaining the compilation results from local storage and building a project based on the compilation results specifically includes: obtaining the compilation results from local storage, verifying the integrity and validity of the compilation results, and recompiling dependent modules corresponding to the compilation results that fail the verification; using a build system to build a project based on the compilation results; and verifying the built project, wherein the verification includes running unit tests or integration tests.
[0014] The second aspect of the present invention provides an accelerated construction device for front-end development, including: a processing module, used to obtain historical usage data and code logic of the project, and determine the dependent modules on the critical path according to the historical usage data and code logic; a compilation module, used to monitor file changes in the project directory, and recompile the affected dependent modules according to the file change results to obtain compilation results; an update module, used to cache the compilation results to local storage, and update the dependent modules and their compilation results through the construction cache expiration and invalidation mechanism; a construction module, used to obtain the compilation results from local storage, and build the project according to the compilation results.
[0015] Optionally, in a first implementation method of the second aspect of the present invention, the processing module includes: a prediction submodule, used to obtain historical usage data and code logic of the project, and predict dependent modules that may be used based on the historical usage data and code logic; an analysis submodule, used to preload the dependent modules using threads, obtain loading results, and analyze the loading results using a dependency analysis tool to obtain a dependency graph; a management submodule, used to determine the dependent modules on the critical path based on the dependency graph, set a higher loading priority for the dependent modules on the critical path, and manage the dependent modules on the critical path using a priority queue.
[0016] Optionally, in a second implementation of the second aspect of the present invention, the prediction submodule includes: a preprocessing unit, used to obtain historical usage data and code logic of the project, and clean and preprocess the historical usage data and code logic of the project to obtain standardized data; a construction unit, used to construct a prediction model, use cross-validation to evaluate model performance, and optimize the prediction model based on the evaluation results; a prediction unit, used to input the standardized data into the prediction model to obtain dependent modules that may be used.
[0017] Optionally, in a third implementation of the second aspect of the present invention, the compilation module includes: a monitoring sub-module, used to determine the project directory and file type to be monitored, and to set the initialization file system monitoring tool to monitor whether there are changed files; a judgment sub-module, used to obtain the path and type of the changed file if a changed file is found, and to judge whether the dependent modules related to the changed file need to be recompiled according to the dependency graph; a compilation sub-module, used to mark the dependent modules that need to be recompiled if recompilation is required, obtain a marking module, put the marked module into the compilation queue for recompilation, and obtain a compilation result.
[0018] Optionally, in a fourth implementation of the second aspect of the present invention, the compilation submodule includes: a marking unit, used to mark the dependent modules that need to be recompiled if recompilation is required, and the dependent modules include direct dependent modules and indirect dependent modules related to the changed files; a sorting unit, used to sort the marked direct dependent modules and indirect dependent modules according to the dependency graph to obtain a sorting result; and a compilation unit, used to put the marked direct dependent modules and indirect dependent modules into the compilation queue in sequence according to the sorting result to recompile and obtain the compilation result.
[0019] Optionally, in a fifth implementation of the second aspect of the present invention, the update module includes: a hash unit, used to store the compilation result output in a local cache, and fingerprint the compilation result using a hash algorithm to generate a unique identifier, and the unique identifier is used as a cache key value; an elimination unit, used to set a validity period for each cached compilation result, and expire and eliminate the compilation result according to the set validity period; an update unit, used to obtain file change results, and invalidate the compilation results corresponding to the dependent modules that need to be recompiled in the cache according to the file change results.
[0020] Optionally, in a sixth implementation of the second aspect of the present invention, the construction module includes: a verification unit, which is used to obtain the compilation results from local storage, verify the integrity and validity of the compilation results, and recompile the dependent modules corresponding to the compilation results that fail the verification; a building unit, which is used to use a build system to build a project according to the compilation results; and a testing unit, which is used to verify the constructed project, and the verification includes running unit tests or integration tests.
[0021] The third aspect of the present invention provides an accelerated construction device for front-end development, comprising a memory and at least one processor, wherein the memory stores computer-readable instructions; the at least one processor calls the computer-readable instructions in the memory to execute the various steps of the accelerated construction method for front-end development as described above.
[0022] A fourth aspect of the present invention provides a computer-readable storage medium having computer-readable instructions stored thereon, which, when executed by a processor, implement the various steps of the accelerated construction method for front-end development as described above.
[0023] Beneficial effects: The present invention provides an accelerated construction method for front-end development, which first obtains the historical usage data and code logic of the project, and determines the dependent modules on the critical path according to the historical usage data and code logic; then monitors the file changes in the project directory, and recompiles the affected dependent modules according to the file change results to obtain the compilation results; at the same time, the compilation results are cached to local storage, and the dependent modules and their compilation results are updated by building a cache expiration and invalidation mechanism, which effectively avoids the problem of repeated compilation; finally, when constructing a component project, the compilation results are obtained from the local storage first, which shortens the construction time and significantly improves the speed and efficiency of the front-end construction. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A first flow chart of an accelerated construction method for front-end development provided by an embodiment of the present invention;
[0025] Figure 2 A second flow chart of the accelerated construction method for front-end development provided by an embodiment of the present invention;
[0026] Figure 3 A third flow chart of the accelerated construction method for front-end development provided by an embodiment of the present invention;
[0027] Figure 4 A fourth flow chart of the accelerated construction method for front-end development provided by an embodiment of the present invention;
[0028] Figure 5A fifth flow chart of the accelerated construction method for front-end development provided by an embodiment of the present invention;
[0029] Figure 6 A sixth flow chart of the accelerated construction method for front-end development provided by an embodiment of the present invention;
[0030] Figure 7 A seventh flow chart of the accelerated construction method for front-end development provided by an embodiment of the present invention;
[0031] Figure 8 A schematic diagram of a structure of an accelerated construction device for front-end development provided by an embodiment of the present invention;
[0032] Fig. 9 Another structural schematic diagram of an accelerated construction device for front-end development provided by an embodiment of the present invention;
[0033] Fig.10 A schematic diagram of the structure of an accelerated construction device for front-end development provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0034] The present invention provides an accelerated construction method, device, equipment and storage medium for front-end development. The present invention first determines the dependent modules on the critical path according to historical usage data and code logic through intelligent dependency management, and recompiles the affected dependent modules according to the file change results by monitoring file changes, thereby avoiding the problem of repeated compilation; and then realizes efficient construction through compilation cache and build cache expiration and invalidation mechanism, solves the bottleneck problem of construction performance in the prior art, shortens the construction time, and significantly improves the speed and efficiency of front-end construction.
[0035] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0036] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 The first embodiment of the accelerated construction method for front-end development in the embodiment of the present invention includes:
[0037] S101. Obtain historical usage data and code logic of the project, and determine dependent modules on the critical path based on the historical usage data and code logic;
[0038] Bottlenecks can be identified by analyzing historical usage data and code logic. For example, you can identify which modules or functions are frequently called or inefficiently executed in the system, and then determine the dependent modules on these critical paths. After determining the dependent modules on the critical path, you can manage the dependencies between these modules more finely, and in subsequent builds, when the system fails, the dependency analysis on the critical path can locate the source of the problem more quickly and reduce troubleshooting time. After determining the dependent modules on the critical path, you can also perform performance analysis on the dependent modules on the critical path, identify performance bottlenecks and optimize them, which can significantly improve the build speed.
[0039] S102. Monitor file changes in the project directory, recompile the affected dependent modules according to the file change results, and obtain the compilation results;
[0040] When monitoring, you can use the initialization file system monitoring tool. Every time a file changes, analyze the affected dependent modules and determine the modules that need to be recompiled. Based on the dependency analysis results, only recompile the affected modules. This method greatly reduces the frequency of full compilation and avoids unnecessary compilation processes, thereby saving computing resources. In addition, this method can also support rapid iteration during the development process. Through fast compilation and feedback mechanisms, it supports project development teams to perform more frequent code iterations and version updates.
[0041] S103. Cache the compilation results to local storage, and update the dependent modules and their compilation results by building a cache expiration and invalidation mechanism;
[0042] By caching compilation results, when the files in the project have not changed, you can directly use the compilation results in the cache to avoid repeated compilation, thereby significantly improving the compilation speed. In large projects, the compilation process is often very time-consuming. Caching compilation results can reduce CPU and memory usage because the compilation process does not need to be repeated. In a continuous integration and continuous deployment (CI / CD) environment, caching compilation results can reduce the load on the build server, enabling it to handle more build tasks. Through the caching mechanism, you can significantly shorten the build time and improve development efficiency.
[0043] The cache expiration and invalidation mechanism can flexibly set the cache expiration time and invalidation conditions according to the needs of the project, which is very flexible. In addition, through a reasonable cache expiration and invalidation mechanism, it can be ensured that the compilation results in the cache will not be outdated or inconsistent due to long-term non-update. When the file changes, the invalidation mechanism can ensure that the old compilation results will not continue to be used, thereby avoiding cache pollution problems.
[0044] S104. Obtain the compilation result from the local storage, and build the project according to the compilation result. Caching the compilation result to the local storage, and updating the dependent modules and their compilation results by building a cache expiration and invalidation mechanism can significantly improve compilation efficiency, save system resources, ensure data consistency, and support rapid iteration and deployment.
[0045] The accelerated construction method for front-end development provided by the present invention determines the dependent modules on the critical path according to the historical usage data and code logic, and then uses a monitoring tool to monitor file changes in the project directory, caches the compilation results of each dependent module to local storage, implements a cache expiration and invalidation mechanism, and obtains the compilation results from the cache in the construction process in priority; through intelligent dependency management, efficient incremental construction and compilation cache, the construction performance bottleneck problem in the prior art is solved, the construction time is shortened, and the speed and efficiency of the front-end construction are significantly improved.
[0046] See also Figure 2 The second embodiment of the accelerated construction method for front-end development in the embodiment of the present invention includes:
[0047] S201. Obtain historical usage data and code logic of the project, and predict the dependent modules that may be used based on the historical usage data and code logic;
[0048] S202. Preload the dependent module using a thread to obtain a loading result, and analyze the loading result using a dependency analysis tool to obtain a dependency graph;
[0049] S203. Determine the dependent modules on the critical path according to the dependency graph, set a higher loading priority for the dependent modules on the critical path, and manage the dependent modules on the critical path using a priority queue.
[0050] In this embodiment, by analyzing the historical usage data and code logic of the project, predicting the dependent modules that may be used, then creating a thread in the background, gradually preloading these dependent modules according to the prediction results, and further obtaining the dependency graph, and finally using algorithms such as depth-first search or topological sorting to analyze the dependency graph, determine the dependencies on the critical path. Dependency analysis tools (such as npm, yarn) use the API provided by npm or yarn to read the package.json file and related configurations of the project, and can parse out a complete dependency graph and store it as a data structure that is convenient for subsequent operations. Specifically, npm uses an algorithm based on depth-first search (DFS, Depth-First Search) to traverse the dependency tree, and yarn ensures the consistency of the dependent version through a deterministic algorithm and a lock file, helping developers understand the project dependency structure and guiding the optimization of the loading order. Based on historical access data or static code analysis, predicting the dependent modules that may be requested in the future, and loading them into memory or local storage in advance, can reduce the delay at runtime. In actual operation, the performance and effect of the threads can also be monitored to ensure that they will not become the bottleneck of the system, and adjust the parameters such as the pre-fetch strategy, the number of threads and the priority according to the actual operation. In addition, dependency prefetching strategies are often combined with heuristic algorithms or machine learning models, such as using the LRU (Least Recently Used) algorithm to predict high-frequency dependencies and optimize the first loading experience.
[0051] See also Figure 3 The third embodiment of the accelerated construction method for front-end development in the embodiment of the present invention includes:
[0052] S301. Obtain historical usage data and code logic of the project, and clean and preprocess the historical usage data and code logic of the project to obtain standardized data;
[0053] For historical usage data, data cleaning can include: missing value processing: identifying and processing missing data, which may be done by filling, deleting or interpolating; outlier detection and processing: identifying and processing abnormal or erroneous data points; data deduplication: ensuring that the data does not contain duplicate records; data format unification. For code logic, data cleaning can include: code cleaning: removing unnecessary comments, test code and temporary files; code formatting: using code formatting tools (such as Prettier, Black, etc.) to ensure consistent code style; code dependency analysis: parsing and recording project dependencies.
[0054] When preprocessing historical usage data, it can include: Feature engineering: creating new features or variables from raw data according to business needs; Data encoding: encoding categorical data into numerical data (such as one-hot encoding, label encoding, etc.); Data partitioning: dividing the data set into training set, validation set, and test set. When preprocessing code logic, it can include: Code metrics: calculating code metrics (such as number of lines, function complexity, class coupling, etc.); Code abstraction: abstracting code logic into analyzable models or graph structures (such as call graphs, dependency graphs).
[0055] S302. Build a prediction model, use cross-validation to evaluate model performance, and optimize the prediction model based on the evaluation results;
[0056] For predictions using dependent modules, common models include but are not limited to: linear regression, logistic regression, decision tree / random forest, gradient boosting machine (such as XGBoost, LightGBM), neural network. Using cross-validation to evaluate the performance of the model can more accurately understand the performance of the model on different data subsets and reduce the risk of overfitting. Common cross-validation methods include K-fold cross-validation.
[0057] S303. Input the standardized data into the prediction model to obtain the dependent modules that may be used. Through model prediction, the dependent modules that may be used can be quickly obtained, and the accuracy and reliability can be ensured.
[0058] See also Figure 4 The fourth embodiment of the accelerated construction method for front-end development in the embodiment of the present invention includes:
[0059] S401. Determine the project directory and file type to be monitored, and set up the initialization file system monitoring tool to monitor whether there are any changes to the file;
[0060] Specifically, Chokidar can be used to initialize the file system monitoring tool. When using the relevant initialization file system monitoring tool, you need to specify the project directory to be monitored and the file type of interest (such as .js, .css, etc.). When the file system changes, Chokidar triggers the corresponding event. The file system monitoring tool uses the file system event monitoring interface provided by the operating system (such as inotify on Linux, FSEvents on macOS, ReadDirectoryChangesW onWindows) to monitor file or directory changes in an efficient and low-latency manner. Once a change is detected, an event callback is triggered to achieve near real-time file system monitoring.
[0061] S402. If a changed file is found, obtain the path and type of the changed file, and determine whether the dependent modules related to the changed file need to be recompiled according to the dependency graph;
[0062] The file type is crucial for determining whether recompilation is needed later, because different types of files have different effects on the compilation process.
[0063] For each relevant dependent module, determine whether recompilation is required based on the type and location of the changed file. In general: If the changed file is a source code file (such as .java, .cpp) and is directly or indirectly referenced by a module, it is likely that the module needs to be recompiled. If the changed file is a configuration file or resource file, and these files are read by the module at runtime, then the module may not need to be recompiled, but it may need to be repackaged or deployed. If the changed file is not related to the module (for example, it is a document or test file), then the module does not need to be recompiled.
[0064] S403. If recompilation is required, mark the dependent modules that need to be recompiled, obtain the marked modules, put the marked modules into the compilation queue for recompilation, and obtain the compilation results.
[0065] See also Figure 5 The fifth embodiment of the accelerated construction method for front-end development in the embodiment of the present invention includes:
[0066] S501. If recompilation is required, mark the dependent modules that need to be recompiled, the dependent modules include direct dependent modules and indirect dependent modules related to the changed file;
[0067] Specifically, a dirty marking algorithm can be used for marking. By determining which dependent modules have become "dirty" due to file changes, only these modules and their dependencies are recompiled. By traversing the direct dependency list of the changed file, it can be determined which are the direct dependent modules (such as dependent modules that directly reference or contain the changed file). When further obtaining the indirect dependent modules, it is necessary to check the dependencies of the directly dependent modules. The indirect dependent modules may not directly reference the changed files, but they depend on those modules that directly depend on the changed files. This step can use a graph traversal algorithm (such as depth-first search or breadth-first search) to traverse the dependency graph and mark all affected indirect dependent modules.
[0068] S502. Sort the marked directly dependent modules and indirectly dependent modules according to the dependency graph to obtain a sorting result;
[0069] Sort the marked direct and indirect dependent modules according to the dependency graph to ensure that these modules are processed in the correct order during compilation to avoid compilation errors or unnecessary repeated compilation. The dependency graph is directed and a topological sorting algorithm is needed to sort these dependent modules.
[0070] S503. According to the sorting result, the marked direct dependent modules and indirect dependent modules are sequentially put into the compilation queue for recompiling to obtain the compilation result. Compiling each dependent module according to the sorting result can ensure that all modules that the next module depends on have been compiled and prepared.
[0071] See also Figure 6 The sixth embodiment of the accelerated construction method for front-end development in the embodiment of the present invention includes:
[0072] S601. The compilation result is output and stored in a local cache, and a hash algorithm is used to fingerprint the compilation result to generate a unique identifier, and the unique identifier is used as a cache key value;
[0073] In this embodiment, the compiled module output (such as JavaScript bundle, style sheet, image, etc.) can be stored in a local cache (such as file system cache on the hard disk, memory cache, etc.), and then the module content can be fingerprinted using a hash algorithm (such as SHA-256) to generate a unique identifier as the key value of the cache to ensure the uniqueness and traceability of the cache.
[0074] S602. Set a validity period for each cached compilation result, and perform expired elimination processing on the compilation result according to the set validity period;
[0075] You can set a timer or use a timestamp to record the creation time of the cache, and set a reasonable expiration time based on the characteristics of the project and the update frequency. When the expiration time is exceeded, the cache is marked as expired.
[0076] S603: Obtain the file change result, and invalidate the compilation result corresponding to the dependent module that needs to be recompiled in the cache according to the file change result.
[0077] When the source code of the relevant module is detected to have changed, the corresponding cache is invalidated. According to the change of the dependency hash, the relevant cache is actively marked invalid and forced to recompile. This method ensures that the latest dependency compilation results are always used during the development process, while maximizing the use of the cache to accelerate the build process. During the build process, first check whether there is a valid compilation result of the required module in the cache. If so, use it directly. Otherwise, compile and update the cache.
[0078] See also Figure 7 The seventh embodiment of the accelerated construction method for front-end development in the embodiment of the present invention includes:
[0079] S701. Obtain the compilation result from the local storage, verify the integrity and validity of the compilation result, and recompile the dependent modules corresponding to the compilation result that failed the verification;
[0080] Getting the compilation results from local storage and validating them is an important step to ensure the stability and reliability of the system. If the compilation results fail validation (either integrity or validity), you need to determine which dependent modules are associated with these results. This usually involves tracing back into the dependency graph during the compilation process and identifying the modules that may be causing the problem.
[0081] S702. Using a build system, build a project according to the compilation result;
[0082] Build systems (such as Maven, Gradle, Make, CMake, etc.) automate the build process such as compilation, linking, packaging and deployment, ensuring that the project can be converted from source code to executable software in a consistent manner.
[0083] S703. Verify the built project, where the verification includes running unit tests or integration tests.
[0084] Unit testing focuses on the smallest testable unit of software (such as functions, methods or classes). By writing test cases for these units and running them, defects such as errors in the code, logic problems or improper boundary conditions can be discovered early. Integration testing focuses on the interaction between different modules or components. By simulating or actually running the integrated environment of these components, defects such as interface mismatches, data transfer errors or integration logic problems can be discovered.
[0085] The above describes the accelerated construction method for front-end development in the embodiment of the present invention. The following describes the accelerated construction device for front-end development in the embodiment of the present invention. Figure 8 An embodiment of an accelerated construction device for front-end development in an embodiment of the present invention includes:
[0086] A processing module 10 is used to obtain historical usage data and code logic of the project, and determine dependent modules on the critical path according to the historical usage data and code logic;
[0087] The compilation module 20 is used to monitor file changes in the project directory, and recompile the affected dependent modules according to the file change results to obtain the compilation results;
[0088] An update module 30, used to cache the compilation results to local storage, and update the dependent modules and their compilation results by building a cache expiration and invalidation mechanism;
[0089] The construction module 40 is used to obtain the compilation result from the local storage and construct the project according to the compilation result.
[0090] See also Fig. 9 An embodiment of an accelerated construction device for front-end development in an embodiment of the present invention includes:
[0091] A processing module 10 is used to obtain historical usage data and code logic of the project, and determine dependent modules on the critical path according to the historical usage data and code logic;
[0092] The compilation module 20 is used to monitor file changes in the project directory, and recompile the affected dependent modules according to the file change results to obtain the compilation results;
[0093] An update module 30, used to cache the compilation results to local storage, and update the dependent modules and their compilation results by building a cache expiration and invalidation mechanism;
[0094] A construction module 40 is used to obtain the compilation result from the local storage and construct a project according to the compilation result;
[0095] In this embodiment, the processing module 10 includes:
[0096] A prediction submodule 110 is used to obtain historical usage data and code logic of the project, and predict the dependent modules that may be used according to the historical usage data and code logic;
[0097] An analysis submodule 120 is used to preload the dependent module using a thread to obtain a loading result, and analyze the loading result using a dependency analysis tool to obtain a dependency graph;
[0098] A management submodule 130, for determining dependent modules on a critical path according to the dependency graph, setting a higher loading priority for the dependent modules on the critical path, and managing the dependent modules on the critical path using a priority queue;
[0099] In this embodiment, the prediction submodule 110 includes:
[0100] A preprocessing unit 111 is used to obtain historical usage data and code logic of a project, and clean and preprocess the historical usage data and code logic of the project to obtain standardized data;
[0101] A construction unit 112 is used to construct a prediction model, evaluate the model performance using cross-validation, and optimize the prediction model according to the evaluation results;
[0102] A prediction unit 113, configured to input the standardized data into a prediction model to obtain a dependency module that may be used;
[0103] In this embodiment, the compiling module 20 includes:
[0104] The monitoring submodule 210 is used to determine the project directory and file type to be monitored, and to set up the initialization file system monitoring tool to monitor whether there are changed files;
[0105] The judgment submodule 220 is used to obtain the path and type of the changed file if a changed file is found, and to judge whether the dependent modules related to the changed file need to be recompiled according to the dependency graph;
[0106] The compiling submodule 230 is used to mark the dependent modules that need to be recompiled if recompilation is required, obtain the marked modules, put the marked modules into the compiling queue for recompilation, and obtain the compiling results;
[0107] In this embodiment, the compiling submodule 230 includes:
[0108] A marking unit 231 is used to mark the dependent modules that need to be recompiled if recompilation is required, wherein the dependent modules include direct dependent modules and indirect dependent modules related to the changed file;
[0109] A sorting unit 232, used to sort the marked direct dependency modules and indirect dependency modules according to the dependency graph to obtain a sorting result;
[0110] A compiling unit 233 is used to sequentially put the marked direct dependent modules and indirect dependent modules into a compiling queue according to the sorting result, so as to recompile and obtain a compiling result;
[0111] In this embodiment, the updating module 30 includes:
[0112] A hash unit 301 is used to store the compilation result output in a local high-speed cache, and fingerprint the compilation result using a hash algorithm to generate a unique identifier, which is used as a key value of the cache;
[0113] The elimination unit 302 is used to set a validity period for each cached compilation result, and perform expired elimination processing on the compilation result according to the set validity period;
[0114] An updating unit 303 is used to obtain a file change result, and invalidate a compilation result corresponding to a dependent module that needs to be recompiled in a cache according to the file change result;
[0115] In this embodiment, the building module 40 includes:
[0116] The verification unit 401 is used to obtain the compilation result from the local storage, verify the integrity and validity of the compilation result, and recompile the dependent modules corresponding to the compilation result that failed the verification;
[0117] A building unit 402 is used to use a building system to build a project according to the compilation result;
[0118] The testing unit 403 is used to verify the built project, and the verification includes running unit tests or integration tests.
[0119] The accelerated construction device for front-end development provided by the present invention obtains the historical usage data and code logic of the project, parses the dependency graph of the project by using a dependency analysis tool, and monitors the file changes under the project directory by using a file system monitoring tool, recompiles the changed dependent modules in time, and caches the compilation results to local storage. When storing, a cache expiration and invalidation mechanism is implemented to ensure the continuous updating of data. During the construction process, the compilation results are obtained from the cache first, which avoids repeated compilation, improves the construction speed, solves the construction performance bottleneck problem in the prior art, and significantly improves the speed and efficiency of front-end construction.
[0120] The above is a detailed description of the accelerated construction device for front-end development in the embodiment of the present invention from the perspective of modular functional entities. The following is a detailed description of the accelerated construction device for front-end development in the embodiment of the present invention from the perspective of hardware processing.
[0121] Fig.10 A schematic diagram of the structure of an acceleration construction device for front-end development provided in an embodiment of the present invention. The acceleration construction device 900 for front-end development may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 910 (for example, one or more processors) and a memory 920, and one or more storage media 930 (for example, one or more mass storage devices) storing application programs 933 or data 932. Among them, the memory 920 and the storage medium 930 can be short-term storage or persistent storage. The program stored in the storage medium 930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the acceleration construction device 900 for front-end development. Furthermore, the processor 910 can be configured to communicate with the storage medium 930, and execute a series of instruction operations in the storage medium 930 on the acceleration construction device 900 for front-end development, so as to implement the steps of the acceleration construction method for front-end development provided in the above-mentioned various method embodiments.
[0122] The accelerated construction device 900 for front-end development may also include one or more power supplies 940, one or more wired or wireless network interfaces 950, one or more input and output interfaces 960, and / or one or more operating systems 931, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Fig.10 The structure of the accelerated construction device for front-end development shown does not constitute a limitation of the accelerated construction device for front-end development, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0123] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of an accelerated construction method for front-end development.
[0124] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the equipment or device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0125] 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 technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0126] It is understandable that those skilled in the art can make equivalent substitutions or changes based on the technical solution and inventive concept of the present invention, and all these changes or substitutions should fall within the protection scope of the claims attached to the present invention.
Claims
1. An accelerated construction method for front-end development, characterized in that: The steps include: Obtain historical usage data and code logic of the project, and determine dependent modules on the critical path according to the historical usage data and code logic; Monitor file changes in the project directory, recompile the affected dependent modules according to the file change results, and obtain the compilation results; Cache the compilation results to local storage, and update the dependent modules and their compilation results by building a cache expiration and invalidation mechanism; The compilation result is obtained from the local storage, and the project is built according to the compilation result.
2. The accelerated construction method for front-end development according to claim 1, characterized in that: The obtaining of historical usage data and code logic of the project, and determining dependent modules on the critical path according to the historical usage data and code logic, specifically includes: Obtain historical usage data and code logic of the project, and predict dependent modules that may be used based on the historical usage data and code logic; Preloading the dependent module by using a thread to obtain a loading result, and analyzing the loading result by using a dependency analysis tool to obtain a dependency graph; Dependent modules on the critical path are determined according to the dependency graph, a higher loading priority is set for the dependent modules on the critical path, and a priority queue is used to manage the dependent modules on the critical path.
3. The accelerated construction method for front-end development according to claim 2, characterized in that: The obtaining of the historical usage data and code logic of the project and predicting the dependent modules that may be used according to the historical usage data and code logic specifically includes: Acquire historical usage data and code logic of the project, and clean and preprocess the historical usage data and code logic of the project to obtain standardized data; Build a prediction model, use cross-validation to evaluate model performance, and optimize the prediction model based on the evaluation results; The normalized data is input into a prediction model to obtain dependency modules that may be used.
4. The accelerated construction method for front-end development according to claim 2, characterized in that: The monitoring project directory files are changed, and the affected dependent modules are recompiled according to the file change results to obtain the compilation results, which specifically include: Determine the project directories and file types to be monitored, and set up the initial file system monitoring tool to monitor whether there are changed files; If a changed file is found, obtain the path and type of the changed file, and determine whether the dependent modules related to the changed file need to be recompiled according to the dependency graph; If recompilation is required, the dependent modules that need to be recompiled are marked to obtain marked modules, and the marked modules are put into a compilation queue for recompilation to obtain a compilation result.
5. The accelerated construction method for front-end development according to claim 4, characterized in that: If recompilation is required, the dependent modules that need to be recompiled are marked to obtain the marked modules, and the marked modules are put into the compilation queue for recompilation to obtain the compilation results, which specifically include: If recompilation is required, mark the dependent modules that need to be recompiled, where the dependent modules include direct dependent modules and indirect dependent modules related to the changed files; Sort the marked direct dependency modules and indirect dependency modules according to the dependency graph to obtain a sorting result; According to the sorting results, the marked direct dependency modules and indirect dependency modules are sequentially put into the compilation queue for recompilation to obtain the compilation results.
6. The accelerated construction method for front-end development according to claim 4, characterized in that: The caching of the compilation results to local storage and updating of the dependent modules and their compilation results by building a cache expiration and invalidation mechanism specifically include: The compilation result is output and stored in a local high-speed cache, and a hash algorithm is used to fingerprint the compilation result to generate a unique identifier, and the unique identifier is used as a key value of the cache; Setting a validity period for each cached compilation result, and performing expired elimination processing on the compilation result according to the set validity period; Get the file change result, and invalidate the compilation result corresponding to the dependent module that needs to be recompiled in the cache according to the file change result.
7. The accelerated construction method for front-end development according to claim 1, characterized in that: The step of obtaining the compilation result from the local storage and constructing the project according to the compilation result specifically includes: Obtaining the compilation result from the local storage, verifying the integrity and validity of the compilation result, and recompiling the dependent modules corresponding to the compilation result that failed the verification; Using a build system to build a project according to the compilation result; The built project is verified, and the verification includes running unit tests or integration tests.
8. An accelerated construction device for front-end development, characterized in that: include: A processing module, used to obtain historical usage data and code logic of the project, and determine dependent modules on the critical path according to the historical usage data and code logic; The compilation module is used to monitor file changes in the project directory, recompile the affected dependent modules according to the file change results, and obtain the compilation results; An update module, used to cache the compilation results to local storage, and update the dependent modules and their compilation results by building a cache expiration and invalidation mechanism; The building module is used to obtain the compilation result from the local storage and build the project according to the compilation result.
9. An accelerated construction device for front-end development, characterized in that: comprising a memory and at least one processor, wherein the memory has computer-readable instructions stored therein; The at least one processor calls the computer-readable instructions in the memory to execute the various steps of the accelerated construction method for front-end development as described in any one of claims 1-7.
10. A computer-readable storage medium having computer-readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the steps of the accelerated construction method for front-end development as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Automatic incremental compiling method and system for Java development
CN119396406A
An automatic incremental compilation method and system for Java development
CN119396406B
Gradle-based software RPM package construction method and system
CN120762733A
