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

Rollup mangles class names, breaking IDE code-complete #1378

Closed
cowwoc opened this issue Apr 22, 2017 · 8 comments
Closed

Rollup mangles class names, breaking IDE code-complete #1378

cowwoc opened this issue Apr 22, 2017 · 8 comments

Comments

@cowwoc
Copy link

cowwoc commented Apr 22, 2017

Version 0.41.6
Webstorm 2017.1.1 (IDE)

  1. Every time a module imports a class and re-exports it, rollup mangles the name of the exported class. I am expecting the name to remain unchanged.
  2. Testcase
  3. The main entry point is supposed to return a function createParent() that returns an instance of type Parent.
  4. Unfortunately, rollup mangles the class name of Parent into Parent$1 so when the IDE parses jsdoc it sees that createParent() returns Parent but it cannot find class Parent anywhere. As a result, code-complete does not show Parent.childMethod().
  5. I am not aware of any workaround for this issue. I am forced to use this design to deal with circular dependencies between modules and these cannot be removed.
@kzc
Copy link
Contributor

kzc commented Apr 22, 2017

Workaround - instead of

export default Parent;

use

export { Parent as default };

@cowwoc
Copy link
Author

cowwoc commented Apr 22, 2017

Thanks for the workaround! I really appreciate it.

  1. So is this a confirmed bug?
  2. Out of curiosity, what is the difference between the two syntaxes? Is this a rollup implementation detail, or are they conceptually different according to the ES6 specification?

@kzc
Copy link
Contributor

kzc commented Apr 22, 2017

I don't know if it's a bug, nor am I very well versed on what the ES6 spec says on the matter.

@kzc
Copy link
Contributor

kzc commented Apr 23, 2017

It appears to be ES2015 spec compliant.

Your example is re-exporting a live binding which is why it requires the export { Parent as default } syntax.

See:

@cowwoc
Copy link
Author

cowwoc commented Apr 23, 2017

FYI, I published a related bug report for Babel: babel/babel#5660

@cowwoc
Copy link
Author

cowwoc commented Apr 23, 2017

@kzc Thanks for the references. Rollup's behavior makes a lot more sense now.

@fregante
Copy link

Was this also solved by https://youtrack.jetbrains.com/issue/WEB-26724?

@cowwoc
Copy link
Author

cowwoc commented Jun 21, 2017

@bfred-it yes

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

3 participants