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

empty dynamic import breaks later code #3243

Closed
tjenkinson opened this issue Nov 18, 2019 · 3 comments
Closed

empty dynamic import breaks later code #3243

tjenkinson opened this issue Nov 18, 2019 · 3 comments

Comments

@tjenkinson
Copy link
Member

  • Rollup Version: 1.27.2
  • Operating System (or Browser): MacOS
  • Node Version: v11.13.0

How Do We Reproduce?

git clone https://github.com/tjenkinson/rollup-bug-empty-dymanic-import.git
cd rollup-bug-empty-dymanic-import
npm install
npm test

Expected Behavior

A non empty bundle is generated that contains the console.log

Actual Behavior

An empty bundle is created. The empty dynamic import seems to cause the issue. If you comment out the console.log in 'a.js', it works.

@lukastaegert
Copy link
Member

I understand, but the warning is technically correct, though the wording is wrong. It should read "created an empty chunk". If you do not throw for warnings, you will see that the entry chunk with the console.log is created. It is the dynamic chunk that is empty, which causes the warning. I think this should definitely be improved, if only to change the warning message in these cases. I guess it would also be helpful to include the name of the empty chunk in the warning message to make clear which chunk we are referring to.

@lukastaegert
Copy link
Member

As for the warning itself, I think it still makes sense. Empty chunks will only be created in two cases: The target of a dynamic import does not have side-effects, or an entry chunk does not have side-effects. Both are under the user's control and are probably unintended.

@tjenkinson
Copy link
Member Author

Ah 🤦‍♂

Makes sense. Sorry for the noise.

It should read "created an empty chunk". If you do not throw for warnings, you will see that the entry chunk with the console.log is created. It is the dynamic chunk that is empty, which causes the warning. I think this should definitely be improved, if only to change the warning message in these cases. I guess it would also be helpful to include the name of the empty chunk in the warning message to make clear which chunk we are referring to.

I opened a PR: #3244

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

No branches or pull requests

2 participants