Extracting boilerplate

Boilerplate code is sections of code that need to be included in various places, but with little or no alterations made to them. When using languages that are considered verbose, it is often necessary to write exhaustive amounts of code. This large section of code is called boilerplate. It has essentially the same purpose as a framework or library, and the terms are often conflated or mutually acceptable.

The Webpack community offers boilerplate installations, such as the combined installation of multiple common dependencies such as prerequisites and loaders. There are multiple versions of these boilerplates, and the use of these can expedite a build. Please search the Webpack Community pages (https://webpack.js.org/contribute/) or Webpack's GitHub page (https://github.com/webpack-contrib) for examples.

This being said, there will be times when only part of the boilerplate is required. For this, extracting the boilerplate functionality of Webpack may be required.

Webpack, while using its minification method, allows boilerplate to be extracted; that is, only the elements of the boilerplate you need are included in the bundle. This is an automated process that's done during the compilation process.

Minification is the key way in which Webpack 5 offers this extraction process and it's one of the more salient ways in which a bundler of this type can be used. There is another key process that is highly useful and native to Webpack 5. It takes us in a different direction regarding how bundles are built but is something that will no doubt follow on from a complex or custom build, such as a project that began by boilerplate being extracted. This process is known as Module Federation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.253.170