Exploring the potential of webpack's code splitting feature to create separate bundles for my TypeScript app has been a priority. After scouring the web for solutions, I stumbled upon a possible lead here: https://github.com/TypeStrong/ts-loader/blob/master/test/execution-tests/babel-codeSplitting/require.d.ts
This reference from the official ts-loader documentation showcases the utilization of require.ensure to establish a split point.
However, what perplexes me is the lack of a straightforward method within TypeScript to accomplish this task. The invocation of require.ensure needs to be done directly in TypeScript. To enable TypeScript to interpret this call seamlessly, the following declaration file must be provided:
declare var require: {
<T>(path: string): T;
(paths: string[], callback: (...modules: any[]) => void): void;
ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void) => void;
};
Is there an alternative, more elegant approach to achieve the same outcome?