Skip to content

Conversation

@JSerFeng
Copy link
Contributor

Summary

When export interop default, should invoke the default access runtime.

Keep empty external import

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings December 23, 2025 06:11
@netlify
Copy link

netlify bot commented Dec 23, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit d369b3a
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/694a32909c5bef0008a71323

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: bug fix release: bug related release(mr only) labels Dec 23, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes interop handling for default exports from CommonJS modules and preserves empty import statements for externals. The changes ensure that when exporting a default from a CJS module, the appropriate runtime helper is invoked, and side-effect imports (like import 'fs') are not removed during optimization.

  • Adds logic to call default_exported() runtime when the symbol being exported is the default access symbol for interop
  • Preserves empty import statements (side-effect imports) for external modules during the optimization pass

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/rspack_plugin_esm_library/src/link.rs Implements the core fix: adds condition to invoke default_exported() for default access symbols (lines 1067-1070) and skips removal of empty imports for externals (lines 1597-1600)
tests/rspack-test/esmOutputCases/interop/export-cjs-default/index.js Test case for default export interop without type:module
tests/rspack-test/esmOutputCases/interop/export-cjs-default/foo.cjs Test fixture that exports a primitive value (42) via module.exports
tests/rspack-test/esmOutputCases/interop/export-cjs-default/__snapshots__/esm.snap.txt Expected output showing __webpack_require__.n() and function invocation for interop
tests/rspack-test/esmOutputCases/interop/export-cjs-default-type-module/package.json Package config specifying type:module
tests/rspack-test/esmOutputCases/interop/export-cjs-default-type-module/index.js Test case for default export interop with type:module
tests/rspack-test/esmOutputCases/interop/export-cjs-default-type-module/foo.cjs Test fixture (same as non-type-module version)
tests/rspack-test/esmOutputCases/interop/export-cjs-default-type-module/__snapshots__/esm.snap.txt Expected output without interop runtime (direct export)
tests/rspack-test/esmOutputCases/externals/empty-import/rspack.config.js Config marking 'fs' as external with module type
tests/rspack-test/esmOutputCases/externals/empty-import/index.js Test case with side-effect import of external
tests/rspack-test/esmOutputCases/externals/empty-import/__snapshots__/esm.snap.txt Expected output preserving the empty import statement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 823.4 KB 0
react-5k 2.7 MB 0
rome 984.3 KB 0
ui-components 2.1 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing d369b3a to feat: add rspack_tools to compare .cache from different os (#12499) by jinrui

❌ Size increased by 384bytes from 47.87MB to 47.87MB (⬆️0.00%)

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 23, 2025

CodSpeed Performance Report

Merging #12530 will not alter performance

Comparing fix/esm (d369b3a) with main (4891406)

Summary

✅ 16 untouched
⏩ 1 skipped1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@JSerFeng JSerFeng enabled auto-merge (squash) December 23, 2025 06:40
@JSerFeng JSerFeng merged commit efed455 into main Dec 23, 2025
62 checks passed
@JSerFeng JSerFeng deleted the fix/esm branch December 23, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants