In order to address the challenge with webpack, it's important to note that there isn't a perfect solution available. Unless the project is massive, transitioning to external modules is often the most effective approach.
If your files predominantly follow this structure:
//a.ts
module a.b.c {
export class A {}
}
//b.ts
module d.e.f {
export class B extends a.b.c.A
}
It becomes relatively simpler as you can simply modify them as follows:
//a.ts
export module a.b.c {
export class A {}
}
//b.ts
import {a} from './a';
module d.e.f {
export class B extends a.b.c.A
}
However, if your scenario involves two files within the same namespace\internal module like a.b.c
, handling this becomes more complex and might require some less elegant solutions like:
//b.ts
import {aImported} from './a';
module a.b.c {
export class B extends aImported.b.c.A
}
In this particular resolution, the files act as external modules exporting internal ones.
Another alternative to consider is taking all existing code, compiling and concatenating it using traditional methods like Gulp or Grunt before integrating the resulting javascript file into webpack. While I have utilized this method previously, I've found it cumbersome and subsequently moved on from it. Despite its minimal impact on code modification, overall, I believe it presents more challenges compared to other solutions...