Say I have a library structure as below:
my-library
|-- lib
| |
| |-- foo
| | |--index.js
| |
| |-- bar
| |--index.js
|
|---src
| |-- foo
| |-- button.js
| |-- index.js
| |-- bar
| |-- button.js
| |-- index.js
|-- package.json
I want to import these packages like this:
import { button } from 'my-library/foo'
import { button } from 'my-library/bar'
Is this possible?
The only way I have got it working is to import it like:
import { Button } from 'my-library/lib/foo'
I'm using Babel if that helps. Should I just transpile to the root directory and not use a lib
dir?
I'm was looking at packages that do this such as lodash and React Native Vector Icons where they specify what they are importing.
Similar question here: Root directory in package.json