Skip to content

[DOCS] webpack documentation concept and config section from CommonJS to ESM#7731

Closed
payelcs2024ipcw-source wants to merge 6 commits intowebpack:mainfrom
payelcs2024ipcw-source:docs/convert-into-ESM
Closed

[DOCS] webpack documentation concept and config section from CommonJS to ESM#7731
payelcs2024ipcw-source wants to merge 6 commits intowebpack:mainfrom
payelcs2024ipcw-source:docs/convert-into-ESM

Conversation

@payelcs2024ipcw-source
Copy link
Copy Markdown

@payelcs2024ipcw-source payelcs2024ipcw-source commented Dec 21, 2025

Fixes #7636

This pull request updates the Concepts and Config section of the webpack documentation to reflect the transition from CommonJS to ECMAScript Modules (ESM).

Changes made:

  • Replaced module.exports examples with export default.
  • Updated require(...) usage to import ... from .....
  • Adjusted wording in the concept explanation to clarify that webpack config files are now standard ECMAScript modules rather than CommonJS modules.
  • Added notes on ESM-specific considerations (e.g., import.meta.url for resolving paths instead of __dirname).

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 21, 2025

@payelcs2024ipcw-source is attempting to deploy a commit to the OpenJS Foundation Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! I left a few comments that needs to be adressed. ☀️

Comment thread src/content/concepts/configuration.mdx Outdated
entry: './foo.js',
output: {
path: path.resolve(__dirname, 'dist'),
path: path.resolve(process.cwd(), 'dist'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont use process.cwd, use this

https://stackoverflow.com/a/50052194

Comment thread src/content/concepts/index.mdx Outdated
Comment thread src/content/concepts/plugins.mdx Outdated
@payelcs2024ipcw-source
Copy link
Copy Markdown
Author

Completed the assigned edits in the concept section and proceeded with further improvements in the config section.

@payelcs2024ipcw-source payelcs2024ipcw-source changed the title [DOCS] webpack documentation concept section from CommonJS to ESM [DOCS] webpack documentation concept and config section from CommonJS to ESM Dec 24, 2025
Comment thread src/content/concepts/plugins.mdx Outdated
const pluginName = 'ConsoleLogOnBuildWebpackPlugin';

class ConsoleLogOnBuildWebpackPlugin {
export default class ConsoleLogOnBuildWebpackPlugin {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected the typo error

Comment thread src/content/concepts/configuration.mdx Outdated
You may have noticed that few webpack configurations look exactly alike. This is because **webpack's configuration file is a JavaScript file that exports a webpack [configuration](/configuration/).** This configuration is then processed by webpack based upon its defined properties.

Because it's a standard Node.js CommonJS module, you **can do the following**:
Because it's a standard ECMAscript Module, you **can do the following**:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the S in script should be capitalized

Comment thread src/content/concepts/entry-points.mdx Outdated

```javascript
module.exports = {
export defualt {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong code

Comment thread src/content/concepts/entry-points.mdx Outdated

```javascript
module.exports = {
export deafult {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong code


```javascript
module.exports = {
export default {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apologies for the oversight earlier. I've double-checked and fixed the typo now. Please let me know if there r further any issues. Thank you.

Comment thread src/content/concepts/plugins.mdx Outdated
export default class ConsoleLogOnBuildWebpackPlugin {
apply(compiler) {
compiler.hooks.run.tap(pluginName, (compilation) => {
compiler.hooks.run.tap(pluginName, () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont remove the param.


```javascript
const path = require('path');
import path from 'path';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when you see this, you will need to add the __dirname code to each snippet.


module.exports = {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes have been made as requested.

@alexander-akait
Copy link
Copy Markdown
Member

Fixed in the main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Update documentation examples to ES6

3 participants