Currently, I am working on a project that consists of lengthy source files. While this is advantageous for imports, it poses challenges in terms of maintenance. For instance:
/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 { ... }
The current compilation results in the following files:
- /dist/core.js
- /dist/core.d.ts
- /dist/core.ts.map
- /dist/data.js
- /dist/data.d.ts
- /dist/data.ts.map
This setup has become quite challenging to maintain as the source files keep growing with additional features. My intention is to separate these into individual files within a new directory, like so:
/main/core/foo.ts
export type Foo { ... }
/main/core/bar.ts
export interface Bar { ... }
/main/core/baz.ts
export class Baz { ... }
I have attempted this restructuring, but it impacts the imports, as seen below:
/main/data/barimpl.ts
import { Foo } from "core/foo";
import { Bar } from "core/bar";
const x: Foo = ...
export class BarImpl implements Bar { ... }
Is there a way to:
- Split /main/core.ts into /main/core/foo.ts, etc., while still compiling them to /dist/core.js, etc.?
- Maintain imports such as
import { Foo, Bar } from "core"
without having to split the imports by file?