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

Add Option to Keep Named Imports #277

Merged
merged 1 commit into from
Oct 17, 2018
Merged

Add Option to Keep Named Imports #277

merged 1 commit into from
Oct 17, 2018

Conversation

haffla
Copy link
Contributor

@haffla haffla commented Oct 15, 2018

Hey guys,

I've added a plugin option that lets you keep the named import.

import { Bar } from 'foo';

is then equivalent to

import { Bar } from 'foo/lib/bar';

instead of

import Bar from 'foo/lib/bar';

for example. I think there is no way around this if you're working with a project that does not have default exports.

P.S. I also edited the README. The fields of the options object (####) should be under the Options heading (###).

@afc163 afc163 requested a review from sorrycc October 16, 2018 05:33
@sorrycc
Copy link
Member

sorrycc commented Oct 16, 2018

I think foo/lib/bar should export default, export Bar looks a bit strange.

@haffla
Copy link
Contributor Author

haffla commented Oct 16, 2018

export Bar looks a bit strange

What do you mean by that? It's not about the way it looks. It's about being able to use babel-plugin-import in projects that do not use default exports. RxJS for example, is a popular example.

I think foo/lib/bar should export default

But it doesn't, and the only way to import it is by using a named import.

This is a totally optional setting.

Also the TypeScript version of babel-plugin-import supports this. I actually stole the name transformToDefaultImport from there.

@sorrycc sorrycc merged commit 28a5b9f into umijs:master Oct 17, 2018
@sorrycc
Copy link
Member

sorrycc commented Oct 17, 2018

  • babel-plugin-import@1.10.0

zhanguangao pushed a commit to zhanguangao/babel-plugin-module-federation-import that referenced this pull request Sep 1, 2023
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

Successfully merging this pull request may close these issues.

2 participants