Home >Common Problem >How to understand webpack packaging principles

How to understand webpack packaging principles

coldplay.xixi
coldplay.xixiOriginal
2021-02-01 15:37:1425721browse

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.

How to understand webpack packaging principles

#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.

How to understand webpack packaging principles

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn