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

module naming convention is not intuitive #1793

Closed
zivl opened this issue Oct 3, 2015 · 7 comments
Closed

module naming convention is not intuitive #1793

zivl opened this issue Oct 3, 2015 · 7 comments

Comments

@zivl
Copy link

zivl commented Oct 3, 2015

when using ES6 import or NPM require for loading modules, naming convention is not intuitive as you expect to.

For example:
Instead of:

import AppBar from 'material-ui/lib/app-bar';
import LeftNav from 'material-ui/lib/left-nav';

I would rather import it as follows:

import AppBar from 'material-ui/lib/AppBar';
import LeftNav from 'material-ui/lib/LeftNav';

See the difference? the modules I'm importing has the same name of the component's name as in the documentation site (http://material-ui.com/#/components/left-nav).

I know it might cause a little backward compatibility issue but this can be workaround easily by generating aliases or even keep both of the files for a few versions, with the appropriate deprecations messages (in code and in console)

@nibon
Copy link

nibon commented Oct 4, 2015

I saw in the documentation that this is the preferred way of importing material-ui-libs. However I import the modules, using src/index.js, in this format which sort of answers your question in this issue.

import { AppBar, Avatar, FontIcon } from 'material-ui'

Are there any reason why I should not import using this method?

@zivl
Copy link
Author

zivl commented Oct 4, 2015

in this way of importing modules, you're importing the entire library. If I'm not mistaken, when packaging using jspm or webpack (or whatever packaging tool out there...) - you also package unused modules, which may cause your bundle.js to become bigger than needed, especially when using fewer modules of a specific library.

Hence, when importing file-by-file, the packaging mechanism takes only modules in use.

@nibon
Copy link

nibon commented Oct 4, 2015

Yeah, just created a small test project (gulp/browserify) to check myself and you are correct. The size differed a couple of hundred kilobytes when only importing RaisedButton. In that case I support the proposition in this issue.

@shaurya947
Copy link
Contributor

@zivl there is convention in the current naming system, so perhaps it becomes intuitive after a couple uses. However, I don't see why we should not do the naming as you suggested.

Any thoughts @hai-cea?

@hai-cea
Copy link
Member

hai-cea commented Oct 5, 2015

@zivl Thanks for opening this issue. I think this change can be made in v0.13.0 which will happen in 3 weeks or so.

@oliviertassinari
Copy link
Member

I like this idea too 👍

@nathanmarks
Copy link
Member

@oliviertassinari can this be closed in favour of #2679 ?

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

No branches or pull requests

8 participants