CN109766099A - Front end source code Compilation Method, device, storage medium and computer equipment - Google Patents

Front end source code Compilation Method, device, storage medium and computer equipment Download PDF

Info

Publication number
CN109766099A
CN109766099A CN201811511759.0A CN201811511759A CN109766099A CN 109766099 A CN109766099 A CN 109766099A CN 201811511759 A CN201811511759 A CN 201811511759A CN 109766099 A CN109766099 A CN 109766099A
Authority
CN
China
Prior art keywords
code
compiled
end source
source code
document
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201811511759.0A
Other languages
Chinese (zh)
Other versions
CN109766099B (en
Inventor
林法鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Koubei Network Technology Co Ltd
Original Assignee
Zhejiang Koubei Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Koubei Network Technology Co Ltd filed Critical Zhejiang Koubei Network Technology Co Ltd
Priority to CN201811511759.0A priority Critical patent/CN109766099B/en
Publication of CN109766099A publication Critical patent/CN109766099A/en
Application granted granted Critical
Publication of CN109766099B publication Critical patent/CN109766099B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention discloses a kind of front end source code Compilation Method, device, storage medium and computer equipments, it is related to browser technology field, main purpose, which is can be realized, is directly locally compiled the front end source code in browser, without additional compiling constructing environment, front end development process can be simplified, and then it is able to ascend front end development efficiency, which comprises in the corresponding dependence packet of the locally-installed front end source code of browser, obtain the corresponding dependent file of the front end source code;The document code dependence of the front end source code is analyzed using the loader built in the browser, and the front end source code is compiled according to the document code dependence and the dependent file.The present invention is suitable for the compiling of front end source code.

Description

Front end source code Compilation Method, device, storage medium and computer equipment
Technical field
The present invention relates to browser technology fields, more particularly to a kind of front end source code Compilation Method, device, storage medium And computer equipment.
Background technique
With the continuous development of information technology, in order to meet the work and life needs of people, the function of browser is more next It is more powerful, various front end pages can be shown, these usual pages are the front-end sources by compilation run browser What code was realized.
At present, it usually needs additional compiling constructing environment is compiled building to front end source code.However, due to additional Compiling constructing environment builds complexity, using complex steps, gets higher so as to cause front end development cost, and development efficiency reduces.
Summary of the invention
In view of this, the present invention provides a kind of front end source code Compilation Method, device, storage medium and computer equipment, it is main Syllabus be can be realized directly browser locally the front end source code is compiled, without additional compiling structure Environment is built, front end development process can be simplified, so as to promote front end development efficiency.
According to the present invention in a first aspect, providing a kind of front end source code Compilation Method, comprising:
In the corresponding dependence packet of the locally-installed front end source code of browser, the corresponding dependent file of the front end source code is obtained;
The document code dependence of the front end source code is analyzed using the loader built in the browser, and according to institute Document code dependence and the dependent file is stated to be compiled the front end source code.
Optionally, the document code that the loader using built in the browser analyzes the front end source code, which relies on, to close System, and the front end source code is compiled according to the document code dependence and the dependent file, comprising:
The first document code in the front end source code is obtained, and obtains the first file generation from the dependent file The corresponding dependent file of code;
It is corresponding to first document code and first document code using the loader built in the browser Dependent file is compiled, and obtains the corresponding compiled code of first document code;
According to the code module specification of the corresponding compiled code of first document code, the first file generation is inquired The second document code that code is relied on, the code module specification preserve first document code and the second file generation Dependence between code;
Compiling is executed to second document code and inquires the operation of relied on document code, it is described until having compiled Document code in the source code of front end.
Optionally, the loader using built in the browser is to first document code and first file The corresponding dependent file of code is compiled, and obtains the corresponding compiled code of first document code, comprising:
It is searched from the loader built in the browser according to the file type of first document code and described the The corresponding loader of one document code, different loaders are used to compile the document code of different file types;
Using lookup loader to first document code and the corresponding dependent file of first document code into Row compiling, obtains the corresponding compiled code of first document code.
Further, described that the front end source code is carried out according to the document code dependence and the dependent file After compiling, the method also includes:
According to the document code dependence and the corresponding compiled code of the front end source code, compiled code is generated Dependence graph;
Using the code loading environment and the compiled code dependence graph simulated in advance, the front end source code is loaded Corresponding compiled code is simultaneously run.
Optionally, described to utilize the code loading environment simulated in advance and the compiled code dependence graph, load The corresponding compiled code of the front end source code is simultaneously run, comprising:
First in the corresponding compiled code of the front end source code is loaded using the code loading environment simulated in advance to compile Translate post code;
If after the second compiling relied in the compiled code dependence graph there are first compiled code Code then loads second compiled code;
If there is no the second compilings that first compiled code is relied in the compiled code dependence graph Post code then runs first compiled code.
Optionally, described in the corresponding dependence packet of the locally-installed front end source code of browser, it is corresponding to obtain the front end source code Dependent file, comprising:
Obtain the dependence package informatin that reliance server is sent;
The corresponding download address for relying on packet of the front end source code is searched from the dependence package informatin, and according under described Set address downloads the corresponding dependence packet of the front end source code;
The corresponding dependence of the front end source code is wrapped and carries out decompression processing, and by the dependent file persistent storage after decompression It is local in the browser.
Optionally, described in the corresponding dependence packet of the locally-installed front end source code of browser, obtain the front end source code Corresponding dependent file, comprising:
Dependent file acquisition request is sent to proxy server, it is corresponding that the front end source code is carried in the acquisition request Dependence packet identification information;The proxy server is used to download the front end source code according to the dependence packet identification information corresponding Dependence packet and decompressed, obtain the corresponding dependent file of the front end source code;
It is local that the dependent file persistence that the reliance server is fed back is buffered in the browser.
Optionally, described in the corresponding dependence packet of the locally-installed front end source code of browser, obtain the front end source code Corresponding dependent file, comprising:
Obtain the corresponding version information of the front end source code;
According to the version information in the corresponding dependence packet of the locally-installed front end source code of browser, the front end is obtained The corresponding dependent file of source code.
Second aspect according to the present invention provides a kind of front end source code compilation device, comprising:
Installation unit, for obtaining the front end source code pair in the corresponding dependence packet of the locally-installed front end source code of browser The dependent file answered;
Compilation unit, the document code for being analyzed the front end source code using the loader built in the browser are relied on Relationship, and the front end source code is compiled according to the document code dependence and the dependent file.
Optionally, the compilation unit includes:
Module is obtained, is obtained for obtaining the first document code in the front end source code, and from the dependent file The corresponding dependent file of first document code;
Collector, for utilizing the loader built in the browser to first document code and first text The corresponding dependent file of part code is compiled, and obtains the corresponding compiled code of first document code;
Enquiry module, for the code module specification according to the corresponding compiled code of first document code, inquiry The second document code that first document code is relied on, the code module specification preserve first document code with Dependence between second document code;
The collector is also used to execute second document code compiling and inquires relied on document code Operation, until having compiled the document code in the front end source code.
Optionally, the collector, specifically for according to the file type of first document code from the browsing Loader corresponding with first document code is searched in loader built in device, different loaders is for compiling not identical text The document code of part type;Using the loader of lookup it is corresponding to first document code and first document code according to Bad file is compiled, and obtains the corresponding compiled code of first document code.
Further, described device further include:
Generation unit is used for according to the document code dependence and the corresponding compiled code of the front end source code, Generate compiled code dependence graph;
Running unit, for adding using the code loading environment and the compiled code dependence graph simulated in advance It carries the corresponding compiled code of the front end source code and runs.
Optionally, the running unit, specifically for loading the front-end source using the code loading environment simulated in advance The first compiled code in the corresponding compiled code of code;If in the compiled code dependence graph, there are described first The second compiled code that compiled code is relied on then loads second compiled code;If the compiled code according to Rely and the second compiled code that first compiled code is relied on is not present in relational graph, then after running first compiling Code.
Optionally, the installation unit, the dependence package informatin sent specifically for obtaining reliance server;From the dependence The corresponding download address for relying on packet of the front end source code is searched in package informatin, and the front end is downloaded according to the download address The corresponding dependence packet of source code;The corresponding dependence of the front end source code is wrapped and carries out decompression processing, and by the dependent file after decompression Persistent storage is local in the browser.
Optionally, the installation unit is specifically used for sending dependent file acquisition request, the acquisition to proxy server The corresponding dependence packet identification information of the front end source code is carried in request;The proxy server is used to be wrapped according to the dependence Identification information downloads the corresponding dependence of the front end source code and wraps and decompressed, and obtains the corresponding dependence text of the front end source code Part;It is local that the dependent file persistence that the reliance server is fed back is buffered in the browser.
The installation unit is specifically used for obtaining the corresponding version information of the front end source code;According to the version information In the corresponding dependence packet of the locally-installed front end source code of browser, the corresponding dependent file of the front end source code is obtained.
The third aspect according to the present invention provides a kind of storage medium, and at least one is stored in the storage medium to hold Row instruction, described execute instruction make processor execute following steps:
In the corresponding dependence packet of the locally-installed front end source code of browser, the corresponding dependent file of the front end source code is obtained;
The document code dependence of the front end source code is analyzed using the loader built in the browser, and according to institute Document code dependence and the dependent file is stated to be compiled the front end source code.
Fourth aspect according to the present invention, provides a kind of computer equipment, including processor, memory, communication interface and Processor described in communication bus, the memory and the communication interface complete mutual communication by the communication bus, The memory makes the processor execute following steps for storing an at least executable instruction, the executable instruction:
In the corresponding dependence packet of the locally-installed front end source code of browser, the corresponding dependent file of the front end source code is obtained;
The document code dependence of the front end source code is analyzed using the loader built in the browser, and according to institute Document code dependence and the dependent file is stated to be compiled the front end source code.
The present invention provides a kind of front end source code Compilation Method, device, storage medium and computer equipment, and needs volume at present Outer compiling constructing environment is compiled building to front end source code and compares, and the present invention passes through in the locally-installed front end source code of browser Corresponding dependence packet, obtains the corresponding dependent file of the front end source code;Institute is analyzed using the loader built in the browser State the document code dependence of front end source code, and according to the document code dependence and the dependent file to before described End source code is compiled, and be can be realized and is directly locally compiled to the front end source code in browser, without by volume Outer compiling constructing environment, can simplify front end development process, and then be able to ascend front end development efficiency.
The above description is only an overview of the technical scheme of the present invention, in order to better understand the technical means of the present invention, And it can be implemented in accordance with the contents of the specification, and in order to allow above and other objects of the present invention, feature and advantage can It is clearer and more comprehensible, the followings are specific embodiments of the present invention.
Detailed description of the invention
By reading the following detailed description of the preferred embodiment, various other advantages and benefits are common for this field Technical staff will become clear.The drawings are only for the purpose of illustrating a preferred embodiment, and is not considered as to the present invention Limitation.And throughout the drawings, the same reference numbers will be used to refer to the same parts.In the accompanying drawings:
Fig. 1 shows a kind of flow diagram of front end source code Compilation Method provided in an embodiment of the present invention;
Fig. 2 shows a kind of structural schematic diagrams of front end source code compilation device provided in an embodiment of the present invention;
Fig. 3 shows the structural schematic diagram of another front end source code compilation device provided in an embodiment of the present invention;
Fig. 4 shows a kind of entity structure schematic diagram of computer equipment provided in an embodiment of the present invention.
Specific embodiment
Exemplary embodiments of the present disclosure are described in more detail below with reference to accompanying drawings.Although showing the disclosure in attached drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here It is limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure It is fully disclosed to those skilled in the art.
As stated in the background art, at present it is generally necessary to which additional compiling constructing environment is compiled building to front end source code. However, using complex steps, getting higher, opening so as to cause front end development cost since additional compiling constructing environment builds complexity Sending out efficiency reduces.
In order to solve the above-mentioned technical problem, the embodiment of the invention provides a kind of front end source code Compilation Methods, such as Fig. 1 institute Show, which comprises
101, in the corresponding dependence packet of the locally-installed front end source code of browser, the corresponding dependence text of the front end source code is obtained Part.
Wherein, the front end source code can be code that software is developed using front end, and specifically the front end source code can be with For the code for developing software development using javascrip code language, the running environment that javascrip develops software is Node.js running environment, the code packet management tool under node.js running environment can be npm, therefore, when the front-end source When code is javascrip code, packet can be relied in the locally-installed npm of browser.The dependence packet is specifically as follows message Body-resolver (body-parser) relies on packet, caching-resolver (cookie-parser) relies on packet, compiling (debug) relies on Packet, template library (ejs) rely on packet, Development Framework (express) relies on packet, page banner request (serve-favicon) relies on Packet, distribution type file storing data library (mongodb) rely on packet etc..Installing the dependent file that above-mentioned dependence is wrapped can be Body-parser, cookie-parser, debug, ejs, express, serve-favicon, mongodb etc..
For the embodiment of the present invention, by being wrapped in the corresponding dependence of the locally-installed front end source code of browser, can be realized by Dependence packet is completely analyzed and installed to browser end, and can be realized and provide the compiling of front end source code or operation institute by browser end The dependence resource needed is compiled or transports it is not necessary that front end source code to be transformed into the corresponding running environment of front end exploitation software Row.Further, since dependent file is stored in browser local, when the dependence of source code changes in front end, available change Dependent file afterwards, without obtaining all dependent files, so as to mitigate the pressure for obtaining front end source code and relying on.
102, the document code dependence of the front end source code, and root are analyzed using the loader built in the browser The front end source code is compiled according to the document code dependence and the dependent file.
Wherein, the front end source code may include multiple document codes, and the document code dependence can be described Dependence between multiple document codes, the adduction relationship being specifically as follows between document code, document code can be quoted With the document code in packet, the document code across packet can also be quoted.For example, if 1 reference document code 2 of document code, file 2 reference document code 3 of code, then there are dependence, document code 2 and document codes between document code 1 and document code 2 There are dependences between 3.When between document code and alternative document code there are when dependence, the fortune of supporting paper code Row result needs to rely on the operation result of alternative document code.
It should be noted that the loader front end source code can correspond under front end exploitation software runtime environment according to Compile Project Realization, for example, can webpack compiling Project Realization under the node.js according to running environment, pass through reality The existing loader can realize the ability to the compiling of front end source code under browser environment.It is closed since the document code relies on System is stored in the code module specification of the corresponding compiled code of document code, can use the loader compiling front-end source Document code in code, obtains the corresponding compiled code of document code, then according to the corresponding compiled code of document code Code module specification, the alternative document code that locating file code is relied on, then the alternative document code that is relied on is repeated Above-mentioned steps, the compiling until completing entire front end source code.For the embodiment of the present invention, added by being realized in browser environment Device mechanism is carried, and using the document code dependence of front end source code described in loader mechanism analysis, and according to the file generation Code dependence and the dependent file are compiled the front end source code, can be realized directly local to described in browser Front end source code is compiled.
A kind of front end source code Compilation Method provided in an embodiment of the present invention, and needs additional compiling constructing environment pair at present Front end source code is compiled building and compares, and the embodiment of the present invention passes through in the corresponding dependence of the locally-installed front end source code of browser Packet, obtains the corresponding dependent file of the front end source code;The front end source code is analyzed using the loader built in the browser Document code dependence, and the front end source code is carried out according to the document code dependence and the dependent file Compiling can be realized and directly locally be compiled to the front end source code in browser, without by additional compiling structure Environment is built, front end development process can be simplified, and then is able to ascend front end development efficiency.
Further, in order to better illustrate the process of above-mentioned front end source code Compilation Method, as to above-described embodiment Refinement and extension, the embodiment of the invention provides several alternative embodiments, but not limited to this, it is specific as follows shown in:
It is described in order to realize the front end source code described in direct compilation in browser in an alternative embodiment of the invention Step 102 can specifically include: obtaining the first document code in the front end source code, and obtains institute from the dependent file State the corresponding dependent file of the first document code;Using the loader built in the browser to first document code and institute It states the corresponding dependent file of the first document code to be compiled, obtains the corresponding compiled code of first document code;Root According to the code module specification of the corresponding compiled code of first document code, inquire what first document code was relied on Second document code, the code module specification preserve between first document code and second document code according to The relationship of relying;Compiling is executed to second document code and inquires the operation of relied on document code, it is described until having compiled Document code in the source code of front end.It should be noted that obtaining corresponding volume by being compiled to first document code Translating post code can be the code for meeting front end development language code module specification, for javascript development language, Compiled code can be the code for meeting common.js module specification.In addition, compiling file code and inquiry document code institute The process of the document code of dependence repeats, when just starting to compile the front end source code, first document code It can be entry file code, be specifically as follows main document code, second document code can be entry file code The document code relied on.It, can be according to the compiled code of the entry file code after having compiled entry file code Code module specification, find the document code that the entry file code is relied on, then entry file code relied on Document code execute compiling file code and inquire the operation of document code that document code is relied on, described in compile All Files code in the source code of front end.
In concrete application scene, loader can be selected to the file according to the corresponding file type of document code Code is compiled, and the loader using built in the browser is to first document code and the first file generation The step of corresponding dependent file of code is compiled, and obtains first document code corresponding compiled code, specifically can be with It include: to be searched from the loader built in the browser according to the file type of first document code and first text The corresponding loader of part code, different loaders are used to compile the document code of different file types;Utilize the load of lookup Device is compiled first document code and the corresponding dependent file of first document code, obtains first file The corresponding compiled code of code.The file type can be picture type, video type, audio types etc..For example, if The file type of one document code is picture type, then can search from the loader built in the browser adding for picture type Device is carried as the load for compiling first document code.By selecting loader to file according to the file type of document code Code and the corresponding dependent file of document code are compiled, and can guarantee that corresponding compiled code meets front end development language generation Code module specification, so as to guarantee the accuracy of document code compiling.
In another alternative embodiment of the invention, the front end source code, wash with watercolours are directly run in browser in order to realize The final front end page for dyeing browser, after the step 102 the method also includes: according to the document code rely on Relationship and the corresponding compiled code of the front end source code generate compiled code dependence graph;Utilize the generation simulated in advance Code loading environment and the compiled code dependence graph, load the corresponding compiled code of the front end source code and run. Wherein, compiled code dependence graph can be consistent with document code dependence, for example, if existing such as in the source code of front end Lower document code dependence: 1 dependent file code 2 of document code, 2 dependent file code 3 of document code, document code 3 according to Rely document code 4, document code 4 does not depend on any document code, and generating compiled code dependence graph can show: text The 1 corresponding compiled code of corresponding compiled code dependent file code 2 of part code, the corresponding compiling offspring of document code 2 The corresponding compiled code of code dependent file code 3, the corresponding compiled code dependent file code 4 of document code 3 are corresponding Compiled code, document code 4 do not depend on any document code.Before the code loading environment simulated in advance can be according to The loading environment simulated implementation of end exploitation software, if front end source code is javascript code, the code simulated in advance Loading environment can be the loading environment of common.js.
In concrete application scene, described relied on using the code loading environment simulated in advance and the compiled code is closed System's figure, loads the corresponding compiled code of the front end source code and can specifically include the step of operation: utilizing what is simulated in advance Code loading environment loads the first compiled code in the corresponding compiled code of the front end source code;If the compiling offspring There are the second compiled codes that first compiled code is relied in code dependence graph, then load second compiling Post code;If after the second compiling relied in the compiled code dependence graph there is no first compiled code Code then runs first compiled code.The corresponding compiled code load of the front end source code and operate to repetition into Capable, when just starting the corresponding compiled code of front end source code described in load operating, first compiled code can be The corresponding compiled code of entry file code, is specifically as follows the corresponding compiled code of main document code, and described second The corresponding compiled code of document code that compiled code can be relied on by entry file code.Loading entry file After the corresponding compiled code of code, the corresponding compiled code of document code that load entrance document code is relied on, to institute The corresponding compiled code of the document code of dependence repeats the step of loading, until having loaded the corresponding compiling of the front end source code Post code, the compiled code for all loads of then reruning.For example, compiled code dependence graph can be shown: text The 1 corresponding compiled code of corresponding compiled code dependent file code 2 of part code, the corresponding compiling offspring of document code 2 The corresponding compiled code of code dependent file code 3, the corresponding compiled code dependent file code 4 of document code 3 are corresponding Compiled code, document code 4 do not depend on any document code.In load operating compiled code, first with common.js The corresponding compiled code of loading environment load document code 1, the then corresponding compiled code of load document code 2, text The corresponding compiled code of part code 3, the corresponding compiled code of last load document code 4, due to the operation of document code 4 Independent of any document code, then the corresponding compiled code of operating file code 4, having run, document code 4 is corresponding It is the corresponding compiled code of operating file code 3, the corresponding compiled code of operating file code 2, last after compiled code The corresponding compiled code of document code 1.
In another alternative embodiment of the invention, the step 101 be can specifically include: being obtained reliance server and is sent Dependence package informatin;The corresponding download address for relying on packet of the front end source code is searched in package informatin from described rely on, and according to The download address downloads the corresponding dependence packet of the front end source code;The front end source code corresponding dependence packet is carried out at decompression Reason, and the dependent file persistent storage after decompression is local in the browser.It specifically, can be from the dependence package informatin Middle lookup source code (tarball) field, dependence packet download address described in the tarball field references, the usual dependence Packet exists in a compressed format, relies on packet download address by pulling, the content of download address is read in a manner of byte stream, can be with It obtains relying on packet, obtains can use default decompression tool after relying on packet, the front end source code corresponding dependence packet is solved Pressure processing, the default decompression tool can be gzip decompression tool or tar decompression tool etc..In addition, decompressing for convenience Dependent file persistent storage afterwards can use browser encapsulation format in the memory of the browser local (BrowserFS) dependent file after decompression is packaged.
In addition, the embodiment of the invention provides a kind of optional corresponding mode for relying on packet of installation front end source code, the step Rapid 101 specifically can also include: to send dependent file acquisition request to proxy server, carry in the acquisition request described The corresponding dependence packet identification information of front end source code;The proxy server can be used for being downloaded according to the dependence packet identification information The corresponding dependence of the front end source code is wrapped and is decompressed, and the corresponding dependent file of the front end source code is obtained;By the dependence It is local that the dependent file persistence of server feedback is buffered in the browser.The proxy server can use front end exploitation Code packet management tool under the running environment of software downloads the corresponding dependence packet of the front end source code, decompresses the front end source code Corresponding dependence packet, and the dependent file after decompression is handed down to browser.Specifically, nodejs can be used in proxy server The npm tool downloading of environment relies on packet.Cross-domain technical problem, energy are downloaded by being able to solve browser using proxy server Enough realize that browser successfully downloads dependent file.
In yet another alternative embodiment of the invention, the step 101 be can specifically include: obtain the front end source code pair The version information answered;According to the version information in the corresponding dependence packet of the locally-installed front end source code of browser, institute is obtained State the corresponding dependent file of front end source code.It should be noted that technical staff is developing in order to enable front end source code is constantly complete When the source code of front end, it will usually be constantly modified to front end source code, therefore, usually there is the front end source code of multiple versions, pass through According to version information in the corresponding dependence packet of the locally-installed front end source code of browser, front end source code and installation can be avoided It relies on and there is conflict between packet, so as to guarantee front end source code normal compilation and operation.For example, if the front end source code is corresponding Version be version 1, then wrapped in corresponding dependences of the front end source code of the locally-installed version 1 of browser;If the front end source code pair The version answered is version 2, then in the corresponding dependence packet of the front end source code of the locally-installed version 2 of browser.
Further, as the specific implementation of Fig. 1, the embodiment of the invention provides a kind of front end source code compilation devices, such as Shown in Fig. 2, described device includes: installation unit 31 and compilation unit 32.
The installation unit 31, for obtaining the front end in the corresponding dependence packet of the locally-installed front end source code of browser The corresponding dependent file of source code.In the corresponding dependence of the locally-installed front end source code of browser in the present apparatus when installation unit 31 Packet, obtains the functional module of the corresponding dependent file of the front end source code.
The compilation unit 32, for analyzing the file generation of the front end source code using the loader built in the browser Code dependence, and the front end source code is compiled according to the document code dependence and the dependent file.Institute State compilation unit 32 be in the present apparatus using the loader built in the browser analyze the document code of the front end source code according to The relationship of relying, and the function mould that the front end source code is compiled according to the document code dependence and the dependent file Block and nucleus module.
In concrete application scene, as shown in figure 3, the compilation unit 32 may include: to obtain module 321, compiling mould Block 322, enquiry module 323.
The acquisition module 321, can be used for obtaining the first document code in the front end source code, and from the dependence The corresponding dependent file of first document code is obtained in file.
The collector 322 can be used for using the loader built in the browser to first document code Dependent file corresponding with first document code is compiled, and obtains the corresponding compiling offspring of first document code Code.
The enquiry module 323 can be used for the code mould according to the corresponding compiled code of first document code Slip gauge model, inquires the second document code that first document code is relied on, and the code module specification preserves described the Dependence between one document code and second document code.
The collector 322 can be also used for executing second document code compiling and inquire relied on text The operation of part code, until having compiled the document code in the front end source code.
For the embodiment of the present invention, in order to guarantee the accuracy of document code compiling, can select to add according to file type Carry device compiling file code, the collector 322, specifically for according to the file type of first document code from described Loader corresponding with first document code is searched in loader built in browser, different loaders is for compiling not With the document code of file type;It is corresponding to first document code and first document code using the loader of lookup Dependent file be compiled, obtain the corresponding compiled code of first document code.
For the embodiment of the present invention, source code corresponding compiled code in front end is directly run in browser in order to realize, Described device further include: generation unit 33 and running unit 34.
The generation unit 33 can be used for according to the document code dependence and the corresponding volume of the front end source code Post code is translated, compiled code dependence graph is generated.The generation unit 33 be in the present apparatus according to the document code according to The relationship of relying and the corresponding compiled code of the front end source code generate the functional module of compiled code dependence graph.
The running unit 34 can be used for relying on using the code loading environment and the compiled code simulated in advance Relational graph loads the corresponding compiled code of the front end source code and runs.The running unit 34 is in the present apparatus using pre- The code loading environment first simulated and the compiled code dependence graph load the corresponding compiling offspring of the front end source code Code and the functional module run.
In concrete application scene, the running unit 34 specifically can be used for utilizing the code loaded ring simulated in advance Border loads the first compiled code in the corresponding compiled code of the front end source code;If the compiled code dependence There are the second compiled codes that first compiled code is relied in figure, then load second compiled code;If There is no the second compiled code that first compiled code is relied in the compiled code dependence graph, then transport Row first compiled code.
Institute is obtained in order to realize dependence packet corresponding in the locally-installed front end source code of browser for the embodiment of the present invention The function of the corresponding dependent file of front end source code is stated, the installation unit 31 specifically can be used for obtaining reliance server transmission Dependence package informatin;The corresponding download address for relying on packet of the front end source code is searched in package informatin from described rely on, and according to The download address downloads the corresponding dependence packet of the front end source code;The front end source code corresponding dependence packet is carried out at decompression Reason, and the dependent file persistent storage after decompression is local in the browser.
The installation unit 31 specifically can be also used for sending dependent file acquisition request to proxy server, described to obtain It takes in request and carries the corresponding dependence packet identification information of the front end source code;The proxy server is used for according to the dependence Packet identification information downloads the corresponding dependence of the front end source code and wraps and decompressed, and obtains the corresponding dependence text of the front end source code Part;It is local that the dependent file persistence that the reliance server is fed back is buffered in the browser.
For the embodiment of the present invention, in order to avoid there is the problem of front end source code is with packet version conflict is relied on, the installation Unit 31 specifically can be also used for obtaining the corresponding version information of the front end source code;According to the version information in browser The corresponding dependence packet of the locally-installed front end source code, obtains the corresponding dependent file of the front end source code.
It should be noted that each functional module involved by a kind of front end source code compilation device provided in an embodiment of the present invention Other are accordingly described, can be with reference to the corresponding description of method shown in Fig. 1, and details are not described herein.
Based on above-mentioned method as shown in Figure 1, correspondingly, the embodiment of the invention also provides one kind to provide a kind of storage Jie Matter is stored with an at least executable instruction in the storage medium, and described execute instruction makes processor execute following steps: clear The corresponding dependence packet of the locally-installed front end source code of device of looking at, obtains the corresponding dependent file of the front end source code;Utilize the browsing Loader built in device analyzes the document code dependence of the front end source code, and according to the document code dependence and The dependent file is compiled the front end source code.
Based on the embodiment of above-mentioned method as shown in Figure 1 and device as shown in Figure 2, the embodiment of the invention also provides one kind Computer equipment, as shown in figure 4, processor (processor) 41, communication interface (Communications Interface) 42, memory (memory) 43 and communication bus 44.Wherein: processor 41, communication interface 42 and memory 43 pass through Communication bus 44 completes mutual communication.Communication interface 44, for other equipment such as client or other servers etc. Network element communication.Processor 41 can specifically execute the correlation in the conversion method embodiment of above-mentioned data for executing program Step.Specifically, program may include program code, which includes computer operation instruction.Processor 41 may be Central processor CPU or specific integrated circuit ASIC (Application Specific Integrated Circuit), or it is arranged to implement one or more integrated circuits of the embodiment of the present invention.
The one or more processors that terminal includes can be same type of processor, such as one or more CPU;? It can be different types of processor, such as one or more CPU and one or more ASIC.Memory 43, for storing journey Sequence.Memory 43 may include high speed RAM memory, it is also possible to further include nonvolatile memory (non-volatile Memory), a for example, at least magnetic disk storage.Program specifically can be used for so that processor 41 executes following operation: clear The corresponding dependence packet of the locally-installed front end source code of device of looking at, obtains the corresponding dependent file of the front end source code;Utilize the browsing Loader built in device analyzes the document code dependence of the front end source code, and according to the document code dependence and The dependent file is compiled the front end source code.
According to the technical solution of the present invention, institute can be obtained in the corresponding dependence packet of the locally-installed front end source code of browser State the corresponding dependent file of front end source code;The document code of the front end source code is analyzed using the loader built in the browser Dependence, and the front end source code is compiled according to the document code dependence and the dependent file, thus It can be realized and directly locally the front end source code is compiled in browser, without additional compiling constructing environment, energy Enough simplify front end development process, and then is able to ascend front end development efficiency.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, there is no the portion being described in detail in some embodiment Point, reference can be made to the related descriptions of other embodiments.
It is understood that the correlated characteristic in the above method and device can be referred to mutually.In addition, in above-described embodiment " first ", " second " etc. be and not represent the superiority and inferiority of each embodiment for distinguishing each embodiment.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description, The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
Algorithm and display are not inherently related to any particular computer, virtual system, or other device provided herein. Various general-purpose systems can also be used together with teachings based herein.As described above, it constructs required by this kind of system Structure be obvious.In addition, the present invention is also not directed to any particular programming language.It should be understood that can use various Programming language realizes summary of the invention described herein, and the description done above to language-specific is to disclose this hair Bright preferred forms.
In the instructions provided here, numerous specific details are set forth.It is to be appreciated, however, that implementation of the invention Example can be practiced without these specific details.In some instances, well known method, structure is not been shown in detail And technology, so as not to obscure the understanding of this specification.
Similarly, it should be understood that in order to simplify the disclosure and help to understand one or more of the various inventive aspects, Above in the description of exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimes In example, figure or descriptions thereof.However, the disclosed method should not be interpreted as reflecting the following intention: i.e. required to protect Shield the present invention claims features more more than feature expressly recited in each claim.More precisely, as following Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore, Thus the claims for following specific embodiment are expressly incorporated in the specific embodiment, wherein each claim itself All as a separate embodiment of the present invention.
Those skilled in the art will understand that can be carried out adaptively to the module in the equipment in embodiment Change and they are arranged in one or more devices different from this embodiment.It can be the module or list in embodiment Member or component are combined into a module or unit or component, and furthermore they can be divided into multiple submodule or subelement or Sub-component.Other than such feature and/or at least some of process or unit exclude each other, it can use any Combination is to all features disclosed in this specification (including adjoint claim, abstract and attached drawing) and so disclosed All process or units of what method or apparatus are combined.Unless expressly stated otherwise, this specification is (including adjoint power Benefit require, abstract and attached drawing) disclosed in each feature can carry out generation with an alternative feature that provides the same, equivalent, or similar purpose It replaces.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodiments In included certain features rather than other feature, but the combination of the feature of different embodiments mean it is of the invention Within the scope of and form different embodiments.For example, in the following claims, embodiment claimed is appointed Meaning one of can in any combination mode come using.
Various component embodiments of the invention can be implemented in hardware, or to run on one or more processors Software module realize, or be implemented in a combination thereof.It will be understood by those of skill in the art that can be used in practice Microprocessor or digital signal processor (DSP) realize one in source code compilation device in front end according to an embodiment of the present invention The some or all functions of a little or whole components.The present invention is also implemented as executing method as described herein Some or all device or device programs (for example, computer program and computer program product).Such realization Program of the invention can store on a computer-readable medium, or may be in the form of one or more signals.This The signal of sample can be downloaded from an internet website to obtain, and is perhaps provided on the carrier signal or mentions in any other forms For.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and ability Field technique personnel can be designed alternative embodiment without departing from the scope of the appended claims.In the claims, Any reference symbol between parentheses should not be configured to limitations on claims.Word "comprising" does not exclude the presence of not Element or step listed in the claims.Word "a" or "an" located in front of the element does not exclude the presence of multiple such Element.The present invention can be by means of including the hardware of several different elements and being come by means of properly programmed computer real It is existing.In the unit claims listing several devices, several in these devices can be through the same hardware branch To embody.The use of word first, second, and third does not indicate any sequence.These words can be explained and be run after fame Claim.

Claims (10)

1. a kind of front end source code Compilation Method characterized by comprising
In the corresponding dependence packet of the locally-installed front end source code of browser, the corresponding dependent file of the front end source code is obtained;
The document code dependence of the front end source code is analyzed using the loader built in the browser, and according to the text Part code dependence and the dependent file are compiled the front end source code.
2. the method according to claim 1, wherein the loader using built in the browser analyzes institute State the document code dependence of front end source code, and according to the document code dependence and the dependent file to before described End source code is compiled, comprising:
The first document code in the front end source code is obtained, and obtains first document code pair from the dependent file The dependent file answered;
Using the loader built in the browser to first document code and the corresponding dependence of first document code File is compiled, and obtains the corresponding compiled code of first document code;
According to the code module specification of the corresponding compiled code of first document code, the first document code institute is inquired The second document code relied on, the code module specification preserve first document code and second document code it Between dependence;
Compiling is executed to second document code and inquires the operation of relied on document code, until having compiled the front end Document code in source code.
3. according to the method described in claim 2, it is characterized in that, the loader using built in the browser is to described First document code and the corresponding dependent file of first document code are compiled, and it is corresponding to obtain first document code Compiled code, comprising:
It is searched from the loader built in the browser according to the file type of first document code and first text The corresponding loader of part code, different loaders are used to compile the document code of different file types;
First document code and the corresponding dependent file of first document code are compiled using the loader of lookup It translates, obtains the corresponding compiled code of first document code.
4. the method according to claim 1, wherein it is described according to the document code dependence and it is described according to After relying file to be compiled the front end source code, the method also includes:
According to the document code dependence and the corresponding compiled code of the front end source code, generates compiled code and rely on Relational graph;
Using the code loading environment and the compiled code dependence graph simulated in advance, it is corresponding to load the front end source code Compiled code and operation.
5. according to the method described in claim 4, it is characterized in that, described using the code loading environment simulated in advance and described Compiled code dependence graph loads the corresponding compiled code of the front end source code and runs, comprising:
After loading the first compiling in the corresponding compiled code of the front end source code using the code loading environment simulated in advance Code;
If there are the second compiled code that first compiled code is relied in the compiled code dependence graph, Then load second compiled code;
If there is no the second compiling offsprings that first compiled code is relied in the compiled code dependence graph Code, then run first compiled code.
6. the method according to claim 1, wherein it is described the locally-installed front end source code of browser it is corresponding according to Rely packet, obtain the corresponding dependent file of the front end source code, comprising:
Obtain the dependence package informatin that reliance server is sent;
The corresponding download address for relying on packet of the front end source code is searched from the dependence package informatin, and according to the downloading ground Download the corresponding dependence packet of the front end source code in location;
The corresponding dependence of the front end source code is wrapped and carries out decompression processing, and by the dependent file persistent storage after decompression in institute State browser local.
7. the method according to claim 1, wherein described corresponding in the locally-installed front end source code of browser Dependence packet, obtain the corresponding dependent file of the front end source code, comprising:
Send dependent file acquisition request to proxy server, carry in the acquisition request front end source code it is corresponding according to Rely packet identification information;The proxy server be used for according to the dependences packet identification information downloading front end source code it is corresponding according to Rely and wrap and decompressed, obtains the corresponding dependent file of the front end source code;
It is local that the dependent file persistence that the reliance server is fed back is buffered in the browser.
8. a kind of front end source code compilation device characterized by comprising
Installation unit, for it is corresponding to obtain the front end source code in the corresponding dependence packet of the locally-installed front end source code of browser Dependent file;
Compilation unit, the document code for being analyzed the front end source code using the loader built in the browser, which is relied on, to close System, and the front end source code is compiled according to the document code dependence and the dependent file.
9. a kind of storage medium is stored thereon with computer program, an at least executable instruction is stored in the storage medium, Described execute instruction makes processor execute such as the corresponding behaviour of source code Compilation Method in front end of any of claims 1-7 Make.
10. a kind of computer equipment, including processor described in processor, memory, communication interface and communication bus, the storage Device and the communication interface complete mutual communication by the communication bus, and the memory can be held for storing at least one Row instruction, the executable instruction execute the processor such as front end source code of any of claims 1-7 compiling Corresponding operation.
CN201811511759.0A 2018-12-11 2018-12-11 Front-end source code compiling method and device, storage medium and computer equipment Active CN109766099B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811511759.0A CN109766099B (en) 2018-12-11 2018-12-11 Front-end source code compiling method and device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811511759.0A CN109766099B (en) 2018-12-11 2018-12-11 Front-end source code compiling method and device, storage medium and computer equipment

Publications (2)

Publication Number Publication Date
CN109766099A true CN109766099A (en) 2019-05-17
CN109766099B CN109766099B (en) 2020-07-31

Family

ID=66451765

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811511759.0A Active CN109766099B (en) 2018-12-11 2018-12-11 Front-end source code compiling method and device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN109766099B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111176625A (en) * 2019-12-31 2020-05-19 杭州趣链科技有限公司 Method for efficiently compiling identity intelligent contract at browser end
CN112068842A (en) * 2020-09-15 2020-12-11 贝壳技术有限公司 Dependency relationship establishing method, linkage compiling method and system
CN112363699A (en) * 2020-11-16 2021-02-12 佳都新太科技股份有限公司 Interaction method and device applied to multi-language development platform
CN113721916A (en) * 2021-07-29 2021-11-30 苏州浪潮智能科技有限公司 Compiling method, device and equipment of operating system and readable storage medium
CN113805874A (en) * 2021-09-10 2021-12-17 上海得帆信息技术有限公司 Front-end code fragment dynamic rendering method and system suitable for multi-frame language
CN114760355A (en) * 2022-03-18 2022-07-15 麒麟软件有限公司 Js-dependent offline management method
CN117251165A (en) * 2023-08-24 2023-12-19 上海合芯数字科技有限公司 Method, device, terminal and medium for compiling building
CN117785213A (en) * 2023-12-27 2024-03-29 长扬科技(北京)股份有限公司 Front-end construction tool and construction method based on Rust development

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833449A (en) * 2010-04-16 2010-09-15 中山大学 Compile processing method and system based on cloud computing
US20170329767A1 (en) * 2016-05-10 2017-11-16 International Business Machines Corporation Localization of application user interface
CN107547944A (en) * 2016-06-27 2018-01-05 中兴通讯股份有限公司 Interface realizing method and device, set top box
US20180210715A1 (en) * 2017-01-25 2018-07-26 Wal-Mart Stores, Inc. Systems, method, and non-transitory computer-readable storage media for generating code for displaying a webpage
US20180260301A1 (en) * 2017-03-03 2018-09-13 Snyk Limited Identifying flawed dependencies in deployed applications
CN108804159A (en) * 2018-06-14 2018-11-13 腾讯科技(深圳)有限公司 Javascript module loadings method and its preprocess method, device and computer equipment
CN108874399A (en) * 2017-05-11 2018-11-23 龙芯中科技术有限公司 The method, apparatus and terminal of plug-in unit are installed

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833449A (en) * 2010-04-16 2010-09-15 中山大学 Compile processing method and system based on cloud computing
US20170329767A1 (en) * 2016-05-10 2017-11-16 International Business Machines Corporation Localization of application user interface
CN107547944A (en) * 2016-06-27 2018-01-05 中兴通讯股份有限公司 Interface realizing method and device, set top box
US20180210715A1 (en) * 2017-01-25 2018-07-26 Wal-Mart Stores, Inc. Systems, method, and non-transitory computer-readable storage media for generating code for displaying a webpage
US20180260301A1 (en) * 2017-03-03 2018-09-13 Snyk Limited Identifying flawed dependencies in deployed applications
CN108874399A (en) * 2017-05-11 2018-11-23 龙芯中科技术有限公司 The method, apparatus and terminal of plug-in unit are installed
CN108804159A (en) * 2018-06-14 2018-11-13 腾讯科技(深圳)有限公司 Javascript module loadings method and its preprocess method, device and computer equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王 然: "Java web 开发的设计与实现", 《民营科技》 *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111176625A (en) * 2019-12-31 2020-05-19 杭州趣链科技有限公司 Method for efficiently compiling identity intelligent contract at browser end
CN111176625B (en) * 2019-12-31 2023-07-28 杭州趣链科技有限公司 Method for efficiently compiling intelligent contract of solubility at browser end
CN112068842A (en) * 2020-09-15 2020-12-11 贝壳技术有限公司 Dependency relationship establishing method, linkage compiling method and system
CN112363699A (en) * 2020-11-16 2021-02-12 佳都新太科技股份有限公司 Interaction method and device applied to multi-language development platform
CN113721916A (en) * 2021-07-29 2021-11-30 苏州浪潮智能科技有限公司 Compiling method, device and equipment of operating system and readable storage medium
CN113721916B (en) * 2021-07-29 2023-07-14 苏州浪潮智能科技有限公司 Compiling method, device and equipment of operating system and readable storage medium
CN113805874A (en) * 2021-09-10 2021-12-17 上海得帆信息技术有限公司 Front-end code fragment dynamic rendering method and system suitable for multi-frame language
CN114760355A (en) * 2022-03-18 2022-07-15 麒麟软件有限公司 Js-dependent offline management method
CN114760355B (en) * 2022-03-18 2023-09-26 麒麟软件有限公司 Node. Js dependent offline management method
CN117251165A (en) * 2023-08-24 2023-12-19 上海合芯数字科技有限公司 Method, device, terminal and medium for compiling building
CN117785213A (en) * 2023-12-27 2024-03-29 长扬科技(北京)股份有限公司 Front-end construction tool and construction method based on Rust development

Also Published As

Publication number Publication date
CN109766099B (en) 2020-07-31

Similar Documents

Publication Publication Date Title
CN109766099A (en) Front end source code Compilation Method, device, storage medium and computer equipment
CN105760201B (en) A kind of starting method and apparatus of embedded equipment
US11667033B2 (en) Systems and methods for robotic process automation
CN110554876A (en) Method and device for compiling android project
US8843904B2 (en) Automated building and retargeting of architecture-dependent assets
US11068243B2 (en) Application stack builder based on node features
CN105204917B (en) The method and device of loading configuration file in application program launching
CN113934426A (en) Software package processing method, device, system, equipment and medium
CN110069259A (en) Analytic method, device, electronic equipment and storage medium based on idl file
CN114116134A (en) Intelligent contract deployment and execution method, equipment and storage medium
CN113268245A (en) Code analysis method, device and storage medium
US9886251B2 (en) Optimized compiling of a template function
CN110851211A (en) Method, apparatus, electronic device, and medium for displaying application information
CN107608672B (en) UI module manager, UI module management method and system
CN105094857A (en) Method and system used for loading applications
CN116166907B (en) Method and device for developing Web application by using WebAsssembly and service page compiling technology
US10120661B2 (en) Multi-flavored software execution from a singular code base
CN110362317B (en) Code conversion method, device and storage medium
US20170083306A1 (en) Download of a package of code
CN114238831A (en) HTML code fragment processing method, system, electronic equipment and storage medium
CN115952089A (en) Software automation unit testing method and device, server and storage medium
CN112379885B (en) Applet compiling method, device, equipment and readable storage medium
CN115291928A (en) Task automatic integration method and device of multiple technology stacks and electronic equipment
CN113220337A (en) Version construction method and device, computer equipment and storage medium
CN110489124A (en) Source code executes method, apparatus, storage medium and computer equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant