Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs: updated getting started guide to correct webpack config file extension to support CJS syntax#7518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
RajeevPullat wants to merge2 commits intowebpack:main
base:main
Choose a base branch
Loading
fromRajeevPullat:docs/fix_getting_started_webpackconfig_file_ext

Conversation

RajeevPullat
Copy link

Updated getting started guide to correct webpack config file extension to support CJS syntax

The docs used import statement in index.js which requires settingtype: "module". There is a PR raised for the samePR:7516. This PR to correct the webpack config file extension. The CommonJS code won't work in *.js extension and will throw below error.

[webpack-cli] ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension

So its best changed towebpack.config.cjs.

…ension to support CJS syntaxThe docs used import statement in index.js which requires setting `type: "module"`. There is a PR for the same `https://github.com/webpack/webpack.js.org/pull/7516`. This is to correct the webpack config file. The commonjs code won't work in *.js extension. So its changed to *.cjs.
@vercelVercel
Copy link

vercelbot commentedJan 11, 2025

@RajeevPullat is attempting to deploy a commit to theWebpack Docs Team onVercel.

A member of the Team first needs toauthorize it.

@Abhijeet641
Copy link

@RajeevPullat sir, did you fix the lint check ? could you please review my pr once#7513

@@ -237,14 +238,14 @@ As of version 4, webpack doesn't require any configuration, but most projects wi
webpack-demo
|- package.json
|- package-lock.json
+ |- webpack.config.js
+ |- webpack.config.cjs

Choose a reason for hiding this comment

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

Can we provide two examples here - for CommonJS and ECMA modules format?

@@ -271,7 +272,7 @@ cacheable modules 530 KiB
webpack 5.4.0 compiled successfully in 1934 ms
```

T>If a`webpack.config.js`is present, the`webpack` command picks it up by default. We use the `--config` option here only to show that you can pass a configuration of any name. This will be useful for more complex configurations that need to be split into multiple files.
T>By default, if you run the webpack command without specifying a configuration file, Webpack will look for certain default filenames. These typically include:`webpack.config.js`(for CommonJS format in JavaScript),`webpack.config.cjs` (for explicit CommonJS format) or `webpack.config.mjs` (for ES Modules). We use the `--config` option here only to show that you can pass a configuration of any name. This will be useful for more complex configurations that need to be split into multiple files.

Choose a reason for hiding this comment

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

👍

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

@alexander-akaitalexander-akaitalexander-akait left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@RajeevPullat@Abhijeet641@alexander-akait

[8]ページ先頭

©2009-2025 Movatter.jp