Can I use bit to share non-react typescript modules?

We have a growing nodejs/typescript project with some local node modules that we include by relative path. This is painful and breaks when we use newer versions of npm so we are looking for a solution for code reuse. Bit looks fascinating, but I’m having trouble sharing a trivial typescript module.

When we do bit add do you specify the TS or the JS file as main? I specify the main entry point in my package.json - why wouldn’t bit look in there?

How does the “typescript” compiler extension work? It seems to find no work to do with my simple module even when i delete the JS file. Do i need to alter my source code to export/share with bit?

Most examples I see on your website describe React components and I don’t use those.

The promise of this approach is clear, but getting started with my non-React scenario is tripping me up.
Any help/advice appreciated.


I can help you with the first issue, but you’ll need to provide more info for me to help with the second one.

You can use bit to track all types of components. Not only react. Any node module can be a component.

When you track a component, by default the main file will be the one named index. Regardless of the extension.
You can tell Bit to mark any other file as the entry point. Use the —main flag with the ‘bit import’ command. Each component has its one main file. It’s not the project’s main file.

As for the compiler issues. What exactly are you trying to do and what is the error?

It is still not clear to me what to “add” for main in a typescript module. Do I add app.ts or app.js?
As for compiling, should I expect bit to run tsc for me or continue with how we do it currently? I really don’t understand what “build” means in the bit context.

a main file in Bit is the component’s (module’s) entry point, in case a component contains more than one file, and there’s no file named index (js/ts is irrelevant in that point).
this is because when you install a component, Bit will know what should be the value in the component’s generated package.json.

Bit builds tracked files and creates packages from them.

@brucemackenzie Have you ever figured it out?

I’ve created a related issue if someone can have a look: