I'm trying to publish a TypeScript library using webpack and with a folder structure like:
src/
module1/
some-class.ts
index.ts
module2/
some-other-class.ts
index.ts
etc/
If used in TS, I should be able to do:
import { SomeClass } from 'my-library/module1';
And when using require, should be able to do:
const SomeClass = require('my-library/module1');
Webpack needs an entry (or multiple entries) and outs files matching those entries. However, I see defining entries for every nested folder very impractical, and also don't know how to make deep nested entries like require('my-library/module1/submodule1/etc').
Also, authored that way, it might not follow the dts files outputted by the ts-loader.
What am I missing here? Is there a way to make webpack replicate the module structure of the TS sources?
Am I using the wrong tool?
If so, what do people use to bundle libraries?