I am currently writing a project that has some very long source files, which is great for imports but not so great for maintenance; for example:
/main/core.ts
export type Foo { ... }
export interface Bar { ... }
export class Baz { ... }
/main/data.ts
import { Foo, Bar } from "core";
const x: Foo = ...;
export class BarImpl implements Bar { ... }
Currently these files compile to:
- /dist/core.js
- /dist/core.d.ts
- /dist/core.ts.map
- /dist/data.js
- /dist/data.d.ts
- /dist/data.ts.map
As mentioned, it's a bit of a maintenance nightmare, with source files getting longer and longer as more features are added. What I'd like to do is split these out into their own source files under a new directory; for example:
/main/core/foo.ts
export type Foo { ... }
/main/core/bar.ts
export interface Bar { ... }
/main/core/baz.ts
export class Baz { ... }
I can do this, but it has a knock on effect with imports; for example:
/main/data/barimpl.ts
import { Foo } from "core/foo";
import { Bar } from "core/bar";
const x: Foo = ...
export class BarImpl implements Bar { ... }
Is it possible to:
- Split /main/core.ts into /main/core/foo.ts etc. and still compile them to /dist/core.js etc.?
- Maintain imports like
import { Foo, Bar } from "core"rather than having to split imports by file?