Splitting method and device, electronic equipment and storage medium
By obtaining and matching the public dependency metadata in the public package, the problem of resource reusability in the cross-platform development framework is solved, page splitting and resource reusing are achieved, and page size and access speed are reduced.
Patent Information
- Application Number
- CN202410009936.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-03
- Publication Date
- 2025-07-04
AI Technical Summary
Page resources cannot be reused in the cross-platform development framework, resulting in large page size, affecting network bandwidth and access speed.
By obtaining the public dependency metadata in the public package, matching the objects to be split in the currently built target page, and associating the objects to be split in the target page according to the matching results to achieve resource reuse.
Reduces page size, reduces network bandwidth and page access speed, and realizes resource reuse.
Smart Images

Figure CN120255885A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to computer technologies, and in particular, to a splitting method, apparatus, electronic device, and storage medium. Background Art
[0002] A cross-platform development framework is a software framework that can be used to develop application programs on different operating systems and platforms. Page construction can be achieved through the cross-platform development framework.
[0003] When developing software through a cross-platform development framework, resources on the page are not reused. As a result, the page size is relatively large, which in turn affects network bandwidth and page access speed. Summary of the Invention
[0004] The present disclosure provides a splitting method, apparatus, electronic device, and storage medium to achieve page splitting and resource reuse on the page.
[0005] In a first aspect, embodiments of the present disclosure provide a splitting method, including:
[0006] Obtaining a common package, where the common package includes metadata of common dependencies;
[0007] Comparing an object to be split in a currently built target page with the common dependencies in the common package to obtain a matching result, where the matching result indicates whether the object to be split is included in the common package;
[0008] Associating the object to be split in the target page according to the matching result.
[0009] In a second aspect, embodiments of the present disclosure further provide a splitting apparatus, including:
[0010] An obtaining module, configured to obtain a common package, where the common package includes metadata of common dependencies;
[0011] A matching module, configured to compare an object to be split in a currently built target page with the common dependencies in the common package to obtain a matching result, where the matching result indicates whether the object to be split is included in the common package;
[0012] An associating module, configured to associate the object to be split in the target page according to the matching result.
[0013] In a third aspect, embodiments of the present disclosure further provide an electronic device, where the electronic device includes:
[0014] One or more processing devices;
[0015] A storage device, configured to store one or more programs,
[0016] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the splitting method provided by the present disclosure.
[0017] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium including computer-executable instructions, which are used to execute the splitting method provided by the present disclosure when executed by a computer processor.
[0018] In the embodiment of the present disclosure, by obtaining a common package, the common package includes metadata of common dependencies; comparing the objects to be split in the currently built target page with the common dependencies in the common package to obtain a matching result, the matching result indicating whether the object to be split is included in the common package; associating the object to be split in the target page according to the matching result, which solves the problem that resources cannot be reused when building a page through a cross-platform development framework. During the process of page building, it is determined whether it matches the object to be split in the currently built target page based on the common package, so as to associate the object to be split with the target page based on the matching result. Associating at least one object to be split with the target page realizes the splitting of the page, and the reuse of resources in the target page is realized through the matching result association between the object to be split and the common package. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Combined with the accompanying drawings and referring to the following specific embodiments, the above and other features, advantages and aspects of the embodiments of the present disclosure will become more obvious. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic, and the original components and elements are not necessarily drawn to scale.
[0020] Figure 1 is a schematic flowchart of a splitting method provided by an embodiment of the present disclosure;
[0021] Figure 2 is a schematic flowchart of another splitting method provided by an embodiment of the present disclosure;
[0022] Figure 3 is a schematic flowchart of a splitting process provided by an embodiment of the present disclosure;
[0023] Figure 4 is a schematic flowchart of a process for constructing common dependencies provided by an embodiment of the present disclosure;
[0024] Figure 5 is a schematic flowchart of a process for publishing and consuming common dependencies provided by an embodiment of the present disclosure;
[0025] Figure 6 is a schematic structural diagram of a splitting device provided by an embodiment of the present disclosure;
[0026] Figure 7 It is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. Specific embodiments
[0027] The embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. On the contrary, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.
[0028] It should be understood that the various steps recorded in the method embodiments of the present disclosure can be executed in different orders and / or executed in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0029] The term "including" and its variations used herein are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0030] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependent relationships.
[0031] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly stated in the context, it should be understood as "one or more".
[0032] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.
[0033] JavaScript (abbreviated as JS) and component products built by a cross-platform development framework are usually used by the built pages. Since it is difficult to split JS, it has not been possible to reuse the same JS and components in multiple services, resulting in unnecessary waste of resources and costs. To solve this technical problem, the present disclosure provides a splitting method.
[0034] Figure 1It is a schematic flowchart of a splitting method provided by an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to the situation of splitting a page. This method can be executed by a splitting device, which can be implemented in the form of software and / or hardware. Optionally, it is implemented by an electronic device, which can be a mobile terminal, a PC, a server, etc.
[0035] As Figure 1 shown, the method includes:
[0036] S110. Obtain a common package.
[0037] The common package includes metadata of common dependencies. Common dependencies can be libraries, frameworks, or other external resources that are commonly relied on by multiple components or modules.
[0038] In one embodiment, the common dependencies include at least one of a component and a file block. A component can be a reusable code unit. A file block can be the product after splitting a JS file, also known as a chunk.
[0039] In this embodiment, a common package can be obtained during the process of building a target page, so as to implement the construction of the page based on the common dependencies included in the common package and reuse the common dependencies in the common package.
[0040] This embodiment can obtain the common package from the storage platform of the common package.
[0041] S120. Compare the object to be split in the currently built target page with the common dependencies in the common package to obtain a matching result.
[0042] The target page can be the currently built page. The object to be split can be the object to be split in the target page, such as a component and / or JS. The matching result indicates whether the object to be split is included in the common package.
[0043] After obtaining the common package in this embodiment, during the process of building the target page, the object to be split can be compared with the common dependencies in the common package to determine whether the object to be split is included in the common package. If so, the common dependencies stored in the common package can be directly used; if not, the object to be split can be locally built.
[0044] Different objects to be split correspond to different matching means, which are not limited here.
[0045] In one embodiment, when the object to be split is a component to be split, the matching can be performed in the pre-compilation hook function. When the object to be split is a target module, the matching can be performed in the parsing hook function.
[0046] Among them, the component to be split can be the component to be split in the target page. The target module can be the JS file to be split in the target page. The pre-compilation hook function, also known as the before compilation hook, is triggered before component compilation and can be used to match the component to be split with the common dependencies. The parsing hook function, also known as the resolve hook, is triggered when resolving the dependency relationship and can be used to match the target module with the common dependencies.
[0047] S130. Associate the object to be split in the target page according to the matching result.
[0048] After determining the matching result, the object to be split can be associated in the target page. During the process of associating the object to be split, the association means can be determined based on the matching result.
[0049] In one embodiment, when the matching result indicates that the object to be split exists in the common package, the common dependencies corresponding to the object to be split in the common package can be used as the object to be split. This avoids building the object to be split. The storage path of the object to be split is associated in the target page so that the code of the object to be split is included in the target page, reducing the page size.
[0050] In one embodiment, when the matching result indicates that the object to be split does not exist in the common package, the object to be split can be built and the build result of the object to be split can be associated with the target page.
[0051] The number of objects to be split in the target page can be at least one. The target page is divided into multiple objects to be split, realizing the division of the target page.
[0052] The technical solution of the embodiments of the present disclosure obtains a common package, where the common package includes metadata of common dependencies; compares the object to be split in the currently built target page with the common dependencies in the common package to obtain a matching result, and the matching result indicates whether the object to be split is included in the common package; associates the object to be split in the target page according to the matching result, solves the problem that resources cannot be reused when building a page through a cross-platform development framework, determines whether it matches the object to be split in the currently built target page based on the common package during the page building process, and associates the object to be split with the target page based on the matching result. Associating at least one object to be split with the target page realizes the splitting of the page, and realizes the reuse of resources in the target page through the matching result association between the object to be split and the common package.
[0053] Figure 2 It is a schematic flowchart of another splitting method provided by the embodiments of the present disclosure. Figure 2Specifically disclosed is an operation of associating the object to be split in the target page according to the matching result. Refer to Figure 2 , the splitting method includes the following operations:
[0054] S210. Obtain a common package.
[0055] S220. Compare the object to be split in the currently constructed target page with the common dependencies in the common package to obtain a matching result.
[0056] S230. In the case where the matching result indicates that the object to be split is included in the common package, use the common dependency in the common package that matches the object to be split as the object to be split, and associate the object to be split in the target page, and end the operation.
[0057] Using the common dependency in the common package that matches the object to be split as the object to be split avoids the operation of constructing the object to be split during the process of constructing the target page, realizing the reuse of resources.
[0058] When constructing the target page, the common dependency that is the object to be split can be directly associated with the target page, and it also avoids repeatedly writing the code of the object to be split into the target page, thereby reducing the volume of the target page.
[0059] S240. In the case where the matching result indicates that the object to be split is not included in the common package, construct the object to be split and associate the object to be split in the target page.
[0060] In the case where the object to be split is not included in the common package, this operation can construct the object to be split and associate the object to be split in the target page.
[0061] When associating the object to be split in the target page, the association can be implemented at least based on the storage address of the object to be split. Different objects to be split correspond to different association means.
[0062] The splitting method provided in this embodiment determines whether it is necessary to construct the object to be split based on whether the object to be split exists in the common package, and then associates the object to be split to the target page, realizing the reuse of resources in the common package.
[0063] Based on the above embodiments, a variant embodiment of the above embodiments is proposed. Here, it should be noted that for the sake of brief description, only the differences from the above embodiments are described in the variant embodiment.
[0064] In one embodiment, the object to be split is a component to be split. Correspondingly, associating the object to be split in the target page includes:
[0065] Determine the component to be split including the split flag through the conversion component hook function;
[0066] Replace the component name of the compiled component to be split with a set keyword through the conversion component hook function;
[0067] Add the storage path of the component to be split to the path attribute for constructing the target page in the cross-platform development framework.
[0068] The conversion component hook function can be regarded as a hook function for implementing component conversion, also known as the transformcomponent hook, which can be triggered before compilation. The split identifier can be regarded as an identifier indicating that the corresponding component needs to be split. When a component needs to be split, the distinction between whether the component is split or not can be achieved by adding a split identifier. The component containing the split identifier can be used as the component to be split, that is, the component to be split.
[0069] The set keyword can be a set keyword, such as component. Replacing the component name with the set keyword facilitates subsequent processing of the component name as a corresponding component as a dynamic component.
[0070] The storage path can be regarded as the path of the storage space of the component to be split. The path attribute can be an attribute in the cross-platform development framework for specifying the storage path to facilitate the consumption of dynamic components.
[0071] In one embodiment, the object to be split is the target module. Correspondingly, associating the object to be split in the target page includes:
[0072] Encapsulate the object to be split into the loading module of the target page through the loading hook function.
[0073] The target module can be a JS file to be split. The loading hook function is also called the load hook, which can be triggered when loading dependencies. Through the loading hook function, the object to be split can be encapsulated into the loading module of the target page. The loading module can be a template for implementing the loading of the target module. This operation can add the construction result of the target module to the loading module to realize the association between the target page and the object to be split.
[0074] In one embodiment, constructing the object to be split includes:
[0075] Determine whether there is an object to be split being constructed during the construction of the target page;
[0076] If there is an object to be split being constructed, wait until the object to be split is constructed, otherwise construct the object to be split.
[0077] During the process of constructing the target page, when the target module does not exist in the common package, it can determine whether the object to be split is in the construction process. If so, it can wait for the construction of the object to be split to complete to obtain the construction information of the object to be split. If not, it can construct the object to be split.
[0078] In one embodiment, the object to be split is a component to be split. Correspondingly, comparing the object to be split in the currently constructed target page with the common dependencies in the common package to obtain a matching result includes:
[0079] Determining whether the common dependencies in the common package include the component to be split through a pre-compilation hook function to obtain a matching result.
[0080] In this embodiment, through the pre-compilation hook function, it can be determined whether there are common dependencies in the common package that match the component to be split, so as to obtain a matching result indicating that the common package includes the component to be split or the common package does not include the component to be split.
[0081] In one embodiment, the object to be split is a target module. Correspondingly, comparing the object to be split in the currently constructed target page with the common dependencies in the common package to obtain a matching result includes:
[0082] Determining the version information of the target module through a parsing hook function;
[0083] Determining whether the common package includes common dependencies that match the version information through the parsing hook function to obtain a matching result.
[0084] The version information can be information representing the version of the target module. When matching the object to be split and the common package, this embodiment can perform the matching based on the version information.
[0085] In this embodiment, the version information of the target module can be obtained in the parsing hook function, and then the common dependencies in the common package are matched through the version information to determine whether there are common dependencies in the common package that match the object to be split.
[0086] Figure 3 This is a schematic diagram of a splitting process provided by an embodiment of the present disclosure. See Figure 3, start building the target page through the page building tool, then read the meta information of the common dependencies, that is, obtain the common package, and the common package includes the metadata of the common dependencies. Then store the common package in the build cache. During the process of using the page building tool to build the target page through the cross-platform development framework, multiple hook functions will be used, such as pre-compilation hook functions, parsing hook functions, loading hook functions, and transforming component hook functions. The type of the pre-compilation hook function can be an asynchronous serial hook, that is, an async serieshook. The types of the parsing hook function and the loading hook function can be asynchronous serial fuse hooks, also known as Async SeriesBail Hook. The type of the transforming component hook function can be an asynchronous serial waterfall hook, also known as Async SeriesWaterfall Hook.
[0087] The pre-compilation hook function and the transforming component hook function can achieve the splitting of components. The parsing hook function and the loading hook function can achieve the splitting of JS.
[0088] In the pre-compilation hook function, it can be determined whether the current component is included in the meta information, that is, it can be determined whether the common dependencies in the common package include the component to be split, and a matching result is obtained. The current component can be considered as the component being currently processed. In the case that the current component is not included in the meta information, an independent build instance can be started to build the dynamic component, that is, build the object to be split, and thus the construction of the component to be split is achieved.
[0089] In the transforming component hook function, it can be determined whether the source code contains a flag bit, that is, it can be determined the component to be split including the split flag bit. If it contains, perform transformation through the compiler, that is, compile the component to be split. Then replace the component name with a set keyword, that is, replace the component name of the compiled component to be split with the set keyword. Then obtain the storage path of the current component, and add a path attribute according to the product path, that is, add the storage path of the component to be split to the path attribute for building the target page by the cross-platform development framework, and thus the splitting of the component is completed.
[0090] In the parsing hook function, it is determined whether the target module needs to be split into text chunks according to the strategy or the user's configuration. If so, read the current dependency version information to create a semantic version control object to obtain the package dependency version, that is, determine the version information of the target module. Judge whether the package dependency version information matches the meta information. If so, return the namespace and the file chunk build information; if not, judge whether there is an existing build instance to build the file chunk. If so, wait until the instance completes the build. If not, start an independent build instance to build the corresponding file chunk. In the development mode, add the corresponding file to facilitate automatic building when the file chunk changes.
[0091] The parsing hook function finally returns the namespace and file block construction information. The namespace is used to implement the matching between unpacked parts, such as the matching when the parsing hook function and the loading hook function interact with data, to achieve the effective transmission of the file block construction information. The file block construction information can be regarded as the construction information of the file block, including the storage path of the file block.
[0092] In this embodiment, the parsing hook function identifies the target module that needs to be split into file blocks through the import statement. If this dependency already exists in the common package, the common dependency is directly introduced. If the corresponding dependency does not exist in the common package, an independent build tool is started with the target module as the entry to compile the build process. The compilation result will be cached and returned, and the independent build instance will output the product to a predetermined path.
[0093] In the loading hook function, the construction result of the file block passed through by the parsing hook function can be read, and it is judged whether the file block is a common dependency in the common package. If so, an additional buried point wrapper can be encapsulated to realize the management of the file block. The loading hook function can encapsulate the file block into the loading module to achieve the splitting of JS. The product of the JS splitting is the file block, also known as the chunk. The loading hook function adds a wrapper to the compilation result (product path) obtained by the parsing hook function and assembles it into a module.
[0094] Through the above technical solutions, this embodiment avoids the problems of the excessive volume of the target page and the non-reuse of common dependencies. Furthermore, it avoids the increase in network bandwidth and page access speed. The unpacking method in this embodiment can be used as an unpacking plugin, and users, that is, page developers, can achieve the automatic splitting of JS and components in the page through the unpacking plugin.
[0095] For example, the resources shared by pages a, b, and c are set in the common package, and there is no need to write the shared resources in pages a, b, and c, reducing the page volume.
[0096] This disclosure automatically splits the dependencies of the target page by designing the default splitting strategy; the split JS and component products are deployed separately, and are recognized during the build process through a page build tool, such as the Speedy plugin, to introduce the corresponding JS or components, realizing the sharing of JS resources among multiple pages. It reduces the split access cost of JS and components in the target page, reduces the product volume, and lowers the release cost.
[0097] Among them, the default splitting strategy can be:
[0098] 1. Split the dependencies of all the first-level node modules (i.e., node_modules) of the project. The node module directory is managed in the dependency management tool, and this embodiment can split the first-level node modules. That is, split the direct dependencies of the project;
[0099] 2. Compatible with the original dynamic JS query (i.e., Query) form to determine whether to split according to the policy and configuration in the parsing hook function, so as to determine whether it is the first-level dependency or the JS query form; and be compatible with the original splitting method through the dynamic JS query form. That is, before using the splitting plugin, the compatibility of splitting has been achieved through the JS query form. Among them, the policy can be the default policy, and the configuration can be the user-defined configuration.
[0100] 3. Bypass the non-splittable dependencies.
[0101] Figure 4 is a schematic flowchart of a process for constructing a common dependency provided by an embodiment of the present disclosure; refer to Figure 4 , merge the user-defined configuration and the default configuration for use as a configuration file for reference when constructing the dependency. Then, for the specified dependency, that is, the specified js or component that can be used as a common dependency, start the build tool to compile and build, and generate meta information according to the build product. Then upload the product to the storage platform for use during page construction.
[0102] Figure 5 is a schematic flowchart of a process for publishing and consuming a common dependency provided by an embodiment of the present disclosure; refer to Figure 5 , the developer's electronic device can deploy an offline common package to the storage platform. The cross-terminal container can download the offline common package from the storage platform. The electronic device for realizing the target page browsing can access the target page, initialize the container through the cross-terminal container, and then open the target page. The process of successfully obtaining the engine and the basic library can be that the cross-terminal container obtains offline resources, the storage platform returns the offline resources, and the cross-terminal container transfers the dynamic JS or dynamic components to the target page. The process of failing to obtain the engine and the basic library can be to obtain offline resources from the storage platform. After failure, remotely request the JS library, and transfer the dynamic JS and dynamic components after the remote request is successful.
[0103] Figure 6 is a schematic structural diagram of a splitting device provided by an embodiment of the present disclosure, as Figure 6 shown, the device includes:
[0104] An acquisition module 610, configured to acquire a common package, where the common package includes metadata of a common dependency;
[0105] A matching module 620, configured to match an object to be split in the currently constructed target page with the common dependencies in the common package to obtain a matching result, where the matching result indicates whether the object to be split is included in the common package;
[0106] An association module 630, configured to associate the object to be split in the target page according to the matching result.
[0107] The technical solution provided by the embodiments of the present disclosure solves the problem that resources cannot be reused when building a page through a cross-platform development framework. During the page building process, it is determined whether it matches the object to be split in the target page being currently built based on the common package, so as to associate the object to be split with the target page based on the matching result, and the target page is associated with at least one object to be split to achieve the splitting of the page. The reuse of resources in the target page is achieved through the matching result association between the object to be split and the common package.
[0108] In one embodiment, the association module 630 includes:
[0109] The first association unit is configured to, when the matching result indicates that the object to be split is included in the common package, use the common dependency in the common package that matches the object to be split as the object to be split, and associate the object to be split in the target page;
[0110] The second association unit is configured to, when the matching result indicates that the object to be split is not included in the common package, construct the object to be split and associate the object to be split in the target page.
[0111] In one embodiment, the object to be split is a component to be split. Correspondingly, the first association unit and the second association unit are specifically configured to:
[0112] Determine the component to be split including the split flag bit through the conversion component hook function;
[0113] Replace the component name of the compiled component to be split with a set keyword through the conversion component hook function;
[0114] Add the storage path of the component to be split to the path attribute for building the target page by the cross-platform development framework through the conversion component hook function.
[0115] In one embodiment, the object to be split is a target module. Correspondingly, the first association unit and the second association unit are specifically configured to:
[0116] Encapsulate the object to be split into the loading module of the target page through the loading hook function.
[0117] In one embodiment, the second association unit is specifically configured to:
[0118] Determine whether there is an object to be split being built during the construction of the target page;
[0119] If there is an object to be split being built, wait until the object to be split is built, otherwise construct the object to be split.
[0120] In one embodiment, the object to be split is a component to be split. Correspondingly, the matching module 520 is specifically configured to:
[0121] Determine whether the common dependencies in the common package include the component to be split through a pre-compilation hook function, and obtain a matching result.
[0122] In one embodiment, the object to be split is a target module. Correspondingly, the matching module 520 is specifically configured to:
[0123] Determine the version information of the target module through a parsing hook function;
[0124] Determine whether the common package includes common dependencies that match the version information through the parsing hook function, and obtain a matching result.
[0125] In one embodiment, the common dependencies include at least one of a component and a file block.
[0126] The splitting device provided by the embodiments of the present disclosure can execute the splitting method provided by any embodiment of the present disclosure, and has corresponding functional modules and beneficial effects for executing the method.
[0127] It should be noted that the various units and modules included in the above device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0128] Figure 7 It is a schematic structural diagram of an electronic device provided by the embodiments of the present disclosure. The following refers to Figure 7 , which shows a schematic structural diagram of an electronic device (such as Figure 7 the terminal device or server in
[0129] The electronic device 500 includes one or more processing devices 501;
[0130] A storage device 508 for storing one or more programs,
[0131] When the one or more programs are executed by the one or more processing devices 501, the one or more processing devices 501 implement the splitting method as described in any one of the present disclosure.
[0132] The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Computers), PMPs (Portable Multimedia Players), in-vehicle terminals (such as in-vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not impose any limitation on the functions and usage scope of the embodiments of the present disclosure.
[0133] As Figure 7 shown, the electronic device 500 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 501, which may perform various appropriate actions and processes according to the programs stored in the read-only memory (ROM) 502 or the programs loaded from the storage device 508 into the random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. The editing / output (I / O) interface 505 is also connected to the bus 504.
[0134] Generally, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or wirelessly to exchange data. Although Figure 7 the electronic device 500 with various devices is shown, it should be understood that it is not required to implement or include all the shown devices. More or fewer devices may be implemented or included alternatively.
[0135] Particularly, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, the embodiments of the present disclosure include a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are executed.
[0136] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are for illustrative purposes only and are not used to limit the scope of these messages or information.
[0137] The electronic device provided in the embodiments of the present disclosure and the splitting method provided in the above embodiments belong to the same inventive concept. For technical details not described in detail in this embodiment, reference may be made to the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0138] The embodiments of the present disclosure provide a computer storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the splitting method provided in the above embodiments.
[0139] It should be noted that the computer-readable medium in the present disclosure may be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two above.
[0140] The computer storage medium may be a storage medium for computer-executable instructions. When the computer-executable instructions are executed by a computer processor, they are used to execute the method provided in the present disclosure.
[0141] The computer-readable storage medium may be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable signal medium may send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted by any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0142] In some embodiments, the client and the server can communicate using any currently known or future-developed network protocol such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include local area networks ("LANs"), wide area networks ("WANs"), the Internet (e.g., the Internet), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.
[0143] The above computer-readable medium can be included in the above electronic device; or it can exist separately without being assembled into the electronic device.
[0144] The above computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to:
[0145] The above computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: obtain a common package, where the common package includes metadata of common dependencies;
[0146] Match the object to be split in the currently built target page with the common dependencies in the common package to obtain a matching result, where the matching result indicates whether the object to be split is included in the common package;
[0147] Associate the object to be split in the target page according to the matching result.
[0148] Computer program code for performing the operations of the present disclosure can be written in one or more programming languages or combinations thereof. The above programming languages include, but are not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., by using an Internet service provider to connect through the Internet).
[0149] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur in a different order than noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or by a combination of dedicated hardware and computer instructions.
[0150] The modules or units involved in the embodiments described in the present disclosure can be implemented in software or in hardware. Among them, the name of the module or unit does not constitute a limitation on the unit itself in some cases. For example, the acquisition module can also be described as the "common package acquisition module".
[0151] The functions described above herein can be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), and so on.
[0152] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0153] According to one or more embodiments of the present disclosure, [Example 1] provides a splitting method, including:
[0154] Obtain a common package, which includes metadata of common dependencies;
[0155] Match the object to be split in the currently built target page with the common dependencies in the common package to obtain a matching result, where the matching result indicates whether the object to be split is included in the common package;
[0156] Associate the object to be split in the target page according to the matching result.
[0157] According to one or more embodiments of the present disclosure, [Example 2] provides the method of Example 1. The associating the object to be split in the target page according to the matching result includes:
[0158] When the matching result indicates that the object to be split is included in the common package, use the common dependency in the common package that matches the object to be split as the object to be split, and associate the object to be split in the target page;
[0159] When the matching result indicates that the object to be split is not included in the common package, construct the object to be split and associate the object to be split in the target page.
[0160] According to one or more embodiments of the present disclosure, [Example 3] provides the method described in Example 2. The object to be split is a component to be split. Correspondingly, associating the object to be split in the target page includes:
[0161] Determine the component to be split including a split flag bit through a conversion component hook function;
[0162] Replace the component name of the compiled component to be split with a set keyword through a conversion component hook function;
[0163] Add the storage path of the component to be split to the path attribute for building the target page by a cross-platform development framework through a conversion component hook function.
[0164] According to one or more embodiments of the present disclosure, [Example 4] provides the method described in Example 2. The object to be split is a target module. Correspondingly, associating the object to be split in the target page includes:
[0165] Encapsulate the object to be split into the loading module of the target page through a loading hook function.
[0166] According to one or more embodiments of the present disclosure, [Example 5] provides the method described in Example 2. The constructing the object to be split includes:
[0167] Determine whether there is an object to be split under construction during the construction of the target page;
[0168] If there is an object to be split under construction, wait for the object to be split to be constructed, otherwise construct the object to be split.
[0169] According to one or more embodiments of the present disclosure, [Example 6] provides the method described in Example 1, where the object to be split is a component to be split. Correspondingly, comparing the object to be split in the currently constructed target page with the common dependencies in the common package to obtain a matching result includes:
[0170] Determine whether the common dependencies in the common package include the component to be split through a pre-compilation hook function to obtain a matching result.
[0171] According to one or more embodiments of the present disclosure, [Example 7] provides the method described in Example 1, where the object to be split is a target module. Correspondingly, comparing the object to be split in the currently constructed target page with the common dependencies in the common package to obtain a matching result includes:
[0172] Determine the version information of the target module through a parsing hook function;
[0173] Determine whether the common package includes common dependencies matching the version information through the parsing hook function to obtain a matching result.
[0174] According to one or more embodiments of the present disclosure, [Example 8] provides the method described in Example 1, where the common dependencies include at least one of components and file blocks.
[0175] According to one or more embodiments of the present disclosure, [Example 9] provides a splitting device, including:
[0176] An acquisition module, configured to acquire a common package, where the common package includes metadata of common dependencies;
[0177] A matching module, configured to compare the object to be split in the currently constructed target page with the common dependencies in the common package to obtain a matching result, and the matching result indicates whether the object to be split is included in the common package;
[0178] An association module, configured to associate the object to be split in the target page according to the matching result.
[0179] According to one or more embodiments of the present disclosure, [Example 10] provides an electronic device, and the electronic device includes:
[0180] One or more processing devices;
[0181] A storage device for storing one or more programs,
[0182] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the splitting method described in any one of Examples 1-8.
[0183] According to one or more embodiments of the present disclosure, [Example 11] provides a storage medium containing computer-executable instructions that are used to execute the splitting method described in any one of Examples 1-8 when executed by a computer processor.
[0184] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the (but not limited to) technical features with similar functions disclosed in the present disclosure.
[0185] In addition, although the operations are depicted in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented in combination in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0186] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms for implementing the claims.
Claims
1. A splitting method, characterized in that, including: Obtain a common package, where the common package includes metadata of common dependencies; Match the object to be split in the currently built target page with the common dependencies in the common package to obtain a matching result, where the matching result indicates whether the object to be split is included in the common package; Associate the object to be split in the target page according to the matching result.
2. The method according to claim 1, characterized in that, The associating the object to be split in the target page according to the matching result includes: When the matching result indicates that the object to be split is included in the common package, use the common dependency in the common package that matches the object to be split as the object to be split, and associate the object to be split in the target page; When the matching result indicates that the object to be split is not included in the common package, construct the object to be split and associate the object to be split in the target page.
3. The method according to claim 2, wherein The object to be split is a component to be split. Correspondingly, associating the object to be split in the target page includes: Determine the component to be split including a split flag bit through a conversion component hook function; Replace the component name of the compiled component to be split with a set keyword through a conversion component hook function; Add the storage path of the component to be split to the path attribute of the cross-platform development framework for constructing the target page through a conversion component hook function.
4. The method according to claim 2, wherein The object to be split is a target module. Correspondingly, associating the object to be split in the target page includes: Encapsulate the object to be split into the loading module of the target page through a loading hook function.
5. The method according to claim 2, characterized in that, The constructing the object to be split includes: Determine whether there is an object to be split under construction during the construction of the target page; If there is an object to be split under construction, wait for the object to be split to be constructed, otherwise construct the object to be split.
6. The method according to claim 1, wherein The object to be split is a component to be split. Correspondingly, the matching the object to be split in the currently built target page with the common dependencies in the common package to obtain a matching result includes: Determine whether the common dependencies in the common package include the component to be split through a pre-compilation hook function to obtain a matching result.
7. The method according to claim 1, wherein The object to be split is a target module. Correspondingly, the matching the object to be split in the currently built target page with the common dependencies in the common package to obtain a matching result includes: Determine the version information of the target module through a parsing hook function; Determine whether the common package includes a common dependency that matches the version information through the parsing hook function to obtain a matching result.
8. The method according to claim 1, characterized in that The common dependencies include at least one of a component and a file block.
9. A splitting device, characterized in that, including: An acquisition module for acquiring a common package, where the common package includes metadata of common dependencies; A matching module for matching the object to be split in the currently built target page with the common dependencies in the common package to obtain a matching result, where the matching result indicates whether the object to be split is included in the common package; An association module for associating the object to be split in the target page according to the matching result.
10. An electronic device, characterized in that, The electronic device includes: One or more processing devices; A storage device for storing one or more programs, When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the splitting method according to any one of claims 1-8.
11. A storage medium containing computer-executable instructions which, when executed by a computer processor, are used to execute the splitting method according to any one of claims 1-8.