CN107665124A - Modularization JavaScript file processing method, equipment and server - Google Patents

Modularization JavaScript file processing method, equipment and server Download PDF

Info

Publication number
CN107665124A
CN107665124A CN201710829299.5A CN201710829299A CN107665124A CN 107665124 A CN107665124 A CN 107665124A CN 201710829299 A CN201710829299 A CN 201710829299A CN 107665124 A CN107665124 A CN 107665124A
Authority
CN
China
Prior art keywords
javascript file
syntax tree
abstract syntax
node
file
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
CN201710829299.5A
Other languages
Chinese (zh)
Other versions
CN107665124B (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.)
Alibaba China Co Ltd
Original Assignee
Guangdong Shenma Search 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 Guangdong Shenma Search Technology Co Ltd filed Critical Guangdong Shenma Search Technology Co Ltd
Priority to CN201710829299.5A priority Critical patent/CN107665124B/en
Publication of CN107665124A publication Critical patent/CN107665124A/en
Application granted granted Critical
Publication of CN107665124B publication Critical patent/CN107665124B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

Disclose a kind of modularization JavaScript file processing method, equipment and server.Methods described includes:Obtain the original JavaScript file formed by modular mode;The JavaScript file is converted into the form of the first abstract syntax tree;For at least one at least one node execution processing in the first abstract syntax tree, to obtain the second abstract syntax tree;And the JavaScript file using the generation conversion of the second abstract syntax tree, for being sent to the terminal device of user.According to one embodiment of the disclosure, it is possible to reduce terminal device is to the processing cost of JavaScript file, so as to lift user experience.

Description

