denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
95.58k stars 5.3k forks source link

Proposal: Make import map works in X-Typescript-Types #11382

Open codehz opened 3 years ago

codehz commented 3 years ago

Currently, X-Typescript-Types can only work with http/https url (including internal reference)

Those response are invalid: (note: assuming that all referenced names are defined in import maps) X-Typescript-Types: <a working url but it import some library that need import map to work, aka peer dependencies> X-Typescript-Types: ~/my-local-override.d.ts

kitsonk commented 3 years ago

I am not sure what you are suggesting. Can you provide a specific example and what sort of use case you are trying to solve?

codehz commented 3 years ago

@kitsonk Library A and B depend on C, but they may not be served on same server (hostname), for example, A and C are on esm.sh, B is on skypack.dev (C can also be found in skypack.dev), so deno will try to download C library from two different origin, that's can be problematic. And it is what import-map want to solve, since it already working for normal import(and @deno-types, <Reference ...>), why not make it works for X-Typescript-Types ?

kitsonk commented 3 years ago

That is still not very clear. Are their examples of packages published in npm that are hard-coded to refer to other CDNs?

When I suggested a specific example, I mean what URLs would be requested, what would the import map actually look like, what the value of the X-TypeScript-Types header would be and what you would expected to be different from today. It is really hard to follow an abstract A depends on B situation.