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

test: "export *" before named export #2893

Merged
merged 3 commits into from Jun 16, 2019
Merged

Conversation

aleclarson
Copy link
Contributor

@aleclarson aleclarson commented Jun 4, 2019

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • test

Description

Putting an export * declaration before named exports results in the export * stealing all of the named exports. Run the test and see it fail, because Rollup is broken.

The _actual/es.js module contains the following:

export * from 'path';
export { isRelative } from 'path';

@aleclarson
Copy link
Contributor Author

The ExternalModule class seems to lie about the names it exports when it's an export * declaration. The workaround is to put external re-exports after internal re-exports.

aleclarson added a commit to pmndrs/react-spring that referenced this pull request Jun 4, 2019
aleclarson added a commit to pmndrs/react-spring that referenced this pull request Jun 7, 2019
@lukastaegert
Copy link
Member

lukastaegert commented Jun 15, 2019

Yes, this looks definitely fishy, I will look into it.

Just one thing to note, though: The actually correct behaviour for conflicting export * from declarations is to not export the conflicting value at all and throw an error when it is accessed . Just try this out in a browser of your choice. So if your logic relies on this, you should probably change it. Nevertheless I do not expect Rollup to support the standard with regard to this detail any time soon.

Nevertheless the logic is also faulty when there would be no conflict, so definitely something to fix.

@lukastaegert
Copy link
Member

I changed the logic so that logic star exports receive higher priority than external star exports. Nevertheless the logic is still quite faulty in several edge-case situations which would need quite a bit more logic:

  • When there is both a local and an external export of the same name, accessing should throw an error
  • When there are several external star exports, all of them should be checked instead of settling for the first one.

@lukastaegert lukastaegert merged commit f4b19ab into rollup:master Jun 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants