Some big pieces of code you can load dynamically.
Update your tsconfig.json:
{
...
"compilerOptions": {
...
"module": "esnext",
}
}
Use import() function:
...
export class AppComponent {
async loadAndRun() {
const file = await import('./big-fn');
file.bigFn();
}
}export function bigFn() {
...
}More info about dynamic imports in TypeScript: https://blog.mariusschulz.com/2018/01/14/typescript-2-4-dynamic-import-expressions