Open
Description
I've sadly discovered that it not possible to augment a ES2015 module that is being re-exported. At least not without specifying the full path to the ES2015 that is then being re-exported.
This has significant implications, particularly for library authors and consumers.
An example would probably help clarify.
Suppose as an authored of a library I want to expose a simple surface area from which consumers should import from. I do this by creating an index.ts file that re-exports modules from nested sub-folders like so:
// index.ts
export { AClass } from './path/to/class-a';
export { BClass } from './path/to/class-b';
export { CClass } from './path/to/class-c';
Now a consumer can import like so:
import { AClass, BClass } from 'some-library';
The benefits of the above:
- As library author I am free to reorganise the modules into sub-folders as the library code base grows without breaking consumers
- As library consumer I don't need to have intimate knowledge of how the library organises it's file on disk - instead I have one path to import modules and this is the name of the npm package itself.
Once augmentation enters the picture all of the above benefits are now gone.
This is really bad for everyone.
What can be done about the situation?
Thanks
Christian