Inconsistent module syntax in tutorial (ESM `import` vs. CommonJS `require`)
In the "Getting Started" tutorial section, webpack.config.js is initialized using ESM syntax:
webpack.config.jsimport path from "node:path"; import { fileURLToPath } from "node:url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); export default { entry: "./src/index.js", output: { filename: "main.js", path: path.resolve(__dirname, "dist"), }, };
However, in the section that immediately follows ("Asset Management"), CommonJS syntax is used:
webpack.config.jsconst path = require('path'); module.exports = { entry: './src/index.js', output: { - filename: 'main.js', + filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), }, };
This can be confusing to somebody who is completing the tutorial sequentially.
PR welcome
Hi! I’ve submitted a PR that aligns the Getting Started guide with a CommonJS webpack.config.js example: #7786.
This follows the approach discussed here.
Happy to adjust, rebase, or close it if it overlaps with other changes. Thanks!
Hi, I would like to work on aligning the module syntax in the tutorial by using CommonJS consistently across sections. Please let me know if that approach works.
Hi
I’d like to work on this issue if it’s still open.
I’ve reviewed the tutorial section and noticed the inconsistency between ESM (import) and CommonJS (require) syntax.
I’d be happy to standardize the examples according to the preferred module format used in the documentation.
Please let me know if I can proceed.