[DOCS] webpack documentation concept and config section from CommonJS to ESM#7731
[DOCS] webpack documentation concept and config section from CommonJS to ESM#7731payelcs2024ipcw-source wants to merge 6 commits intowebpack:mainfrom
Conversation
|
@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. |
evenstensberg
left a comment
There was a problem hiding this comment.
Thanks for your PR! I left a few comments that needs to be adressed. ☀️
| entry: './foo.js', | ||
| output: { | ||
| path: path.resolve(__dirname, 'dist'), | ||
| path: path.resolve(process.cwd(), 'dist'), |
There was a problem hiding this comment.
Dont use process.cwd, use this
|
Completed the assigned edits in the concept section and proceeded with further improvements in the config section. |
| const pluginName = 'ConsoleLogOnBuildWebpackPlugin'; | ||
|
|
||
| class ConsoleLogOnBuildWebpackPlugin { | ||
| export default class ConsoleLogOnBuildWebpackPlugin { |
There was a problem hiding this comment.
corrected the typo error
| 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**: |
There was a problem hiding this comment.
the S in script should be capitalized
|
|
||
| ```javascript | ||
| module.exports = { | ||
| export defualt { |
|
|
||
| ```javascript | ||
| module.exports = { | ||
| export deafult { |
|
|
||
| ```javascript | ||
| module.exports = { | ||
| export default { |
There was a problem hiding this comment.
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.
src/content/concepts/plugins.mdx
Outdated
| export default class ConsoleLogOnBuildWebpackPlugin { | ||
| apply(compiler) { | ||
| compiler.hooks.run.tap(pluginName, (compilation) => { | ||
| compiler.hooks.run.tap(pluginName, () => { |
|
|
||
| ```javascript | ||
| const path = require('path'); | ||
| import path from 'path'; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
the changes have been made as requested.
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:
module.exportsexamples withexport default.require(...)usage toimport ... from .....import.meta.urlfor resolving paths instead of__dirname).