Skip to content
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

Do not add tree-shaken variables to namespaces when inlining dynamic imports #5047

Merged
merged 1 commit into from Jun 26, 2023

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

This resolves an issue when

  • using inlineDynamicImports and
  • dynamically importing a module
  • where the module reexports a variable that is not used
  • and the import() promise does not use the variable

It is basically a regression introduced in #4952 where we implemented tree-shaking for dynamic imports. There were two places where tree-shaken variables were not properly handled, which is fixed here.

@vercel
Copy link

vercel bot commented Jun 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
rollup ✅ Ready (Inspect) Visit Preview Jun 25, 2023 6:23pm

@github-actions
Copy link

github-actions bot commented Jun 25, 2023

Thank you for your contribution! ❤️

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

npm install rollup/rollup#gh-5043-inline-dynamic-import-error

or load it into the REPL:
https://rollup-iwvoq1d4i-rollup-js.vercel.app/repl/?pr=5047

@codecov
Copy link

codecov bot commented Jun 25, 2023

Codecov Report

Merging #5047 (03291a4) into master (7ed978f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #5047   +/-   ##
=======================================
  Coverage   98.96%   98.96%           
=======================================
  Files         225      225           
  Lines        8301     8302    +1     
  Branches     2279     2280    +1     
=======================================
+ Hits         8215     8216    +1     
  Misses         31       31           
  Partials       55       55           
Impacted Files Coverage Δ
src/Chunk.ts 99.65% <100.00%> (+<0.01%) ⬆️
src/Module.ts 100.00% <100.00%> (ø)

@lukastaegert lukastaegert merged commit 83d21a4 into master Jun 26, 2023
12 checks passed
@lukastaegert lukastaegert deleted the gh-5043-inline-dynamic-import-error branch June 26, 2023 20:05
@rollup-bot
Copy link
Collaborator

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

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.

TypeError: Cannot read properties of undefined (reading 'exports')
2 participants