rollup / rollup/rollup

`/*#__PURE__*/` annotation ineffective for tree-shaking top-level `await import().then(...)` expressions

Open
#5,948 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

t¹ 🐞 bug t⁸ ⋅ triage
Dominant language
JavaScript
Stars
26.3k
Forks
1.8k
Avg merge
2d 11h
Merged PRs (30d)
20

Description

Rollup Version

4.40.2

Operating System (or Browser)
Node Version (if applicable)

No response

Link To Reproduction

https://rollupjs.org/repl/?version=4.40.2&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMmltcG9ydCUyMCU3QmElN0QlMjBmcm9tJTIwJy4lMkZtaXguanMnJTVDbmNvbnNvbGUubG9nKGEpJTIyJTJDJTIyaXNFbnRyeSUyMiUzQXRydWUlMkMlMjJuYW1lJTIyJTNBJTIybWFpbi5qcyUyMiU3RCUyQyU3QiUyMmNvZGUlMjIlM0ElMjJleHBvcnQlMjBjb25zdCUyMG5hdGl2ZV9hJTIwJTNEJTIwMSU1Q25leHBvcnQlMjBjb25zdCUyMHNoaW1fYSUyMCUzRCUyMDIlNUNuZXhwb3J0JTIwY29uc3QlMjBuYXRpdmVfYiUyMCUzRCUyMDElNUNuZXhwb3J0JTIwY29uc3QlMjBzaGltX2IlMjAlM0QlMjAyJTVDbmV4cG9ydCUyMGNvbnN0JTIwb3RoZXIlMjAlM0QlMjAzJTIyJTJDJTIyaXNFbnRyeSUyMiUzQWZhbHNlJTJDJTIybmFtZSUyMiUzQSUyMmFsbC5qcyUyMiU3RCUyQyU3QiUyMmNvZGUlMjIlM0ElMjJleHBvcnQlMjBjb25zdCUyMGElMjAlM0QlMjAlMkYqJTIzX19QVVJFX18qJTJGYXdhaXQlMjBpbXBvcnQoJy4lMkZhbGwuanMnKS50aGVuKCglN0JuYXRpdmVfYSUyQ3NoaW1fYSU3RCklM0QlM0VuYXRpdmVfYSUzRm5hdGl2ZV9hJTNBc2hpbV9hKSU1Q25leHBvcnQlMjBjb25zdCUyMGIlMjAlM0QlMjAlMkYqJTIzX19QVVJFX18qJTJGYXdhaXQlMjBpbXBvcnQoJy4lMkZhbGwuanMnKS50aGVuKCglN0JuYXRpdmVfYiUyQ3NoaW1fYiU3RCklM0QlM0VuYXRpdmVfYiUzRm5hdGl2ZV9iJTNBc2hpbV9iKSUyMiUyQyUyMmlzRW50cnklMjIlM0FmYWxzZSUyQyUyMm5hbWUlMjIlM0ElMjJtaXguanMlMjIlN0QlNUQlMkMlMjJvcHRpb25zJTIyJTNBJTdCJTIyb3V0cHV0JTIyJTNBJTdCJTIyZm9ybWF0JTIyJTNBJTIyZXMlMjIlN0QlN0QlN0Q=

Expected Behaviour

/*#__PURE__*/await import is pure function call

const a = await import('./all-DnWgraJt.js').then(({native_a,shim_a})=>native_a?native_a:shim_a);
// await import('./all-DnWgraJt.js').then(({native_b,shim_b})=>native_b?native_b:shim_b);

console.log(a);
Actual Behaviour
const a = await import('./all-DnWgraJt.js').then(({native_a,shim_a})=>native_a?native_a:shim_a);
await import('./all-DnWgraJt.js').then(({native_b,shim_b})=>native_b?native_b:shim_b); // should be removed

console.log(a);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Rollup 4.40.2 reproduction and compare the generated output with the expected tree-shaking behavior for top-level await import().then(...) expressions. Trace the tree-shaking handling for the two annotated expressions, then verify that the unused second expression is removed while the used first expression remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.