My aspiration is to develop a Typescript library that emulates the structure of popular libraries like RxJS and Angular Material, which are divided into submodules.
RxJS and Angular exhibit a way to import features using syntax like this:
// RxJS
import { map, filter } from 'rxjs/operators';
// Angular
import { MatButtonModule } from '@angular/material/button';
Despite studying RxJS's source code on Github in an attempt to replicate this behavior, I have not been successful.
I aim to provide a similar importing experience by allowing users to bring in a class with
import { foo } from 'package/bar'
;
While my library compiles without error, attempting to import it consistently results in a
Cannot resolve dependency 'package/foo'
issue. Oddly enough, importing without specifying the submodule, such as import { test } from package
, works perfectly fine.
I have experimented with using paths in tsconfig but have yet to find a solution. It's possible that I am implementing it incorrectly.
How can I accomplish this type of importing functionality?