Home >Common Problem >How to understand webpack packaging principles
The webpack packaging principle is to statically analyze the dependencies between files, and generate static resources from these modules according to specified rules. When webpack processes the program, it will recursively build a dependency graph, which contains For each module your application needs, package all these modules into one or more bundles.
#The operating environment of this article: Windows 7 system, Dell G3 computer.
Webpack packaging principle is to statically analyze the dependencies between files, and then generate static resources from these modules according to specified rules. When webpack handles the program, it will be built recursively A dependency graph that contains every module an application requires, and then packages all of those modules into one or more bundles.
Webpack has two ways to organize module dependencies, synchronous and asynchronous. Asynchronous dependencies will be used as split points to form a new block; after optimizing the dependency tree, each asynchronous block will be packaged as a file.
Webpack has a smart parser that can handle almost any third-party library. Regardless of whether their module form is CommonJS, AMD or ordinary JS files; even when loading dependencies, dynamic tables require(",/templates/" name ", jade") are allowed.
Extension information
In a typical application or site built with webpack, there are three main types of code:
1. Source code written by the team.
2. Any third-party library or "vendor" code that the source code depends on.
3. Webpack’s runtime and manifest manage the interaction of all modules.
runtime includes: the loading and parsing logic required to connect modules during module interaction; including the connection of loaded modules in the browser, and the execution logic of lazy-loaded modules.
If you want to learn more about programming, please pay attention to the php training column!
The above is the detailed content of How to understand webpack packaging principles. For more information, please follow other related articles on the PHP Chinese website!