Skip to content

fix: should export external aliased right#12143

Merged
JSerFeng merged 1 commit intomainfrom
esm-reexport-external-alia
Nov 11, 2025
Merged

fix: should export external aliased right#12143
JSerFeng merged 1 commit intomainfrom
esm-reexport-external-alia

Conversation

@JSerFeng
Copy link
Copy Markdown
Contributor

@JSerFeng JSerFeng commented Nov 10, 2025

Summary

Should handle renamed re-export from external module. Use get_target to find the final binding

// index.js
export { f } from './lib'

// lib.js
export {readFile as f} from 'fs'

Should be rendered as

export { readFile as f } from 'fs'

Related links

Checklist

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

Copilot AI review requested due to automatic review settings November 10, 2025 10:23
@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Nov 10, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 10, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 2d2e881
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6912ab0786d5a700078bd046

Copy link
Copy Markdown
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 refactors the handling of re-exported modules in the ESM library plugin by replacing a manual loop-based export resolution with a call to the get_target() helper function, and adds test coverage for externals with aliased exports.

  • Replaces manual export chain traversal with get_target() helper call
  • Uses resolved target's IDs instead of always using original item.ids
  • Adds support for handling inlined exports from invalid targets in concatenated modules

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/rspack-test/esmOutputCases/externals/externals-aliased/rspack.config.js Config for new test case testing aliased external modules
tests/rspack-test/esmOutputCases/externals/externals-aliased/module.js Test module that re-exports from 'fs' with aliases
tests/rspack-test/esmOutputCases/externals/externals-aliased/index.js Test case verifying aliased external exports work correctly
tests/rspack-test/esmOutputCases/externals/externals-aliased/snapshots/esm.snap.txt Expected output snapshot for the aliased externals test
crates/rspack_plugin_esm_library/src/link.rs Refactored export resolution logic to use get_target(), added inlined export handling for invalid targets
crates/rspack_core/src/exports/target.rs Changed find_target_from_export_info visibility from pub(crate) to pub

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 10, 2025

📦 Binary Size-limit

Comparing 2d2e881 to refactor: render runtime globals with runtime template (#12144) by harpsealjs

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 10, 2025

CodSpeed Performance Report

Merging #12143 will not alter performance

Comparing esm-reexport-external-alia (2d2e881) with main (5409f3f)

Summary

✅ 17 untouched

@JSerFeng JSerFeng force-pushed the esm-reexport-external-alia branch 2 times, most recently from a2307c3 to 7f38828 Compare November 11, 2025 02:12
@JSerFeng JSerFeng enabled auto-merge (squash) November 11, 2025 02:24
@JSerFeng JSerFeng force-pushed the esm-reexport-external-alia branch from 7f38828 to eb38c0a Compare November 11, 2025 03:16
@JSerFeng JSerFeng force-pushed the esm-reexport-external-alia branch from eb38c0a to 2d2e881 Compare November 11, 2025 03:18
@JSerFeng JSerFeng merged commit 611e68c into main Nov 11, 2025
44 checks passed
@JSerFeng JSerFeng deleted the esm-reexport-external-alia branch November 11, 2025 08:51
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