Giter Site home page Giter Site logo

indexr's People

Contributors

ryardley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

manusevenval

indexr's Issues

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:

  1. Drop a bunch of modules in the root folder of an npm package either alongside the index or within module folders.
  2. indexr by default will create an index recursively unless you specify not to within the glob patterns found within .indexrignore or .indexrrc
  3. Using .indexrrc.js to configure the different things indexr can do as it creates the indexes. Perhaps define plugins that change the way indexr works.
  4. You can specify if a particular file is going to be included in the index using comment directives such as /* indexr-ignore */

Use custom named collections from header comments

Providing both named exports and custom named collections

Indexr should provide both named exports and custom named collections. Modules are included by default within an all collection as well as named exports. Modules can opt in to of a custom collection using /* indexr-collection reducers */

Automatic docs creation

It is annoying to have to sync docs before publishing. Look into ways to automatically create the docs as it should be possible to create an API markdown from the cli help output.

Crashes when running

Hi,

I just tried global installation and it choked

$ npm install indexr -g
/Users/gleb/.nvm/versions/node/v6.3.1/bin/indexr -> /Users/gleb/.nvm/versions/node/v6.3.1/lib/node_modules/indexr/dist/bin.js
/Users/gleb/.nvm/versions/node/v6.3.1/lib
└─┬ [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └── [email protected] 
  │ ├── [email protected] 
  │ ├─┬ [email protected] 
  │ │ └─┬ [email protected] 
  │ │   ├── [email protected] 
  │ │   └── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  └── [email protected] 

~/git/utils on master*
$ indexr src
module.js:442
    throw err;
    ^

Error: Cannot find module 'chokidar'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/gleb/.nvm/versions/node/v6.3.1/lib/node_modules/indexr/dist/modules/watch/index.js:8:17)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)

Header comments signal write override

Default outputFilename is index.js whilst headers are checked to know whether or not to overwrite an index file.

The create-index package uses a specific string that acts as a command to work out if it is allowed to overwrite a file or now. I think this should be built in perhaps following the model laid down by eslint.

/* indexr-allow-overwrite */
//  This file is autogenerated by indexr.
//  Do not edit this file.
//  Check this file into source control.
...

Add --named-exports flag to create named exports for module indexes

The following comes from reddit:

Reddit user theillustratedlife says:


Would be much more interesting if it did named exports. I have literally never wanted to export an array of modules as an index. Two problems:
How am I supposed to know which modules are at which index?

const [a, c] = require('./');

What if module b gets added to a folder that contains a and c? If I rerun indexr, I'll have code that should point at c (position 1 in the old array) and now points at b (position 1 in the new array). This is very bad.
The index I really want lets me do this:

import {
  a,
  c,
} from './';

Though even then, I'd want to test my build process to verify that it properly tree-shakes imported but unused modules. And since imports can have side-effects, I'm not sure that could always work.

Export named object

Hi,

Nice project!

I have however a question; I usually name my export like following:

// test.js
export function foo() {
    return 'foo';
}

export function foo() {
    return 'bar';
}

But when I use indexr, it will create the following content (indexr -m "." --submodules "test.js" . --named-exports):

export { default as testJs } from './test.js';

Which will not work :/
If indexr, however, created the following file:

export * from './test.js';

everything would work perfectly. Is it possible to add an extra flag to just export everything (star export as shown above)?

Prevent Indexr from overwriting non indexr files

When you run indexr it will will write files according to the input you have given it. It should really check to see if the file is an autogenerated file or not before writing and if not it should generate the file.

Different formatting options for the exported module name

Hi there,

It would be useful if you could specify a different formatter than camelCase for the exported module name (export { default as moduleName } from '/path/to/module.name').

I am working on a React app, and want my exports in PascalCase to make them look consistent with other components.

Ideally this could be 'configurable' but it's kind of hard to have a javascript function as a config value. I am thinking a mvp could be a flag for camelCase vs PascalCase?

The camelCase repo lists this in their related list for a PascalCase formatter.

v2.0.0 ideas

Indexr v2.0.0 spec

I would like this comment to act as a spec for version 2.

If you have any comments or suggestions please add them below and I will incorporate them into this comment.

[discussion] change default output filename

So if any one is out there and has an opinion I am not comfortable with the default index file that Indexr exports. Currently it is index.r.js. If anyone has preferences or thinks things should be done differently perhaps you can chime in here.

Test that the output works and is importable

This probably needs to be done outside of mocha as we need to import the code we have created. Not sure exactly how best to make this happen but should be able to kludge something together.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.