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

Variable name conflicts when using inlineDynamicImports #3245

Closed
philipwalton opened this issue Nov 19, 2019 · 6 comments · Fixed by #3256
Closed

Variable name conflicts when using inlineDynamicImports #3245

philipwalton opened this issue Nov 19, 2019 · 6 comments · Fixed by #3256

Comments

@philipwalton
Copy link

  • Rollup Version: 1.27.2
  • Operating System (or Browser): Chrome 78
  • Node Version: 10

I'm using Rollup and the inlineDynamicImports option to bundle my code, and I've run into the following error:

When Rollup processes the following code:

const initLog = async () => {
  const log = await import('./log');
  log.init();
};

It turns it into this:

const initLog = async () => {
  const log = await Promise.resolve().then(function () { return log; });
  log.init();
};

But notice how in the second line, the function is returning the variable log from the outer scope. However, since the function also defines a variable named log in the inner scope, instead of returning the imported module, undefined gets returned and there's a runtime error.

Note: I'm happy to put together a repro if this isn't enough to go off of.

@lukastaegert
Copy link
Member

A repro would be nice as I am really confused as to why there is no definition of log in the inner module. Or is it a global variable? In that case, yes, the outer log should have been deconflicted.

@lukastaegert
Copy link
Member

Ah sorry, log is of course the namespace. Yes, a repro would help, when I tried it locally, it was always properly deconflicted.

@philipwalton
Copy link
Author

philipwalton commented Nov 22, 2019

Repro: https://github.com/philipwalton/rollup-3245-repro

Let me know if anything here doesn't make sense.

@lukastaegert
Copy link
Member

Ah, that is helpful, thanks a lot! I'm starting to get an idea of what is going on here.

@lukastaegert
Copy link
Member

Fix at #3256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants