lukeed / tsm

TypeScript Module Loader
MIT License
1.18k stars 19 forks source link

Resolve remote imports from CDNs? #40

Closed manuschillerdev closed 2 years ago

manuschillerdev commented 2 years ago

I use tsm a lot for prototyping ideas without the need to set up a proper project and I love it for that! As soon as I use dependencies, I'd need to add a package.json and install the depencies as usual.

It would be super cool, if tsm could resolve modules from cdns for that purpose.

Two possible solutions come to my mind:

lukeed commented 2 years ago

Thanks! tsm exposes esbuild’s transform options directly, which do not (currently) include plugins support. IIRC there’s an open issue somewhere about adding plugins to the transform API specifically for resolution customization, but tsm is dependent on esm for that decision. The only reliable other way to do that would be to incorporate some other AST parser/modifier/stringify tool which I don’t want to do (for size and speed degradation)