Exports

Re-export things, all the time. Make importing things as confusing as possible. JS doesn’t have great “module” features. Like everything else, its very loosey goosey, giving developers the option to do anything and everything.

./components/
├── button.ts
└── index.ts // button is re-exported here

Both of these are valid and both of these show up in the auto-complete list of possible imports.

import button from '~/components/button'
import { button } from '~/components'

Every time you re-export, you’re adding another option in that list.

Even better, if you “goto definition”, you’ll first be brought to the re-export.

In Rust this is better because make you define a mod.rs file in directories. If you don’t declare your export here, YOU CANNOT IMPORT IT. “Barrels” done right.

Another terrible thing you can do is re-export a npm dependency. So now you can e.g. import useState from react and my-react-for-some-reason.