-
-
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
[WIP] move components to directories #3212
Conversation
Yeah this is going to be a pain 😆 Back in December, @alitaheri reminded me and @oliviertassinari about this issue (in that call you helped orchestrate actually 😆). Apparently our only option is to do the migration all at once. We could create a codemod like at https://github.com/reactjs/react-codemod to help assist developers with the migration in their own codebases. Like you said, components with composite names like |
Or! when we publish, we flatted the requires like:
import Avatar from 'material-ui/Avatar'; while keeping a
import Avatar from 'material-ui/lib/avatar'; lib/avatar will be like: import Avatar from '../Avatar';
export default Avatar; You see this pattern in many places. npm for example has branches for these kinds of thing! This is gonna ease the pain dramatically 😁 |
I really like that import path 😆 |
Same. 😄 How is that achieved in practice? Do we need to maintain a build script with source and destination paths? What does the source tree look like in the ideal scenario? At the moment we have some as |
@mbrookes Yeah, we will have to maintain a map too. like one for the docs site. but since components aren't added that often it's not a big overhead in my opinion. |
Closing in favour of discussion here #2679. Please copy over any relevant comments not reflected there. |
I've been experimenting with putting the component files that are currently in the top level
src
directory into their own subdirectories, and have run into a an interesting problem.When (ignoring case) the directory name is the same as the legacy filename, that is to say, for files with a single word name (i.e. those that don't have a hyphen in them), the import fails if you specify the directory to import from:
instead, you have to specify the full path:
or:
Even then it complains about duplicate paths - but at least it loads.
Unless there's a clever workaround (or I'm misunderstanding the problem), this is going to be a bit of a hitch for standardising the directory layout and simplifying imports, while maintaining backwards compatibility with the current file-name (with a deprecation warning inserted).