Skip to content

feat: improve module.exports bundle to ESM library #19776

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2025
Merged

Conversation

hai-x
Copy link
Member

@hai-x hai-x commented Aug 9, 2025

What kind of change does this PR introduce?

If we have CommonJsSelfReferenceDependency, we will generate default export statement in ESM library output.

// CommonJsSelfReferenceDependency
module.exports = {}

// CommonJsSelfReferenceDependency
this.foo = {}

// CommonJsSelfReferenceDependency
Object.defineProperty(module.export, "foo", ...)

Partial support about 💎Nice CommonJS modules are converted to ESM

Did you add tests for your changes?

Yes

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

Nothing

Copy link

codspeed-hq bot commented Aug 9, 2025

CodSpeed Performance Report

Merging #19776 will degrade performances by 91.44%

Comparing cjs-to-esm (39455bd) with main (67379fe)

Summary

⚡ 2 improvements
❌ 3 regressions
✅ 37 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark "devtool-source-map", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 90.2 ms 130.6 ms -30.93%
benchmark "future-defaults", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 14.7 ms 52 ms -71.77%
benchmark "lodash", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 71.8 ms 838.7 ms -91.44%
benchmark "many-modules-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 121.6 ms 96.5 ms +25.96%
benchmark "many-modules-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 127.5 ms 99.3 ms +28.36%

@alexander-akait alexander-akait merged commit e3c48f5 into main Aug 11, 2025
42 of 44 checks passed
@alexander-akait alexander-akait deleted the cjs-to-esm branch August 11, 2025 11:55
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