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

[ES6] Use import over require #2333

Merged
merged 1 commit into from
Dec 1, 2015
Merged

[ES6] Use import over require #2333

merged 1 commit into from
Dec 1, 2015

Conversation

oliviertassinari
Copy link
Member

Following #2253, this PR update the src folder.

oliviertassinari added a commit that referenced this pull request Dec 1, 2015
@oliviertassinari oliviertassinari merged commit ae6147c into mui:master Dec 1, 2015
@oliviertassinari oliviertassinari deleted the ES6-modules branch December 1, 2015 22:56
@balthazar
Copy link
Contributor

@oliviertassinari What do you think about all the indexes?

@oliviertassinari
Copy link
Member Author

What do you think about all the indexes?

Could you be more specific? I don't follow.

@balthazar
Copy link
Contributor

Can't we use es6 export style for this without having to require things?

@oliviertassinari
Copy link
Member Author

Oh, looks like I have forgotten this file.

@balthazar
Copy link
Contributor

Not just this one, all the indexes of each folder follow this pattern

@oliviertassinari
Copy link
Member Author

@apercu You are right, thanks for noticing the we need to update the index.
We can use https://github.com/reactjs/react-docgen/blob/master/src/main.js as inspiration.
Do you want to give it a try?

I'm wondering if adopting the ES6 module definition for the index would make webpack only import the desired file with the following structure. cc @subjectix

import {DatePicker} from 'material-ui';`

@alitaheri
Copy link
Member

@oliviertassinari I don't know if webpack can prune the tree or under what conditions it can. But it would be great if it was possible. it will need research.

@balthazar
Copy link
Contributor

Yeah I was wondering about that since my material-ui is taking 40% of my project bundle loading all the svg icons while I'm only using a couple. Will do a bit of tests and can submit a PR

@oliviertassinari
Copy link
Member Author

I have opened an issue to continue the conversation #2558.

Yeah I was wondering about that since my material-ui is taking 40% of my project

We advise people to directly require the needed component, but that would be better if we can use the index.js (for code clarify and modifying the file name without introducing breaking changes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants