Analysis of Web pack package js file

When using projects in webpack, we can use esModule, commonJS, and import(moduleName) for lazy module loading. How does webpack do all this?1. Preparation:1.1. Use webapck@4 webpack- cli@3"html-webpack-plugin": "4", "webpack": "4", "webpack-cli": "3"1.2 document structure1.3, webpack.config.jsconst path = require('path') const HtmlWebpackPlugi ...

Posted by Codein on Fri, 25 Feb 2022 16:43:39 +0100

Explain ESM module and CommonJS module in simple terms

Ruan Yifeng Getting started with ES6 There are some significant differences between ES6 module and CommonJS module mentioned in:The CommonJS module outputs a copy of the value, while the ES6 module outputs a reference to the value.CommonJS module is loaded at run time, and ES6 module is the output interface at compile time.If you read the diffe ...

Posted by Phate on Sun, 13 Feb 2022 02:43:48 +0100