Skip to content

refactor(template): convert the default template from CMJs to esm#4709

Merged
alexander-akait merged 5 commits intowebpack:mainfrom
ThierryRakotomanana:refactor/default-config-to-esm
Mar 19, 2026
Merged

refactor(template): convert the default template from CMJs to esm#4709
alexander-akait merged 5 commits intowebpack:mainfrom
ThierryRakotomanana:refactor/default-config-to-esm

Conversation

@ThierryRakotomanana
Copy link
Contributor

@ThierryRakotomanana ThierryRakotomanana commented Mar 18, 2026

Summary

Currently, the official Getting Started using quick start minimal uses ES Modules (ESM) syntax. However, the command npx create-webpack-app still generates a webpack.config.js using CommonJS (require/module.exports). This creates a confusing experience for new users.

This PR rectifies webpack.config.js tempate to generate an ES Modules config by default.

What kind of change does this PR introduce?

It's refactor, I refactor the default config template
Did you add tests for your changes?
I've updated all test cases,

Does this PR introduce a breaking change?
Not really, just an update

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Use of AI
No need,

@changeset-bot
Copy link

changeset-bot bot commented Mar 18, 2026

🦋 Changeset detected

Latest commit: 1edb5f9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-webpack-app

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

You need to update all test cases, not just change it in template

@ThierryRakotomanana
Copy link
Contributor Author

@alexander-akait test cases updated

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.43%. Comparing base (49efdc0) to head (1edb5f9).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4709   +/-   ##
=======================================
  Coverage   91.43%   91.43%           
=======================================
  Files          14       14           
  Lines        4716     4716           
  Branches      679      679           
=======================================
  Hits         4312     4312           
  Misses        402      402           
  Partials        2        2           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49efdc0...1edb5f9. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Let's covert all templates in init, not only default, because we recommend to use ECMA modules everywhere

@ThierryRakotomanana
Copy link
Contributor Author

Got it

…stcases

- Add "type": "module" to package.json
- Convert Webpack configs for React, Vue, and Svelte to ESM syntax
- Polyfill __dirname/ __filename for ESM compatibility
- Fix missing VueLoaderPlugin import in Vue template
- Update test cases snapshot
@ThierryRakotomanana
Copy link
Contributor Author

@alexander-akait I've also add "type": "module" to all the package.json to fix the Warning [MODULE_TYPELESS_PACKAGE_JSON]

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Please use the same quotes - " everywhere in templates

@alexander-akait alexander-akait merged commit 493ef15 into webpack:main Mar 19, 2026
19 checks passed
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.

2 participants