scalable-react / scalable-react-typescript-boilerplate

:star: Scalable micro-framework featuring React and TypeScript
https://scalable-react-ts-boilerplate.herokuapp.com/
MIT License
173 stars 26 forks source link

Generating import/export file? #86

Closed koenverburg closed 7 years ago

koenverburg commented 7 years ago

Hey Guys, First of all thanks for greating this project, It helpt me a lot with getting my head around typescript and react and making it scalable.

In the components and containers folders there is an index.tsx in there every component/container is imported and exported but I see comment's like /* GENERATOR-IMPORT */ so I thought maybe a script is generating these files is this correct or do I need to import/export every new component manually?

This is the index.tsx from your current project. I personaly forked it. which was before the move to lerna.

// component/index.tsx
/* GENERATOR-IMPORT */
import Html from './Html';

export {
  /* GENERATOR-EXPORT */
  Html,
};
RyanCCollins commented 7 years ago

Hey @CreativeKoen!

Yes, the comments are there for the sake of the code generators. We use these to make it easy to scaffold out features / components.

Keep in mind at the moment, things are still being worked on so don't be surprised if you find any gremlins when running the generators. If you do and feel inclined to fix them, we are definitely accepting PRs.

When a component or feature is generated by the generator, it exports it from the root index.ts file so that it's available from import using one of the aliases. For example, say you generate a component called Post, you should be able to import it in another component like import { Post } from 'components';` There are examples of this in use in the docs package, if you need a reference.

Please let me know if you have any other questions. Good luck!