-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Core] Improve our import path #2679
Comments
@oliviertassinari How smart and reliable can it really be? How about nested imports? things like svg-icons? how can we address that? I mean we cant put all the icons in the main index file, right? can it actually shake those branches deep down the import tree? I couldn't find info whether it can or not. But there are other issues. Maybe people don't want to enable it for some reasons. I think it's best to support both rather than enforce one over the other. |
@oliviertassinari @alitaheri I agree with both of you 😄 . One of my first challenges with That being said, being dependent on the reliability of webpack and or browserify is risky and it might also be worthwhile to continue supporting the "full" path for a while. I'll throw another idea out there that may sound crazy. Material-ui is a big project, and maybe the components deserve their own packages. One possible approach is making material-ui a monorepo. We could put each component in their own directory (like we were planning on doing anyway) and give it its own import TextField from 'material-ui-text-field'
/* In addition a top level 'material-ui' package could have all components as a dependency and re-export */
import {TextField} from 'material-ui' Haven't thought through it much. It might be a really bad idea but I thought it's worth mentioning since the React project even follows the monorepo approach. |
@newoga Interesting idea. However, the dependency management will be really hard. unlike a library like lodash, this one is very tightly coupled. we'll need to make a huge number of packages (some internal) to include all. besides the svg-icons will prove difficult, they should all be in one package and yet support static imports so only the ones needed get through. Supporting both styles: import TextField from 'material-ui/TextField'; and import {TextField} from 'material-ui'; is easy. but svg-icons will be harder to tackle. but having separate packages for each of them. will be really hard >.> npm will find us and kill us all :D :D |
@alitaheri Haha, indeed, they might. I don't want to die. 😆 |
Me neither xD xD |
Also related to #1793. |
@alitaheri @newoga this is on the |
We still haven't discussed and decided on the best approach to implementing this. I think we've settled on putting all the components in directories (along with its internal components and tests, possibly docs). I think we've also settled on the following path: To do this, we're going to have to change our build process to publish the package from within the conceptual I'm open to better ideas but that's my current thought! |
It's a shame
Clever. How will backwards compatibility work for people importing from src? Or is that an inevitable breaking change? |
Yeah it'd be nice if it was supported 😞. I've seen some projects that have a release script that simply copies the
Yeah, that's kind of what I had in mind. I consider importing from |
Open a PR on npm? 😄 |
Haha, possibly. Though, I've always got the impression that they try to keep their toolset really simple and allow more sophisticated tooling be developed in user space. Though as far as tooling goes, I think the |
I'll open an issue and see what they say. |
Sounds good. 😄 |
Just another note on this, I know we're already really busy/slammed but I think it would be nice/good form to create a codemod to help users migrate their projects to the new paths. |
Yes indeed, the sooner we do it, the best it will be for everybody.
I completely agree and I volunteer to work on this codemod once we have moved the files. |
I started to write the issue for this the other day, and realised this in't so much an issue for npm as for webpack, browserify, node etc to interpret I started poking through the code of the various tools to see if there's a shared lib used, but didn't have much luck finding anything. So whilst It would still be nice to have - even if all parties agreed, it won't come soon enough for 0.15.0, and in the unlikely event it did, would force a dependancy on the latest versions of said tools. tl;dr, we have to do this the hard way. |
@callemall/material-ui Did we figure out where we are publishing from to make this happen? Last I recall, we discussed publishing from the |
@nathanmarks Yeah, let's get this sorted. |
@oliviertassinari I already added filter out the tests during build when I moved them 👍 (so they don't end up in the lib folder). For the sake of simplicity then, why don't we just have the build process create a minimal |
Improves the import path by creating a package.json inside the build directory so the library can be published with a flattened root folder. The lib root package.json is transformed into a minimal version and the README, CHANGELOG and LICENSE are copied over. Resolve: mui#2679
Improves the import path by creating a package.json inside the build directory so the library can be published with a flattened root folder. The lib root package.json is transformed into a minimal version and the README, CHANGELOG and LICENSE are copied over. Resolves: mui#2679
The tree shaking feature is on his way with webpack 2 (http://www.2ality.com/2015/12/webpack-tree-shaking.html) and will probably soon be implemented by browserify.
I think that, at some point, we will have to deprecate the usage of import:
And instead, advice people to use:
The text was updated successfully, but these errors were encountered: