I’m working with a project that makes many imports from a particular library, but importing from the dist
rather than being more generic.
ie.
import {Header} from '@some-lib/.../.../dist/Header';
import {Footer} from '@some-lib/.../.../dist/Footer';
import {Column} from '@some-lib/.../.../dist/Column';
import {Button} from '@some-lib/.../.../dist/Button';
import {Radio} from '@some-lib/.../.../dist/Radio';
rather than
import {Header, Footer, Column, Button, Radio} from '@some-lib';
While I understand that this is done for greater efficiency and more specificity in what we import into each component, it really clogs up the file with a million imports at the top and doesn’t look all that attractive.
Would it be possible to perhaps have a separate file in which we can import all of the lib’s components from their respective dist
locations and re-export them such that we can achieve a single line import, but with the benefits of performance of the multi-line?
For example:
// libImportExport.js
import {Header} from '@some-lib/.../.../dist/Header';
import {Footer} from '@some-lib/.../.../dist/Footer';
import {Column} from '@some-lib/.../.../dist/Column';
import {Button} from '@some-lib/.../.../dist/Button';
import {Radio} from '@some-lib/.../.../dist/Radio';
export {Header, Footer, Column, Button, Radio};
// MyComponent.jsx
import {Header, Footer, Column, Button, Radio} from './libImportExport';
...
Or is this a pointless effort to make?