Add compiler flag to collapse module IIFEs #4652
Labels
Duplicate
An existing issue was already created
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
If you have multiple classes in the same module namespace but defined in different files (or even just different
module
blocks) TypeScript'stsc
will wrap every one of them into its own nest of IIFEs; one for each level of namespace nesting.For deep namespace hierarchies this produces large amounts of code that increases code size and hurts parsing / loading performance.
To solve this problem, we use a post processing tool (https://github.com/tschneidereit/typescript-module-merger) to merge subsequent modules that appear in the same namespace. This is not a sound optimization but works well in practice. Such a feature should be part of the TypeScript compiler, perhaps under a compiler flag.
The text was updated successfully, but these errors were encountered: