question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

index.ts barrel files in the codebase?

See original GitHub issue

Having 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:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dsherretcommented, Dec 29, 2017

@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:

# install
npm install -g barrel-maintainer
# view the help
barrel-maintainer -h
# run it on a project
barrel-maintainer src

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.

1reaction
dsherretcommented, Dec 10, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found