Front-end component detection method, system and equipment and storage medium
By loading preset plug-ins in the front-end construction tool, collecting and detecting compiled resources, and generating detailed reports, the problem of limitations of front-end component detection is solved, and component quality assessment and performance improvement are achieved.
Patent Information
- Application Number
- CN202410712879.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-08-30
AI Technical Summary
Existing technology has limitations in front-end component detection, making it difficult to achieve comprehensive and automated detection, making it difficult to evaluate component quality and limiting performance improvement and bug reduction.
By loading preset plug-ins in front-end build tools, collecting compilation resources and calling detection methods, generating detection reports, including code detection, unit testing and server-side rendering detection, various detections are performed in the compilation stream in real time, providing detailed component quality Report.
It achieves comprehensive detection of front-end components, improves component quality, optimizes performance, reduces bugs, and enhances developers' understanding and control of component quality.
Smart Images

Figure CN118567758A
Abstract
Description
Background Art
[0002] Front-end development refers to the process and result of merging multiple source files (such as JavaScript, Cascading Style Sheets CSS, images, etc.) into a single file. Among them, component-based front-end development is one of the front-end development modes.
[0003] In front-end development, the process and result of merging multiple source files (such as JavaScript, CSS, images, etc.) into a single file of one or more front-end components. By using a front-end build tool, these source files can be packaged into one or more bundle files. The build tool analyzes the dependencies between source files and merges them into one file, which contains all the code and resources.
[0004] In this way, the front-end page can be developed in a componentized way with the help of a framework (such as Vue.js, Angular, React), making the code easier to reuse. At this point, a front-end page is no longer composed of independent HTML, CSS, JavaScript and other files, but the web page is divided into front-end components according to the component concept, and these front-end components are assembled together to form a complete web page.
[0005] In this way, a front-end component contains not only HTML, CSS, JavaScript code, but also the component's template, style, interaction, etc., which basically covers all the content of the component. The outside world only needs to call it according to the properties, functions, and event handling set by the component, without considering the internal implementation logic of the front-end component. To the outside world, the front-end component is a complete black box.
[0006] Among them, in component-based front-end development, front-end building tools have become an indispensable part. They can help us automate tasks, optimize codes, and improve development efficiency.
[0007] Specifically, the front-end build tool compiles source files into a single component and combines multiple compiled components into a deployable software package. This software package may contain compiled executable files, library files, configuration files, documents, resource files, and other front-end components. Therefore, the front-end build process usually includes multiple steps such as compilation, packaging, and compression. The final generated software package can be deployed to the target environment for use.
[0008] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present embodiment, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0009] In response to the problems in the prior art, the purpose of this embodiment is to provide a front-end component detection method, system, device and storage medium, which overcomes the difficulties of the prior art and can improve the quality of front-end component detection.
[0010] The present disclosure provides a front-end component detection method, which includes:
[0011] Load the preset plugin in the front-end building tool;
[0012] Call the preset plug-in to collect the compilation resources of the front-end components in the compilation flow based on the build tool;
[0013] Call the detection method corresponding to the compiled resource, detect the compiled resource, and generate a detection report for the front-end component.
[0014] In an optional implementation, loading a preset plug-in in a front-end building tool includes:
[0015] Declaratively mount the preset plug-in to each node in the compilation flow to collect the compilation resources of the corresponding node when the corresponding node is running.
[0016] In an optional implementation manner, when the corresponding node is running, collecting the compilation resources when the corresponding node is running includes at least one of the following situations:
[0017] Collect pre-compilation code in the hook function of the compilation input node;
[0018] Collect the compiled code in the hook function of the compilation output node;
[0019] Read the virtual attribute information and configuration information required for front-end component rendering from the root directory of the front-end component.
[0020] In an optional implementation, calling a detection method corresponding to a compilation resource to detect the compilation resource and generate a detection report of the front-end component includes:
[0021] For pre-compiled code or post-compiled code, call the code detection tool to perform code detection and generate a code detection report.
[0022] 5. The front-end component detection method according to claim 4, characterized in that calling a code detection tool to perform code detection comprises:
[0023] The code detection tool is called to parse the pre-compiled code into an abstract syntax tree, and the code detection is performed on the abstract syntax tree.
[0024] In an optional implementation, calling a detection method corresponding to a compilation resource to detect the compilation resource and generate a detection report of the front-end component includes:
[0025] Call the server-side renderer, use virtual attribute information and configuration information to simulate server-side rendering, and generate a server-side rendering detection report by detecting the server-side rendering process.
[0026] In an optional implementation, calling a preset plug-in to collect compilation resources of the front-end component in a compilation flow based on a build tool includes:
[0027] Based on the preset plug-in, the compiled and packaged modules of the compiled resources are collected so as to call the unit test plug-in to perform unit test on the compiled and packaged modules and generate a unit test report for the front-end components.
[0028] In an optional implementation manner, the front-end component detection method further includes:
[0029] When the detection report shows that the corresponding node in the compilation flow does not meet the requirements, an exception is thrown and the compilation flow is terminated.
[0030] In an optional implementation manner, the front-end component detection method further includes:
[0031] Rendering is performed on the detection report of the front-end component and the compiled and packaged module of the front-end component, and the rendering page of the detection report and the rendering page of the compiled and packaged module to which it belongs are displayed at the same time.
[0032] The present disclosure also provides a front-end component detection system, which includes:
[0033] Load the module and load the preset plug-in in the front-end building tool;
[0034] The collection module calls the preset plug-in to collect the compilation resources of the front-end components in the compilation flow based on the build tool;
[0035] The detection module calls the detection method corresponding to the compiled resources, detects the compiled resources, and generates a detection report for the front-end components.
[0036] An embodiment of this implementation further provides an electronic device, including:
[0037] processor;
[0038] a memory in which executable instructions for the processor are stored;
[0039] Among them, the processor is configured to perform the steps of the above-mentioned front-end component detection method by executing executable instructions.
[0040] An embodiment of the present implementation also provides a computer-readable storage medium for storing a program, which implements the steps of the above-mentioned front-end component detection method when executed.
[0041] The front-end component detection method, system, device and storage medium provided in this embodiment have the following technical effects:
[0042] This implementation method can intervene in the compilation flow of the front-end component through a preset plug-in of a custom build tool during the entire compilation process of the front-end component, perform various tests in real time in the compilation flow and produce reports, so that developers can understand the quality of this component more easily, quickly, clearly and comprehensively, breaking through the limitations of front-end component detection in existing technologies, and ultimately achieving the purpose of optimizing components, improving performance and reducing bugs. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Other features, objectives and advantages of the present embodiment will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings.
[0044] Figure 1 One of the flowcharts of the front-end component detection method according to an embodiment of the present disclosure is shown.
[0045] Figure 2 A specific flow chart showing the front-end component detection method of an embodiment of the present disclosure.
[0046] Figure 3 The second flowchart of the front-end component detection method of the embodiment of the present disclosure is presented.
[0047] Figure 4 The third flowchart showing the front-end component detection method of the embodiment of the present disclosure.
[0048] Figure 5 Demonstration of use Figure 1 , 3 Or the test report display interface obtained by the front-end component detection method shown in 4.
[0049] Figure 6 One of the structural diagrams of the front-end component detection system of an embodiment of the present disclosure is shown.
[0050] Figure 7 The second structural diagram of the front-end component detection system of the embodiment of the present disclosure is shown.
[0051] Figure 8 A schematic diagram showing the structure of an electronic device according to this embodiment.
[0052] Fig. 9 It is a schematic diagram of the structure of the computer-readable storage medium of this embodiment. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical scheme and advantages of this embodiment more clear, this embodiment will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this embodiment, not all of the embodiments. Based on the embodiments in this embodiment, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this embodiment.
[0054] The accompanying drawings are only schematic illustrations of the present embodiment and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware forwarding modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0055] In addition, the processes shown in the drawings are only exemplary and do not necessarily include all the steps. For example, some steps may be decomposed, some steps may be combined or partially combined, and the actual execution order may be changed according to the actual situation.
[0056] The disclosed embodiments provide a front-end component detection method, which can realize automatic and comprehensive detection of the entire compilation flow of a build tool, breaking through the limitations of the front-end component detection in the prior art.
[0057] like Figure 1 As shown, Figure 1 A flow chart showing a front-end component detection method provided by an embodiment of the present disclosure is shown. The front-end component detection method of this embodiment includes but is not limited to the following steps:
[0058] Step 110: Load the preset plug-in in the front-end building tool;
[0059] Step 120: calling a preset plug-in to collect compilation resources of the front-end component in a compilation flow based on a build tool;
[0060] Step 130: calling the detection method corresponding to the compilation resource, detecting the compilation resource, and generating a detection report of the front-end component.
[0061] Using this implementation, by writing a preset plug-in plugin for the front-end construction tool and loading it into the front-end construction tool, it is possible to collect compilation resources based on the preset plug-in, then perform detection by calling various corresponding detection methods, and finally generate a detection report.
[0062] This implementation method can intervene in the compilation flow of the front-end component through a preset plug-in of a custom build tool during the entire compilation process of the front-end component, perform various tests in real time in the compilation flow and produce reports, so that developers can understand the quality of this component more easily, quickly, clearly and comprehensively, breaking through the limitations of front-end component detection in existing technologies, and ultimately achieving the purpose of optimizing components, improving performance and reducing bugs.
[0063] In the embodiment of the present disclosure, the compiled resources of the front-end component include source files such as JavaScript, CSS, image data, etc. Compilation is a step in the construction process of the front-end construction tool, which refers to the process of converting source code into an executable program or library.
[0064] Compilation usually includes steps such as lexical analysis, syntax analysis, semantic analysis, and code generation. The compilation flow can refer to the data flow in the entire compilation process.
[0065] In this embodiment, the front-end building tool can be webpack, rollup or vite, etc., which is not limited here. Taking webpack as an example, webpack is a static module bundler. Webpack builds a dependency graph internally, which maps to each front-end component required by the project and generates one or more bundles.
[0066] In the embodiment of the present disclosure, loading a preset plug-in in a front-end building tool includes:
[0067] Declaratively mount the preset plug-in to each node in the compilation flow to collect the compilation resources of the corresponding node when the corresponding node is running.
[0068] In this embodiment, the preset plug-in is injected into each node of the compilation flow in a declarative manner, so that when the corresponding compilation flow node is run, the preset plug-in is automatically called to perform corresponding functions, such as automatically collecting compilation resources and performing automatic detection.
[0069] This implementation can dynamically load the preset plug-in of this embodiment into the compilation service without intruding the compilation process, and the preset plug-in and the compilation service belong to the same process to run asynchronously and in parallel with the compilation.
[0070] Combination Figure 2 As shown, the preset plug-in is mounted in the early compilation stage of the front-end component declaration cycle based on a declarative method (corresponding to the compilation input node above), and is configured to collect the original addresses (deppaths) of each compilation resource with dependencies, and extract the pre-compilation code based on the original addresses.
[0071] The preset plug-in is mounted in a declarative manner at the end of the compilation of the front-end component declaration cycle, and is configured to collect the final compilation results, including the compiled code above.
[0072] Continue as Figure 2 As shown, based on the preset plug-in, mock attribute information and configuration information are also read, where mock is a testing technology used in software development. It can simulate a virtual function implementation when the actual code has not yet been implemented for testing and debugging. The purpose of mock testing is to test specific parts of the software without relying on the real system, so as to find and solve problems faster.
[0073] therefore, Figure 2 The mock attribute information and configuration information shown correspond to the virtual attribute information and configuration information above, and are used for subsequent simulation tests on front-end components.
[0074] This implementation provides a preset plug-in in a declarative manner, which not only enables automated detection, but also provides custom configuration, so that users can customize the preset plug-in to meet personalized needs.
[0075] Take webpack as an example, it has a built-in LabeledModulesPlugin plug-in, which allows custom configuration and import of preset plug-ins. The preset plug-in can hook into each compilation flow node, and at each stage of compilation, the plug-in has full access to the compilation flow nodes.
[0076] Specifically, webpack creates various hooks on internal objects, including creating hooks at the corresponding nodes of the compilation flow, at which time the preset plug-in is registered to the corresponding hook in a declarative manner. When the corresponding node of the compilation flow runs, the preset plug-in is triggered to collect the compilation resources required by the corresponding node.
[0077] Specifically, collecting the compilation resources when the corresponding node is running includes at least one of the following situations:
[0078] Collect pre-compilation code in the hook function of the compilation input node;
[0079] Collect the compiled code in the hook function of the compilation output node;
[0080] Read the virtual attribute information and configuration information required for front-end component rendering from the root directory of the front-end component.
[0081] Therefore, the compiled resources include pre-compiled code, compiled code, virtual attribute information and configuration information required for front-end component rendering, etc. The pre-compiled code corresponds to the source file or source code mentioned above, and the compiled code corresponds to the executable file, executable program, etc. mentioned above, which can constitute part of the front-end component.
[0082] The above hook function is specifically used to provide corresponding compilation operations for corresponding compilation resources. The compilation resources used in the compilation input node are source files containing pre-compilation codes, while the compilation resources in the compilation output node are compiled codes. Among them, the above virtual attribute information and configuration information are used to render output in combination with the compiled codes.
[0083] In an optional implementation, calling a detection method corresponding to a compilation resource to detect the compilation resource and generate a detection report of the front-end component includes:
[0084] For pre-compiled code or post-compiled code, call the code detection tool to perform code detection and generate a code detection report.
[0085] In this implementation, a calling instruction for a code detection tool is configured in a preset plug-in, and a code detection report is generated by performing static code detection on pre-compiled code or post-compiled code by calling the code detection tool.
[0086] like Figure 2 As shown, for the CSS code before compilation, the following detection is performed:
[0087] Call the code detection tool to perform abstract syntax tree AST (Abstract Syntax Tree) analysis on the CSS code before compilation, perform code detection on the abstract syntax tree, generate CSS problems, and output a code detection report based on the CSS problems. CSS problems may include unreasonable writing, overly simple naming, and other non-standard problems.
[0088] Call static analysis tools, such as stylelint and postcss, to check the CSS code. If there are any problems, a problem alert is generated.
[0089] CSS code volume size, analyze the size, and generate a size warning if there is a problem.
[0090] As mentioned above, static code analysis is an automated code analysis method that detects potential programming errors, security vulnerabilities, and other problems by checking the syntax, structure, and data flow of the code. In this sense, the above static analysis tools are also code detection tools. For the type of code detection tool, you can choose to call the appropriate code detection tool according to the specific problem you need to detect. For example, stylelint is a CSS code checker (linter) that can perform error checking on style sheets by defining a series of coding style rules to keep a consistent coding style.
[0091] For example, postcss provides a way to process CSS with JavaScript code. It is responsible for parsing CSS code into an abstract syntax tree structure, which is then handed over to specific plug-ins for processing. The plug-in can perform a variety of operations based on the AST of CSS code, such as supporting variables and mixins, adding browser-related declaration prefixes, or translating style rules using future CSS specifications into a format supported by the current CSS specification.
[0092] Continue as Figure 2 As shown, code detection for JS code before compilation may include:
[0093] By parsing Ast from the JS code before compilation and performing code analysis on Ast, JS problems are generated;
[0094] Call static analysis tools, such as ESlint, JSHint, or JSLint, to perform static code analysis on the JS code before compilation and output JS problems;
[0095] Get the size of the Js code before compilation, analyze the size, and generate a size warning if there is a problem.
[0096] Among them, ESLint is a configurable JavaScript checker, a code detection tool used to identify JavaScript and give reports according to the rules. Its purpose is to make the code style more consistent and avoid errors.
[0097] Among them, JShint is a javascript syntax and style checking tool.
[0098] In the embodiments of the present disclosure, Figure 2 As shown, for the compiled JS bundle, that is, the compiled packaged module, based on the preset plug-in, the unit test plug-in is called to perform unit testing on the compiled packaged module, and a unit test report of the front-end component is generated.
[0099] Among them, unit testing UT (unit testing), also known as simulation run detection tasks, refers to the work of checking and verifying the smallest testable unit in the compiled packaged module in isolation from other parts of the program. The smallest testable unit here usually refers to a function or a class. The purpose of unit testing is to detect whether the execution process and output of the corresponding function meet expectations under all possible inputs.
[0100] The compiled and packaged module may be a component module in the front-end component, and may specifically be a unit module obtained by compiling a function that can specifically execute a certain function.
[0101] This embodiment can implement unit testing for compiled code. Specifically, the unit test plug-in is implemented by the Jest tool, which is a JavaScript test runner, that is, a JavaScript library for creating, running and structuring tests.
[0102] In an optional implementation, calling a detection method corresponding to a compilation resource to detect the compilation resource and generate a detection report of the front-end component includes:
[0103] The server-side renderer is called, and the server-side rendering is simulated using the virtual attribute information and configuration information. The server-side rendering process is detected to generate a server-side rendering detection report.
[0104] In this implementation, virtual attribute information and configuration information are used to simulate server-side rendering SSR (ServerSide Render). SSR is to render the page content on the server side, and the browser directly displays the HTML returned by the server. Among them, the server-side rendering generates a virtual DOM (Document Object Model) view. The DOM view here depicts the document HTML as a structure composed of multiple nodes. In this way, the entire SSR process and DOM view can be detected to obtain a server-side rendering detection report.
[0105] This implementation simulates SSR to detect the SSR process and output an SSR detection result, which corresponds to the server-side rendering detection report above, including rendering errors or rendering execution time, etc.
[0106] As a specific implementation method, call React Dom Server to perform mock ssr rendering. React Dom Server is a server-side renderer, and mock ssr render stands for simulated SSR rendering.
[0107] In an optional implementation, virtual attribute information and configuration information can also be used to simulate client-side rendering CSR (Client-Side Rendering). In this mode, the server is mainly responsible for providing static HTML files (which may contain some basic HTML structures and JavaScript scripts), while the actual page rendering work is completely completed by the client's browser. This means that the page content is dynamically generated on the user's browser.
[0108] Specifically, CSR relies on Ajax or Fetch API to asynchronously obtain data from the server and builds a DOM tree on the browser side through JavaScript libraries (such as React, Vue, Angular, etc.).
[0109] Using this implementation, the client renderer is called, and the virtual attribute information and configuration information are used to simulate the client rendering. By detecting the client rendering process, a client rendering detection report is generated, such as Figure 2 The output CSR result is shown, which includes error or profile.
[0110] In the embodiments of the present disclosure, Figure 3 As shown, Figure 3 This is a flowchart of another front-end component detection method provided by an embodiment of the present disclosure, and the method includes but is not limited to the following steps:
[0111] Step 310: Load the preset plug-in in the front-end building tool;
[0112] Step 320: calling a preset plug-in to collect compilation resources of the front-end component in a compilation flow based on a build tool;
[0113] Step 330: calling the detection method corresponding to the compilation resource, detecting the compilation resource, and generating a detection report of the front-end component;
[0114] Step 340: when the detection report shows that the corresponding node in the compilation flow does not meet the standard, an exception is thrown and the compilation flow is terminated, that is, an exception is thrown and the compilation is exited.
[0115] This implementation proposes a restricted compilation method to enable users to solve abnormal problems in a timely manner and limit the release of low-quality code. At the same time, by stopping losses in time, the front-end component detection efficiency is also improved.
[0116] In one embodiment, as exemplified above, in combination Figure 2 As shown, unit testing is performed on the compiled and packaged modules contained in the front-end components, which includes testing the code coverage. The code coverage is how much of the code is covered after running the test, which codes are run and which are not run.
[0117] If the unit test code coverage reaches a certain value, continue to the next step of compilation;
[0118] If the unit test code coverage reaches a certain value, an exception is thrown and the compilation flow is terminated.
[0119] This is an example. For any of the above code detections, certain judgment conditions for terminating compilation or continuing compilation can be set, which are not limited here.
[0120] In an optional embodiment, the above test report can also be displayed through a user interface to intuitively display the test results. Figure 4 As shown, the front-end component detection method provided in the optional embodiment of the present disclosure may include but is not limited to the following steps:
[0121] Step 410: Loading the preset plug-in in the front-end building tool;
[0122] Step 420: calling a preset plug-in to collect compilation resources of the front-end component in a compilation flow based on a build tool;
[0123] Step 430: calling the detection method corresponding to the compilation resource, detecting the compilation resource, and generating a detection report of the front-end component;
[0124] Step 440: Render the detection report of the front-end component and the compiled and packaged module of the front-end component, and display the rendering page of the detection report and the rendering page of the compiled and packaged module.
[0125] like Figure 5 As shown in the figure, the detection report and the rendering interface of the corresponding module in the front-end component are displayed on the same interface, which can intuitively display the possible problems in the detection report and where the problems are. At the same time, based on the rendering interface of the corresponding module, users can intuitively view the rendering effect, allowing developers to understand the quality of this component more easily, quickly, clearly and comprehensively, so as to ultimately achieve the purpose of optimizing components, improving performance and reducing bugs.
[0126] Alternatively, another job-type application may be started, and according to the steps of the above embodiment, the detection of all online front-end components may be performed regularly (the above steps), and alarms or restrictions may be issued by detecting the indicators therein.
[0127] like Figure 5 As shown, the upper left corner displays the component JS size, component CSS size, SSR simulation rendering detection results and CSR simulation rendering detection results, where the SSR simulation rendering detection results include execution time, rendering results and rendering error information, and the CSR simulation rendering detection results include rendering error information.
[0128] Figure 5 The upper right corner shows the ESLint code detection results, CSS code detection results (problems) (such as the existence of names that may cause global style conflicts) and StyleLint detection results.
[0129] Figure 5 The lower left corner shows another ESLint detection result, and a detailed list of errors is shown.
[0130] Figure 5 The lower right corner shows the UT result (code coverage), another SSR simulation rendering result and a CSR simulation rendering result, where the CSR simulation rendering result is a specific pattern. Figure 5 Use the word "pattern" to represent.
[0131] In the embodiment of the present disclosure, before executing step 440, the detection report including all detection items is also stored on the ground.
[0132] Figure 6 FIG. 1 is a schematic diagram of the structure of the front-end component detection system of this embodiment. Figure 6 As shown, the front-end component detection system 600 of this embodiment includes:
[0133] A loading module 610 loads a preset plug-in in a front-end building tool;
[0134] The collection module 620 calls a preset plug-in to collect compilation resources of the front-end component in the compilation flow based on the build tool;
[0135] The detection module 630 calls the detection method corresponding to the compiled resource, detects the compiled resource, and generates a detection report of the front-end component.
[0136] In an optional embodiment, the loading module 610 is specifically used for:
[0137] Declaratively mount the preset plug-in to each node in the compilation flow to collect the compilation resources of the corresponding node when the corresponding node is running.
[0138] In an optional embodiment, the acquisition module 620 is specifically used for:
[0139] When the corresponding node is running, the compilation resources of the corresponding node are collected when the corresponding node is running, including at least one of the following situations:
[0140] Collect pre-compilation code in the hook function of the compilation input node;
[0141] Collect the compiled code in the hook function of the compilation output node;
[0142] Read the virtual attribute information and configuration information required for front-end component rendering from the root directory of the front-end component.
[0143] In an optional embodiment, the detection module 630 is specifically used for:
[0144] For pre-compiled code or post-compiled code, call the code detection tool to perform code detection and generate a code detection report.
[0145] In an optional embodiment, the detection module 630 is specifically used for:
[0146] The code detection tool is called to parse the pre-compiled code into an abstract syntax tree, and the code detection is performed on the abstract syntax tree.
[0147] In an optional embodiment, the detection module 630 is specifically used for:
[0148] Call the server-side renderer, use virtual attribute information and configuration information to simulate server-side rendering, and generate a server-side rendering detection report by detecting the server-side rendering process.
[0149] In an optional embodiment, the detection module 630 is specifically used for:
[0150] Based on the preset plug-in, the compiled and packaged modules of the compiled resources are collected so as to call the unit test plug-in to perform unit test on the compiled and packaged modules and generate a unit test report for the front-end components.
[0151] In an optional embodiment, the detection module 630 is further configured to:
[0152] The front-end component detection method also includes:
[0153] When the detection report shows that the corresponding node in the compilation flow does not meet the requirements, an exception is thrown and the compilation flow is terminated.
[0154] In an alternative embodiment, Figure 6 compared to, Figure 7 The front-end component detection system 700 further includes:
[0155] The display module 700 performs rendering on the detection report of the front-end component and the compiled and packaged module of the front-end component, and displays the rendering page of the detection report and the rendering page of the compiled and packaged module.
[0156] The disclosed embodiment provides a front-end component detection system, which can intervene in the compilation flow of the front-end component through a preset plug-in of a custom build tool during the entire compilation process of the front-end component, perform various detections in real time in the compilation flow and produce reports, so that developers can understand the quality of this component more easily, quickly, clearly and comprehensively, breaking through the limitations of the front-end component detection technology of the prior art, so as to ultimately achieve the purpose of optimizing components, improving performance and reducing bugs.
[0157] This embodiment also provides an electronic device, including a processor and a memory storing executable instructions of the processor, wherein the processor is configured to execute the steps of the front-end component detection method by executing the executable instructions.
[0158] As mentioned above, the electronic device of this embodiment can intervene in the compilation flow of the front-end component through a preset plug-in of a custom build tool during the entire compilation process of the front-end component, perform various tests in real time in the compilation flow and produce reports, so that developers can understand the quality of this component more easily, quickly, clearly and comprehensively, breaking through the limitations of front-end component detection in the prior art, and ultimately achieving the purpose of optimizing components, improving performance and reducing bugs.
[0159] It will be appreciated by those skilled in the art that various aspects of the present embodiment may be implemented as a system, method or program product. Therefore, various aspects of the present embodiment may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "platform".
[0160] Figure 8 Schematic diagram of the structure of the electronic device of this embodiment. Figure 8 An electronic device 800 according to this embodiment of the present embodiment will be described. Figure 8 The electronic device 800 shown is merely an example and should not limit the functions and scope of use of this embodiment.
[0161] like Figure 8 As shown, the electronic device 800 is in the form of a general computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one storage unit 820, a bus 830 connecting different platform components (including the storage unit 820 and the processing unit 810), a display unit 840, etc.
[0162] The storage unit stores program codes, which can be executed by the processing unit 810, so that the processing unit 810 performs the steps of various exemplary embodiments of the present embodiment described in the front-end component detection method section of this specification. For example, the processing unit 810 can perform the following steps: Figure 1 , Figure 3 or Figure 4 The steps shown in any one of the embodiments.
[0163] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 821 and / or a cache memory unit 822 , and may further include a read-only memory unit (ROM) 823 .
[0164] The storage unit 820 may also include a program / utility 824 having a set (at least one) of program modules 825, such program modules 825 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0165] Bus 830 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0166] The electronic device 800 may also communicate with one or more external devices 80 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 800, and / or communicate with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 850. Furthermore, the electronic device 800 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 860. The network adapter 860 may communicate with other modules of the electronic device 800 via a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage platforms, etc.
[0167] This embodiment also provides a computer-readable storage medium for storing a program, and the steps of the front-end component detection method are implemented when the program is executed. In some possible implementations, various aspects of this implementation can also be implemented in the form of a program product, which includes a program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps of various exemplary implementations of this implementation described in the front-end component detection method section of this specification.
[0168] As shown above, when the program of the computer-readable storage medium of this embodiment is executed, it can intervene in the compilation flow of the front-end component through a preset plug-in of a custom build tool during the entire compilation process of the front-end component, perform various tests in real time in the compilation flow and produce reports, so that developers can understand the quality of this component more easily, quickly, clearly and comprehensively, breaking through the limitations of the front-end component detection of the prior art, thereby ultimately achieving the purpose of optimizing components, improving performance and reducing bugs.
[0169] Fig. 9 Schematic diagram of the structure of the computer-readable storage medium of this embodiment. Fig. 9 As shown, a program product 900 for implementing the above method according to an embodiment of the present embodiment is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present embodiment is not limited thereto, and in this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0170] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0171] Computer readable storage media may include data signals propagated in baseband or as part of a carrier wave, wherein readable program codes are carried. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program codes contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.
[0172] The program code for performing the operations of the present embodiment may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0173] In summary, the front-end component detection method, system, device and storage medium of the present embodiment can intervene in the compilation flow of the front-end component through a preset plug-in of a custom build tool during the entire compilation process of the front-end component, perform various detections in real time in the compilation flow and produce reports, so that developers can understand the quality of this component more easily, quickly, clearly and comprehensively, breaking through the limitations of the front-end component detection of the prior art, and ultimately achieving the purpose of optimizing components, improving performance and reducing bugs.
[0174] The above content is a further detailed description of the present embodiment in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present embodiment is limited to these descriptions. For ordinary technicians in the technical field to which the present embodiment belongs, several simple deductions or substitutions can be made without departing from the concept of the present embodiment, which should be regarded as falling within the protection scope of the present embodiment.
Claims
1. A front-end component detection method, characterized in that: include: Load the preset plugin in the front-end building tool; Calling the preset plug-in to collect compilation resources of the front-end component in a compilation flow based on the build tool; The detection method corresponding to the compilation resource is called to detect the compilation resource, and a detection report of the front-end component is generated.
2. The front-end component detection method according to claim 1, characterized in that: The loading of the preset plug-in in the front-end building tool includes: The preset plug-in is mounted to each node in the compilation flow in a declarative manner, so as to collect the compilation resources when the corresponding node is running.
3. The front-end component detection method according to claim 2, characterized in that: When the corresponding node is running, collecting the compilation resources when the corresponding node is running includes at least one of the following situations: Collect pre-compilation code in the hook function of the compilation input node; Collect the compiled code in the hook function of the compilation output node; The virtual attribute information and configuration information required for rendering the front-end component are read from the root directory of the front-end component.
4. The front-end component detection method according to claim 3, characterized in that: The calling of the detection method corresponding to the compilation resource, detecting the compilation resource, and generating a detection report of the front-end component includes: For the pre-compiled code or the compiled code, a code detection tool is called to perform code detection and generate a code detection report.
5. The front-end component detection method according to claim 4, characterized in that: The calling of the code detection tool to perform code detection includes: The code detection tool is called to parse the pre-compiled code to obtain an abstract syntax tree, and code detection is performed on the abstract syntax tree.
6. The front-end component detection method according to claim 3, characterized in that: The calling of the detection method corresponding to the compilation resource, detecting the compilation resource, and generating a detection report of the front-end component includes: The server-side renderer is called, the virtual attribute information and the configuration information are used to simulate the server-side rendering, and a server-side rendering detection report is generated by detecting the server-side rendering process.
7. The front-end component detection method according to claim 1, characterized in that: The calling of the preset plug-in to collect the compilation resources of the front-end component in the compilation flow based on the construction tool includes: Based on the preset plug-in, the compiled packaged module of the compiled resource is collected, so as to call the unit test plug-in to perform unit test on the compiled packaged module and generate a unit test report of the front-end component.
8. The front-end component detection method according to claim 1, characterized in that: The front-end component detection method further includes: When the detection report shows that the corresponding node in the compilation flow does not meet the standard, an exception is thrown and the compilation flow is terminated.
9. The front-end component detection method according to claim 1, characterized in that: The front-end component detection method further includes: Rendering is performed on the detection report of the front-end component and the compiled and packaged module of the front-end component, and the rendering page of the detection report and the rendering page of the compiled and packaged module are displayed at the same time.
10. A front-end component detection system, characterized in that: include: Load the module and load the preset plug-in in the front-end building tool; A collection module, calling the preset plug-in to collect the compilation resources of the front-end component in the compilation flow based on the construction tool; The detection module calls the detection method corresponding to the compilation resource, detects the compilation resource, and generates a detection report of the front-end component.
11. An electronic device, characterized in that: include: processor; a memory storing executable instructions of the processor; The processor is configured to execute the steps of the front-end component detection method according to any one of claims 1 to 9 by executing the executable instructions.
12. A computer-readable storage medium for storing a program, characterized in that: When the program is executed, the steps of the front-end component detection method according to any one of claims 1 to 9 are implemented.
Citation Information
Cited By
Method, device, medium and product for verifying internationalized translation key in real time based on construction tool and ESLint rule
CN121503502A