Modularization JavaScript file processing method, equipment and server
Technical field
The present invention relates to JavaScript technical fields, are used for processing module more particularly, to one kind The method of JavaScript file, the equipment for processing module JavaScript file, processing server and Web service Device.
Background technology
With the rapid development of Internet, front end exploitation becomes increasingly complex.Development of Modular can solve cumbersome file Dependence Problem, while also improve the maintainability of code.
Generally, caused JavaScript code is sent to processing server by designer.Processing server will JavaScript file is bundled to together and sends it to Web server.Designer can also directly use the meter of oneself JavaScript file is bundled to together and sends it to Web server by calculation machine, in this case, the meter of designer Calculation machine can also be considered as processing server.When a user visits a web site, Web server can be by the JavaScript texts of packing Part and Html files send jointly to the terminal device of user.Terminal device passes through Network Capture JavaScript file and Html File.Terminal device runs JavaScript file, to realize corresponding function.
Conventionally, as a JavaScript module may quote other JavaScript modules, therefore, In order to run desired JavaScript file in terminal device, without producing mistake, generally, server will be all JavaScript modules are packaged into a JavaScript file and are sent to terminal device, wherein, some JavaScript modules It is probably that present terminal equipment institute is unwanted.
When part, JavaScript modules are updated, server needs again to beat all JavaScript modules Bag, and the file after whole packing is sent to terminal device.In the case of mobile Internet, this may expend user's Flow, and take more download time.
Terminal device is when running JavaScript file, it is necessary to be parsed and obtained to JavaScript file first The dependence table of JavaScript file.This can increase the load time and/or white screen time of page loading.In addition, existing Have in technology, generally produce dependence table in a manual manner.This mode it is less efficient.
Accordingly, it is desirable to provide a kind of new technical scheme, enters for above-mentioned at least one technical problem of the prior art Row improves.
The content of the invention
It is an object of the present invention to provide a kind of new solution for modularization JavaScript exploitations.
According to the first aspect of the invention, there is provided a kind of method for processing module JavaScript file, bag Include:Obtain the original JavaScript file formed by modular mode;The JavaScript file is converted into first to take out As the form of syntax tree;For at least one in the following processing of at least one node execution in the first abstract syntax tree, with Obtain the second abstract syntax tree:If node includes LeadingComments and TrailingComments, obtain corresponding Require parameter, if the type of node is ExpressionStatement and identified comprising require, obtain phase The require answered parameter and by the node from the first abstract syntax tree deletion, if the type of node is not ExpressionStatement and identified comprising require, then corresponding require parameter is obtained, according to the parameter Generate new node and replace current node with the new node, and if node identifies comprising exports, then according to original The new node of the current file coordinates measurement of JavaScript file;And utilize the generation conversion of the second abstract syntax tree JavaScript file, for being sent to the terminal device of user.
Preferably, the JavaScript file of conversion is generated using the second abstract syntax tree also to be included:For the second abstract language Method tree adds closure.
Preferably, adding closure for the second abstract syntax tree also includes:The abstract syntax tree of closure is generated, as the 3rd language Method tree;It will be added in second abstract syntax tree in the 3rd abstract syntax tree, to generate the 4th abstract syntax tree;And will 4th abstract syntax tree is converted into JavaScript file, the JavaScript file as the conversion.
Preferably at least one node in the first abstract syntax tree perform in following processing it is at least one with Include to the second abstract syntax tree:Whole nodes in ergodic abstract syntax tree are to obtain the second abstract syntax tree.
Preferably at least one node in the first abstract syntax tree perform in following processing it is at least one with Also include to the second abstract syntax tree:The dependence of JavaScript file is generated by obtaining corresponding require parameter Relation table.
Preferably, multiple original JavaScript files to be formed by modular mode generate multiple conversions respectively JavaScript file.
The dependence table is preferably based on, in the JavaScript file needed for web page files embedded web page file Dependency information;Or based on the dependence table, generate the dependence of the JavaScript file needed for web page files Relation sublist simultaneously associates the dependence sublist with the web page files.
Preferably, the JavaScript file of the conversion is generated by servers off-line.
The dependence table is preferably based on, in the JavaScript file for individually updating the multiple conversion It is at least one.
According to the second aspect of the invention, a kind of equipment for processing module JavaScript file, including:For Obtain the device of the original JavaScript file formed by modular mode;For the JavaScript file to be converted into The device of the form of first abstract syntax tree;For performing following processing at least one node in the first abstract syntax tree In it is at least one, to obtain the device of the second abstract syntax tree:If node include LeadingComments and TrailingComments, then obtain corresponding require parameter;If the type of node is ExpressionStatement and comprising require identify, then obtain corresponding require parameter and by the node from First abstract syntax tree deletion;If the type of node is not ExpressionStatement and identified comprising require, Corresponding require parameter is then obtained, new node is generated according to the parameter and replaces current section with the new node Point;If identified with node comprising exports, according to the new section of the current file coordinates measurement of original JavaScript file Point;And the JavaScript file for being generated conversion using the second abstract syntax tree is set for being sent to the terminal of user Standby device.
According to the third aspect of the invention we, a kind of processing server, including embodiment in the disclosure are used to locating The equipment for managing modularization JavaScript file, or including memory and processor, wherein, the memory storage can perform Instruction, the executable instruction control embodiment of the computing device in the disclosure when the server is run For the operation in the method for processing module JavaScript file.
According to the fourth aspect of the invention, a kind of Web server, it is used for processing module based on described for obtaining The JavaScript file for the conversion that the method for JavaScript file is generated, wherein, the Web server is based on relying on and closed It is table, is independently updated to terminal device at least one in the JavaScript file of the multiple conversion.
According to one embodiment of the disclosure, it is possible to reduce terminal device to the processing cost of JavaScript file, from And lift user experience.
By referring to the drawings to the present invention exemplary embodiment detailed description, further feature of the invention and its Advantage will be made apparent from.
Brief description of the drawings
It is combined in the description and the accompanying drawing of a part for constitution instruction shows embodiments of the invention, and even It is used for the principle for explaining the present invention together with its explanation.
Fig. 1 shows the indicative flowchart of the method for one embodiment according to the disclosure.
Fig. 2 shows the schematic block diagram of the server according to another embodiment of the disclosure.
Fig. 3 shows the schematic block diagram of the server according to another embodiment of the disclosure.
Fig. 4 shows the schematic diagram according to one example of the present disclosure.
Embodiment
The various exemplary embodiments of the present invention are described in detail now with reference to accompanying drawing.It should be noted that:Unless have in addition Body illustrates that the unlimited system of part and the positioned opposite of step, numerical expression and the numerical value otherwise illustrated in these embodiments is originally The scope of invention.
The description only actually at least one exemplary embodiment is illustrative to be never used as to the present invention below And its application or any restrictions that use.
It may be not discussed in detail for technology, method and apparatus known to person of ordinary skill in the relevant, but suitable In the case of, the technology, method and apparatus should be considered as part for specification.
In shown here and discussion all examples, any occurrence should be construed as merely exemplary, without It is as limitation.Therefore, other examples of exemplary embodiment can have different values.
It should be noted that:Similar label and letter represents similar terms in following accompanying drawing, therefore, once a certain Xiang Yi It is defined, then it need not be further discussed in subsequent accompanying drawing in individual accompanying drawing.
Below, each embodiment and example according to the present invention are described with reference to the accompanying drawings.
<Method>
Fig. 1 shows the method for processing module JavaScript file of one embodiment according to the disclosure Indicative flowchart.
As shown in figure 1, in step S1100, the original JavaScript file formed by modular mode is obtained.
Here, technical staff still can write JavaScript code using modular mode, so as to utilize module Melt benefit caused by hair.The technical scheme of the present embodiment will not impact to the written in code work of technical staff.When After code is supplied to server by technical staff, code can be handled automatically, to realize the skill in this embodiment Art scheme.
Generally, technical staff can produce multiple original JavaScript files in exploitation.Can be respectively to each JavaScript file performs the processing in the present embodiment.
In step S1200, the JavaScript file is converted into the form of the first abstract syntax tree.
It is known in the art and not the present embodiment institute how JavaScript file to be converted into abstract syntax tree Concern.Therefore, the detailed description to it is omitted herein.
In step S1300, at least one in following processing is performed at least one node in the first abstract syntax tree It is individual, to obtain the second abstract syntax tree:
If node includes LeadingComments and TrailingComments, corresponding require ginseng is obtained Number;
If the type of node is ExpressionStatement and identified comprising require, obtain corresponding Require parameter and by the node from the first abstract syntax tree deletion;
If the type of node is not ExpressionStatement and identified comprising require, obtain corresponding Require parameter, new node is generated according to the parameter and replaces current node with the new node;With
If node identifies comprising exports, new according to the current file coordinates measurement of original JavaScript file Node.
In one example, can be with whole nodes in ergodic abstract syntax tree to obtain the second abstract syntax tree.Change sentence Talk about, original JavaScript file can integrally be handled, to generate new converted JavaScript file, supplied User uses.
In superincumbent processing, due to require parameter is identified and handled, thus, it is possible to obtain accordingly Dependence.Therefore, the dependence of JavaScript file can be generated by obtaining corresponding require parameter Table.
In step S1400, the JavaScript file changed is generated using the second abstract syntax tree, for being sent to user Terminal device.
Such as, it is generally the case that technical staff can be the multiple original JavaScript files of a Website development or one Individual website needs to use multiple original JavaScript files.In such a case, it is possible to formed by modular mode Multiple original JavaScript files generate the JavaScript file of multiple conversions respectively.
The second abstract syntax tree can be utilized to directly generate the JavaScript file of conversion, can also be to the second abstract language Method tree is further processed and generates the JavaScript file of conversion.
For example, can be that the second abstract syntax tree adds closure.In one example, the abstract of closure can be firstly generated Syntax tree, as the 3rd syntax tree.Then, will be added in the second abstract syntax tree in the 3rd abstract syntax tree, with life Into the 4th abstract syntax tree.Finally, the 4th abstract syntax tree is converted into JavaScript file, as the conversion JavaScript file.
By this embodiment, JavaScript file can be obtained automatically while JavaScript file is changed Dependence table.Based on the dependence table, in the JavaScript file needed for web page files embedded web page file Dependency information.So, when the user accesses a web page, Web server can be by web page files (such as Html files) and phase The JavaScript file answered is sent to the terminal device of user.Alternatively, based on the dependence table, web page files are generated The dependence sublist of required JavaScript file simultaneously associates the dependence sublist with the web page files.In this feelings Under condition, Web server can be sent to the terminal device of user using the dependence sublist as a single file.
The JavaScript file of the conversion can be generated by servers off-line.So, terminal device can be obtained directly The JavaScript file of the conversion so handled is taken, so as to reduce the processing needed for terminal device, and user is lifted and uses body Test.
Herein, each JavaScript file is individually changed, and can independently be sent to terminal device. Therefore, the dependence table can be based on, individually updates at least one in the JavaScript file of the multiple conversion It is individual.
Due in the terminal device that JavaScript file is sent to user with before for users to use, it is right JavaScript file is handled, therefore, it is possible to reduce is handled in terminal device generation dependence table, so as to save Save the time and/or white screen time of terminal device loading webpage.
Herein, due to dependence table can be automatically generated in server, and dependence is sent to user, because This, can individually update the one or more of multiple JavaScript files, without all JavaScript files are packed Terminal device is sent to together.Therefore, this can save the flow of user.
In addition, terminal device can directly utilize received dependence.This is advantageous to terminal device loading webpage.
<Equipment>
, can be by software, hardware and software and hard it will be appreciated by those skilled in the art that in electronic technology field The mode that part combines, the above method is embodied into those skilled in the art in the product and is easy to be based on method as disclosed above, is produced A kind of raw equipment for processing module JavaScript file.The equipment can include being used to perform foregoing reality Apply the device of each step in the method for processing module JavaScript file in example.For example, the equipment bag Include:For obtaining the device of the original JavaScript file formed by modular mode;For the JavaScript is literary Part is converted into the device of the form of the first abstract syntax tree;For being performed at least one node in the first abstract syntax tree It is at least one in following processing, to obtain the device of the second abstract syntax tree:If node include LeadingComments and TrailingComments, then corresponding require parameter is obtained, if the type of node is ExpressionStatement and comprising require identify, then obtain corresponding require parameter and by the node from First abstract syntax tree deletion, if the type of node is not ExpressionStatement and identified comprising require, Corresponding require parameter is then obtained, new node is generated according to the parameter and replaces current section with the new node Point, and if node identifies comprising exports, then according to the new section of the current file coordinates measurement of original JavaScript file Point;And the device for the JavaScript file using the generation conversion of the second abstract syntax tree.
It is well known by those skilled in the art that the development of the electronic information technology with such as large scale integrated circuit technology With the trend of hardware and software, clearly to divide computer system soft and hardware boundary and seem relatively difficult.Because appoint What operation can be realized with software, can also be realized by hardware.The execution of any instruction can be completed by hardware, equally also may be used To be completed by software.Hardware implementations or software implement scheme are used for a certain machine function, depending on price, speed The Non-technical factors such as degree, reliability, memory capacity, change cycle.For the technician, software realization mode and hardware It is achieved in that equivalent.Technical staff can select software or hardware to realize such scheme as needed.Therefore, here not Specific software or hardware are limited.
<Server>
Fig. 2 shows the schematic block diagram of the server according to another embodiment of the disclosure.As shown in Fig. 2 service Device 2000 includes modularization JS document handling apparatus 2010.Modularization JS document handling apparatus 2010 for example can be noted earlier The equipment for processing module JavaScript file.
Fig. 3 also show the schematic block diagram of the server according to another embodiment of the disclosure.As shown in figure 3, clothes Be engaged in device 3000 can include processor 3010, memory 3020, interface arrangement 3030, communicator 3040, display device 3050, Input unit 3060, loudspeaker 3070, microphone 3080, etc..
Processor 3010 is such as can be central processor CPU, Micro-processor MCV.Memory 3020 is for example including ROM (read-only storage), RAM (random access memory), hard disk nonvolatile memory etc..Interface arrangement 3030 is for example Including USB interface, earphone interface etc..
Communicator 3040 can for example carry out wired or wireless communication.
Display device 3050 is, for example, LCDs, touch display screen etc..Input unit 3060 can for example include touching Touch screen, keyboard etc..User can pass through loudspeaker 3070 and the inputting/outputting voice information of microphone 3080.
Server shown in Fig. 3 is only explanatory, and is never intended to limit invention, its application, or uses.
In this embodiment, the memory 3020 is used for store instruction, and the executable instruction is in the server The computing device is controlled to be used for processing module JavaScript file according to any one embodiment during operation Method in operation.It will be appreciated by those skilled in the art that although figure 3 illustrates multiple devices, still, the present invention can To only relate to partial devices therein, for example, processor 3010 and storage device 3020 etc..Technical staff can be according to the present invention Disclosed conceptual design instruction.How control processor is operated for instruction, and this is it is known in the art that therefore no longer retouching in detail herein State.
The configuration of electronic equipment is more and more flexible at present.Here server can be special or designer The programmed computer of member.In addition, as stated in the Background Art, it is commonly designed personnel and program code is sent to processing server, connect Processing server and the code after processing is sent to Web server.User can access webpage by Web server.Here Server 2000,3000 can be the processing server, and the JavaScript file of the conversion generated is sent to Other Web server.Alternatively, processing server and Web server can be bound together.In this case, The server 2000,3000 is both processing server and Web server.
It is based on being described previously for processing module in addition, Web server can be obtained directly or indirectly The JavaScript file for the conversion that the method for JavaScript file is generated, and dependence table is based on, independently to end End equipment updates at least one in the JavaScript file of the multiple conversion.
<Example>
Fig. 4 shows the schematic diagram according to one example of the present disclosure.
As shown in figure 4, the programmed computer 4020 of designer, processing server 4030, Web server 4040 and user Terminal device 4050 connected by network 4010.
Network 4010 can be cable network, wireless network or the mixing of the two.
The programmed computer 4020 of designer can be combined together with processing server 4030.Alternatively, processing clothes Business device 4030 and Web server 4040 can be combined together.
As a rule, designer writes program code using programmed computer 4020.Then, designer is by program generation Code is sent to processing server 4030.File after processing is sent to Web server 4040 by processing server 4030.User can To access the webpage in Web server 4040 using terminal device 4050.
Typically, can be in the embodiment during processing server 4030 realizes the disclosure.But as previously described, can also The embodiment is realized in programmed computer 4020 or Web server 4040.
By the technical scheme of the disclosure, the Javascript file translations formed by modular mode can be closed The modular arrangement of bag and NameSpace carry.Fine-grained modular arrangement can be realized in this way.
Specifically, can by processing server 4030 offline to will for user access webpage in JavaScript File is handled.Here, for the processing of server, the JavaScript file is original JavaScript texts Part.The original JavaScript file is developed using modular mode.One website usually requires multiple JavaScript file.The processing that can be directed in each original JavaScript file execution embodiment of the disclosure.
First, original JavaScript file is obtained.Then, the first abstract syntax can be translated into by code Tree.
Then, the second abstract syntax tree is traveled through, following processing is performed to its each node:
If a, node includes LeadingComments and TrailingComments, obtain corresponding require's Parameter;
If b, the type of node is ExpressionStatement and identified comprising require, obtain corresponding Require parameter and by the node from the first abstract syntax tree deletion;
If c, the type of node is not ExpressionStatement and identified comprising require, obtain corresponding Require parameter, new node is generated according to the parameter and replaces current node with the new node;With
D, if node identifies comprising exports, according to the current file coordinates measurement of original JavaScript file New node.
While above-mentioned processing is carried out, JavaScript can be generated by obtaining corresponding require parameter The dependence table of file.
After traversing operation terminates, a new abstract syntax tree can be obtained, i.e. the second abstract syntax tree.In addition, The abstract syntax tree of a closure can be generated, as the 3rd syntax tree.The 3rd will be added in second abstract syntax tree In abstract syntax tree, to generate the 4th abstract syntax tree.Then, the 4th abstract syntax tree is converted into JavaScript file, JavaScript file as the conversion.
The JavaScript file of the conversion and dependence table can be sent to Web service by processing server 4030 Device 4040.Web server 4040 is injected into web page files according to the dependence table.When the user accesses a web page, Web takes Web page files and corresponding JavaScript file are sent to user by business device 4040.Web server 4040 can be based on described Dependence table determines the JavaScript file needed for each webpage.Web server 4040 can independently send described One or more of JavaScript file, without all of which is packaged with.
Terminal device 4050 receives web page files and corresponding JavaScript file, and they are handled with aobvious Show., therefore, can due to the time of the generation dependence of terminal device 405 can be reduced at least in part by scheme here To reduce the time and/or white screen time of loading webpage.In addition, when part JavaScript file needs renewal, can be only The file for needing to update is sent to terminal device 4050 by Web server 4040.This can reduce the traffic of network transmission. In the case where mobile Internet is applied, this is particularly advantageous.
The present invention can be equipment, method and/or computer program product.Computer program product can include computer Readable storage medium storing program for executing, containing for making processor realize the computer-readable program instructions of various aspects of the invention.
Computer-readable recording medium can keep and store to perform the tangible of the instruction that uses of equipment by instruction Equipment.Computer-readable recording medium for example can be-- but be not limited to-- storage device electric, magnetic storage apparatus, optical storage Equipment, electromagnetism storage device, semiconductor memory apparatus or above-mentioned any appropriate combination.Computer-readable recording medium More specifically example (non exhaustive list) includes:Portable computer diskette, hard disk, random access memory (RAM), read-only deposit It is reservoir (ROM), erasable programmable read only memory (EPROM or flash memory), static RAM (SRAM), portable Compact disk read-only storage (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanical coding equipment, for example thereon It is stored with punch card or groove internal projection structure and the above-mentioned any appropriate combination of instruction.Calculating used herein above Machine readable storage medium storing program for executing is not construed as instantaneous signal in itself, the electromagnetic wave of such as radio wave or other Free propagations, leads to Cross the electromagnetic wave (for example, the light pulse for passing through fiber optic cables) of waveguide or the propagation of other transmission mediums or transmitted by electric wire Electric signal.
Computer-readable program instructions as described herein can be downloaded to from computer-readable recording medium it is each calculate/ Processing equipment, or outer computer or outer is downloaded to by network, such as internet, LAN, wide area network and/or wireless network Portion's storage device.Network can include copper transmission cable, optical fiber is transmitted, is wirelessly transferred, router, fire wall, interchanger, gateway Computer and/or Edge Server.Adapter or network interface in each calculating/processing equipment receive from network to be counted Calculation machine readable program instructions, and the computer-readable program instructions are forwarded, for the meter being stored in each calculating/processing equipment In calculation machine readable storage medium storing program for executing.
For perform the computer program instructions that operate of the present invention can be assembly instruction, instruction set architecture (ISA) instruction, Machine instruction, machine-dependent instructions, microcode, firmware instructions, condition setup data or with one or more programming languages The source code or object code that any combination is write, programming language of the programming language including object-oriented-such as Smalltalk, C++ etc., and conventional procedural programming languages-such as " C " language or similar programming language.Computer Readable program instructions fully can on the user computer perform, partly perform on the user computer, be only as one Vertical software kit performs, part performs or completely in remote computer on the remote computer on the user computer for part Or performed on server.In the situation of remote computer is related to, remote computer can pass through network-bag of any kind LAN (LAN) or wide area network (WAN)-be connected to subscriber computer are included, or, it may be connected to outer computer (such as profit Pass through Internet connection with ISP).In certain embodiments, by using computer-readable program instructions Status information carry out personalized customization electronic circuit, such as PLD, field programmable gate array (FPGA) or can Programmed logic array (PLA) (PLA), the electronic circuit can perform computer-readable program instructions, so as to realize each side of the present invention Face.
Referring herein to method, apparatus (system) and computer program product according to embodiments of the present invention flow chart and/ Or block diagram describes various aspects of the invention.It should be appreciated that each square frame and flow chart of flow chart and/or block diagram and/ Or in block diagram each square frame combination, can be realized by computer-readable program instructions.
These computer-readable program instructions can be supplied to all-purpose computer, special-purpose computer or other programmable datas The processor of processing unit, so as to produce a kind of machine so that these instructions are passing through computer or other programmable datas During the computing device of processing unit, work(specified in one or more of implementation process figure and/or block diagram square frame is generated The device of energy/action.These computer-readable program instructions can also be stored in a computer-readable storage medium, these refer to Order causes computer, programmable data processing unit and/or other equipment to work in a specific way, so as to be stored with instruction Computer-readable medium then includes a manufacture, and it is included in one or more of implementation process figure and/or block diagram square frame The instruction of the various aspects of defined function/action.
Computer-readable program instructions can also be loaded into computer, other programmable data processing units or other In equipment so that series of operation steps is performed on computer, other programmable data processing units or miscellaneous equipment, with production Raw computer implemented process, so that performed on computer, other programmable data processing units or miscellaneous equipment Instruct function/action specified in one or more of implementation process figure and/or block diagram square frame.
Flow chart and block diagram in accompanying drawing show system, method and the computer journey of multiple embodiments according to the present invention Architectural framework in the cards, function and the operation of sequence product.At this point, each square frame in flow chart or block diagram can generation One module of table, program segment or a part for instruction, the module, program segment or a part for instruction include one or more use In the executable instruction of logic function as defined in realization.At some as the function of in the realization replaced, being marked in square frame Can be with different from the order marked in accompanying drawing generation.For example, two continuous square frames can essentially be held substantially in parallel OK, they can also be performed in the opposite order sometimes, and this is depending on involved function.It is also noted that block diagram and/or The combination of each square frame and block diagram in flow chart and/or the square frame in flow chart, function or dynamic as defined in performing can be used The special hardware based system made is realized, or can be realized with the combination of specialized hardware and computer instruction.It is right It is well known that, realized for those skilled in the art by hardware mode, realized by software mode and by software and It is all of equal value that the mode of combination of hardware, which is realized,.
It is described above various embodiments of the present invention, described above is exemplary, and non-exclusive, and It is not limited to disclosed each embodiment.In the case of without departing from the scope and spirit of illustrated each embodiment, for this skill Many modifications and changes will be apparent from for the those of ordinary skill in art field.The selection of term used herein, purport Best explaining the principle of each embodiment, practical application or to the technological improvement in market, or make the art its Its those of ordinary skill is understood that each embodiment disclosed herein.The scope of the present invention is defined by the appended claims.

Claims (12)

1. a kind of method for processing module JavaScript file, including:
Obtain the original JavaScript file formed by modular mode;
The JavaScript file is converted into the form of the first abstract syntax tree;
It is abstract to obtain second at least one in the following processing of at least one node execution in the first abstract syntax tree Syntax tree:
If node includes LeadingComments and TrailingComments, corresponding require parameter is obtained,
If the type of node is ExpressionStatement and identified comprising require, obtain corresponding Require parameter and by the node from the first abstract syntax tree deletion,
If the type of node is not ExpressionStatement and identified comprising require, obtain corresponding Require parameter, new node is generated according to the parameter and replaces current node with the new node, and
If node identifies comprising exports, according to the new section of the current file coordinates measurement of original JavaScript file Point;And
Using the JavaScript file of the second abstract syntax tree generation conversion, for being sent to the terminal device of user.
2. according to the method for claim 1, wherein, the JavaScript file changed is generated using the second abstract syntax tree Also include:Closure is added for the second abstract syntax tree.
3. according to the method for claim 2, wherein, adding closure for the second abstract syntax tree also includes:
The abstract syntax tree of closure is generated, as the 3rd syntax tree;
It will be added in second abstract syntax tree in the 3rd abstract syntax tree, to generate the 4th abstract syntax tree;And
4th abstract syntax tree is converted into JavaScript file, the JavaScript file as the conversion.
4. according to the method for claim 1, wherein, performed at least one node in the first abstract syntax tree as follows At least one in processing is included with obtaining the second abstract syntax tree:
Whole nodes in ergodic abstract syntax tree are to obtain the second abstract syntax tree.
5. according to the method any one of claim 1-4, wherein, at least one in the first abstract syntax tree What node performed in following processing at least one is also included with obtaining the second abstract syntax tree:
The dependence table of JavaScript file is generated by obtaining corresponding require parameter.
6. the method according to claim 11, wherein, for the multiple original JavaScript texts formed by modular mode Part generates the JavaScript file of multiple conversions respectively.
7. the method according to claim 11, wherein, based on the dependence table, in web page files embedded web page file The dependency information of required JavaScript file;Or based on the dependence table, generate needed for web page files The dependence sublist of JavaScript file simultaneously associates the dependence sublist with the web page files.
8. according to the method for claim 6, wherein, the JavaScript file of the conversion is generated by servers off-line.
9. according to the method for claim 6, wherein, based on the dependence table, individually update the multiple conversion JavaScript file in it is at least one.
10. a kind of equipment for processing module JavaScript file, including:
For obtaining the device of the original JavaScript file formed by modular mode;
For the device for the form that the JavaScript file is converted into the first abstract syntax tree;
It is at least one in following processing for being performed at least one node in the first abstract syntax tree, to obtain second The device of abstract syntax tree:
If node includes LeadingComments and TrailingComments, corresponding require parameter is obtained;
If the type of node is ExpressionStatement and identified comprising require, obtain corresponding Require parameter and by the node from the first abstract syntax tree deletion;
If the type of node is not ExpressionStatement and identified comprising require, obtain corresponding Require parameter, new node is generated according to the parameter and replaces current node with the new node;With
If node identifies comprising exports, according to the new section of the current file coordinates measurement of original JavaScript file Point;And
For generating the JavaScript file changed using the second abstract syntax tree for being sent to the terminal device of user Device.
11. a kind of processing server, including it is according to claim 10 for processing module JavaScript file Equipment, or including memory and processor, wherein, the memory storage executable instruction, the executable instruction is in institute Controlled when stating server operation and be used for processing module described in any one of the computing device in claim 1-9 Change the operation in the method for JavaScript file.
12. a kind of Web server, mould is handled based on being used for described in any one in claim 6-9 for obtaining The JavaScript file for the conversion that the method for block JavaScript file is generated, wherein, the Web server be based on according to Rely relation table, independently updated to terminal device at least one in the JavaScript file of the multiple conversion.
CN201710829299.5A 2017-09-14 2017-09-14 Modular JavaScript file processing method, device and server Active CN107665124B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710829299.5A CN107665124B (en) 2017-09-14 2017-09-14 Modular JavaScript file processing method, device and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710829299.5A CN107665124B (en) 2017-09-14 2017-09-14 Modular JavaScript file processing method, device and server

Publications (2)

Publication Number Publication Date
CN107665124A true CN107665124A (en) 2018-02-06
CN107665124B CN107665124B (en) 2021-04-20

Family

ID=61097023

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710829299.5A Active CN107665124B (en) 2017-09-14 2017-09-14 Modular JavaScript file processing method, device and server

Country Status (1)

Country Link
CN (1) CN107665124B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110347416A (en) * 2019-07-19 2019-10-18 网易(杭州)网络有限公司 The update method and device of script
CN110362792A (en) * 2019-07-05 2019-10-22 五八有限公司 RN file is converted to the method, apparatus and conversion equipment of small routine file

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103645986A (en) * 2013-11-29 2014-03-19 北京广利核系统工程有限公司 Generation method and reconstruction method of visualization syntax tree of compiler
CN103778052A (en) * 2012-10-17 2014-05-07 百度在线网络技术(北京)有限公司 Method and device for front end javascript code testing
US8789018B2 (en) * 2011-05-31 2014-07-22 Microsoft Corporation Statically derived symbolic references for dynamic languages
CN104991773A (en) * 2015-06-30 2015-10-21 小米科技有限责任公司 Program generation method and apparatus
CN105025367A (en) * 2014-04-30 2015-11-04 中国科学院声学研究所 Page loading method based on digital set-top box
CN106874394A (en) * 2017-01-13 2017-06-20 百度在线网络技术(北京)有限公司 A kind of method and apparatus of file packing pretreatment
CN107038058A (en) * 2017-02-08 2017-08-11 阿里巴巴集团控股有限公司 A kind of code process method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8789018B2 (en) * 2011-05-31 2014-07-22 Microsoft Corporation Statically derived symbolic references for dynamic languages
CN103778052A (en) * 2012-10-17 2014-05-07 百度在线网络技术(北京)有限公司 Method and device for front end javascript code testing
CN103645986A (en) * 2013-11-29 2014-03-19 北京广利核系统工程有限公司 Generation method and reconstruction method of visualization syntax tree of compiler
CN105025367A (en) * 2014-04-30 2015-11-04 中国科学院声学研究所 Page loading method based on digital set-top box
CN104991773A (en) * 2015-06-30 2015-10-21 小米科技有限责任公司 Program generation method and apparatus
CN106874394A (en) * 2017-01-13 2017-06-20 百度在线网络技术(北京)有限公司 A kind of method and apparatus of file packing pretreatment
CN107038058A (en) * 2017-02-08 2017-08-11 阿里巴巴集团控股有限公司 A kind of code process method and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110362792A (en) * 2019-07-05 2019-10-22 五八有限公司 RN file is converted to the method, apparatus and conversion equipment of small routine file
CN110362792B (en) * 2019-07-05 2023-05-23 五八有限公司 Method and device for converting RN file into applet file and conversion equipment
CN110347416A (en) * 2019-07-19 2019-10-18 网易(杭州)网络有限公司 The update method and device of script

Also Published As

Publication number Publication date
CN107665124B (en) 2021-04-20

Similar Documents

Publication Publication Date Title
CN104407863B (en) Abstract control model programmer and method
CN107239491A (en) For realizing method, equipment, browser and electronic equipment that user behavior is followed the trail of
CN107451162A (en) Network resource accession equipment, mixing apparatus and method
CN107168749A (en) A kind of Compilation Method, device, equipment and computer-readable recording medium
CN103955367A (en) Method and device for generating pages
US20150143267A1 (en) SYSTEM AND METHOD FOR DEVELOPING A RULE-BASED EVENT-DRIVEN MULTI-LAYERED FRONTEND FOR BUSINESS SERVICES AND RENDERING THE GUIs ON MULTIPLE CLIENT DEVICES
CN104331315B (en) A kind of parsing of arbitrary levels json objects and generation method and system
EP3834080B1 (en) Static reconcilliation of application view hierarchies
CN112527281B (en) Operator upgrading method and device based on artificial intelligence, electronic equipment and medium
US12032941B2 (en) Method and system for updating legacy software
CN107168993A (en) Handle method, equipment, client device and the electronic equipment of response data
CN108089879A (en) Increment updating method, equipment and programmable device
TWI826702B (en) Techniques for defining and executing program code specifying neural network architectures
CN112015468A (en) Interface document processing method and device, electronic equipment and storage medium
CN109284488A (en) Based on the method, apparatus and medium that modification front end table column data is locally stored
CN107665124A (en) Modularization JavaScript file processing method, equipment and server
Shah Harnessing customized built-in elements--Empowering Component-Based Software Engineering and Design Systems with HTML5 Web Components
CN108255916A (en) Method, equipment, client terminal device and the electronic equipment that Webpage is presented
CN110275923B (en) Management method and equipment of plug-in graphics
US11922142B1 (en) Bi-directional design-to-code
CN103226475A (en) Method and device for realizing control replacement during transcoding
CN112632293B (en) Industry map construction method and device, electronic equipment and storage medium
CN103488477A (en) Visual editing system and visual editing method of JAVA interface
US8972927B2 (en) Method and system for providing modeled components
CN109032576A (en) A kind of cross-platform generation method and device based on configuration

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200528

Address after: 310051 room 508, floor 5, building 4, No. 699, Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province

Applicant after: Alibaba (China) Co.,Ltd.

Address before: 510627 Guangdong city of Guangzhou province Whampoa Tianhe District Road No. 163 Xiping Yun Lu Yun Ping square B radio tower 13 layer self unit 01

Applicant before: GUANGZHOU SHENMA MOBILE INFORMATION TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant