Support for dynamically exported components
See original GitHub issueUsing atomic design and @diegohaz arc boilerplate, you are able to reference components that are located anywhere in the components subdirectories i.e. atoms, molecules, organisms etc. For reference here is the link: https://github.com/diegohaz/arc/wiki/Atomic-Design#do-not-worry Per the link: This is possible because all components are dynamically exported on src-example/components/index.js and imported in a way that Atomic Design structure doesn’t matter:
import { Input, Label, Field, HomePage, PageTemplate } from 'components'
Has anyone been able to get the same functionality with create-react-app?
I have managed to get rid of the relative paths using .env and specifying NODE_PATH=src but I still have to explicitly include the entire subdirectory structure for the component.
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
I don’t recommend doing this via
index.js
. It means code splitting won’t work because everything ends up in the same bundle.At Facebook, we use a system called “haste” that lets you import any file by its unique name without relative paths. I’m open to supporting it as an opt-in in CRA projects, but somebody would need to write a Webpack plugin for it. Jest already supports it.
Going to close this as overlapping too much with https://github.com/facebookincubator/create-react-app/issues/1333.