index.ts barrel files in the codebase?
See original GitHub issueHaving single index.ts
barrel files in each directory might help others to understand the codebase a bit better, and remove a lot of extra files that are currently one-off barrels (for instance compiler/class.ts
, compiler/common.ts
, compiler/decorator.ts
, etc.)
It would also be a bit more idiomatic in that you could import directly from a directory, such as:
import { CallExpression } from './compiler';
and:
export * from './compiler';
Thoughts?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Automatic barrels (index.ts files) for your entire code base
im considering a few ways to handle this. one is have a “ignore” pragma at the top for manually created index files. another...
Read more >How to add Barrels in TypeScript (or JavaScript)
A barrel's a way to put together all the same type or the same usage files in the same place, and then, use...
Read more >Barrel - TypeScript Deep Dive
A barrel is a way to rollup exports from several modules into a single convenient module. The barrel itself is a module file...
Read more >Putting React in Barrels | Andrew Tarry
A barrel is just a file that only exports files from multiple other files. It contains all our code so that imports become...
Read more >Barrel files, webpack and jest
but I have encouraged similar problem with barrel type definition src/types/index.d.ts referenced usually as @/types all around in codebase.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gregjacobs I ended up rolling this into a library. I’ll make the repo public soon, but you can try it out now if you’re interested:
That will run in the background and watch the files for any changes. I still need to make a few improvements before making that public.
Obviously, make sure to have the ability to easily restore the project back to normal based on any changes you make.
I was thinking about a library that does it, but yeah this is such a simple script to write and it would be more flexible if people maintained it themselves. I’ll add it to the docs. Thanks!
Also, these barrel files are so much better. Really helped reduce the noise in the code.