[Translation] webpack official website documentation: Concepts -- 7. Modules

Original translation, please indicate the source when reprinting.

Original address: https://webpack.js.org/concepts/modules/

 

In modular programming, the developer divides the program into several functional blocks called modules.

Each module has a small surface part relative to the entire program, which does some verification, debugging, and piecemeal testing. Write a better module that provides consistent abstraction and boundary encapsulation, so each module in the application as a whole has a clear design and a clear purpose.

Node.js has supported module programming almost since its inception. On the Internet, support modules have come slowly. There are already several tools on the web that support modules, and they have various advantages and limitations. Webpack learns from these systems and applies the concept of modules to all files in your project.

 

what is a webpack module

In contrast to Node.js modules, webpack modules extend their relevance through multiple channels. Some examples are:

  • An ES2015 import statement
  • A CommonJS require() statement
  • An AMD define and require statement
  • An @import declaration in the css/sass/less file

 

Supported Module Types

Webpack supports multiple languages ​​through loaders and preprocessing to make modules. Loaders tell webpack how to handle non-JavaScript modules and include their dependencies in your bundle. The Webpack community has created loaders for a variety of popular languages ​​and language processors, including:

  • CoffeeScript
  • TypeScript
  • ESNext(Babel)
  • Sass
  • Less
  • Stylus

 

And many more! In general, webpack provides a lot of powerful and rich customization APIs, which allows you to use webpack in any stack, provided your development, testing and production workflows are still in a scalable state.

 

-- End --

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326830803&siteId=291194637