镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Fix invalid output for exported destructuring declarations with defaults - #6648

Merged
lukastaegert merged 6 commits into
rollup:masterfrom
trleo:fix/rollup-6646-destructuring-default-export
Nov 8, 2026
Merged

lukastaegert merged 6 commits into
rollup:masterfrom
trleo:fix/rollup-6646-destructuring-default-export

Conversation

@trleo

@trleo trleo commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Exported destructuring declarations could produce invalid output in non-ES formats. The bug is broader than the reported default case: any exported variable in a destructuring pattern was rendered invalidly because Identifier.render used the base qualified name in binding positions.

The fix renders binding identifiers with the plain name and uses a live getter for reassigned pattern variables, so exports stay live.

Fixes #6646

Trleo

@vercel

vercel Bot commented Nov 8, 2026

Copy link
Copy Markdown

@trleo is attempting to deploy a commit to the rollup-js Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install trleo/rollup#fix/rollup-6646-destructuring-default-export

Notice: To build the native dependencies, you need Rustup installed; the required nightly toolchain is then picked up automatically from rust-toolchain.toml.

@lukastaegert lukastaegert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your fix. I took the liberty to slightly simplify it and also reduce the huge amount of comments and extend test coverage.

@vercel

vercel Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rollup Ready Ready Preview Nov 8, 2026 7:13am UTC

Request Review

@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.33%. Comparing base (ca871b2) to head (fda5487).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6648   +/-   ##
=======================================
  Coverage   98.33%   98.33%           
=======================================
  Files         380      380           
  Lines       14070    14081   +11     
  Branches     3007     3011    +4     
=======================================
+ Hits        13836    13847   +11     
  Misses        192      192           
  Partials       42       42           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Performance report

  • BUILD: 5887ms, 855 MB
    • initialize: 0ms, 24.1 MB
    • generate module graph: 2033ms, 631 MB
      • generate ast: 1072ms, 619 MB
    • sort and bind modules: 402ms, 692 MB
    • mark included statements: 3445ms, 855 MB
      • treeshaking pass 1: 1882ms, 830 MB (-2%)
      • treeshaking pass 2: 436ms, 845 MB
      • treeshaking pass 3: 381ms, 830 MB
      • treeshaking pass 4: 370ms, 830 MB
      • treeshaking pass 5: 369ms, 855 MB
  • GENERATE: 572ms, 887 MB
    • initialize render: 0ms, 855 MB
    • generate chunks: 40ms, 834 MB
      • optimize chunks: 0ms, 837 MB (-2%)
    • render chunks: 511ms, 860 MB
    • transform chunks: 20ms, 887 MB
    • generate bundle: 0ms, 887 MB

The chunk-level export resolution already keeps variables declared in destructuring patterns on plain local names, so the dedicated binding-name API and the render branch were dead code. Remove them, extend the tests to cover update/for-of and reassigned rest bindings, and pin the CJS export shape with a form snapshot.
@lukastaegert
lukastaegert force-pushed the fix/rollup-6646-destructuring-default-export branch from 4877713 to 4308865 Compare November 8, 2026 07:10
@lukastaegert
lukastaegert added this pull request to the merge queue Nov 8, 2026
Merged via the queue into rollup:master with commit 6be8a51 Nov 8, 2026
50 checks passed
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

This PR has been released as part of rollup@4.68.1. You can test it via npm install rollup.

This branch was successfully deployed

1 active deployment
Preview — fda5487f Deployed Nov 8, 2026 by vercel[bot]
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.

Exported destructuring declaration with a default value produces invalid code in cjs/amd/iife/umd output

2 participants