indexr
indexr copied to clipboard
Export Index files for libraries
Exporting index files for libraries
I am seeing quite a lot of this from libraries:
// Loading partial methods in to limit dependencies
import flatten from 'lodash/flatten';
whilst you can also do
// Loading named export
import {flatten} from 'lodash';
as well as
// Loading default property
import _ from 'lodash';
_.flatten(fooArray);
and also
import * as _ from 'lodash';
_.flatten(fooArray);
However for the reducer or dynamic module routes usecase it would also be great to have access to all the submods as an array:
import { all } from './modules';
all.map(app::use);
Because of CommonJS heritage it is intuitive that ES6 does this automatically however it does not for all the right reasons mainly because the default export is simply a named export called default.
An index should be able to provide all of this automatically.
import method1 from './method1';
import method2 from './method2';
import method3 from './method3';
export { method1 as method1 };
export { method2 as method2 };
export { method3 as method3 };
export {[
method1,
method2,
method3
] as all };
export default {
method1,
method2,
method3,
all,
};
This should probably be the default behaviour for indexr and the main usecase.
Workflow should probably be:
- Drop a bunch of modules in the root folder of an npm package either alongside the index or within module folders.
indexrby default will create an index recursively unless you specify not to within the glob patterns found within.indexrignoreor.indexrrc- Using
.indexrrc.jsto configure the different things indexr can do as it creates the indexes. Perhaps define plugins that change the way indexr works. - You can specify if a particular file is going to be included in the index using comment directives such as
/* indexr-ignore */