Pinning does not propagate in .d.ts files
Issue
Pinning a TS type definition file does not propagate to the imported files.
Reproduction
- Request
reactpinned to an older esm.sh version (e.g.v65) - https://esm.sh/[email protected]?pin=v65 - Get the .d.ts URL from the
x-typescript-typesheader - https://esm.sh/v65/@types/react@^18/index.d.ts. This step works fine, the rootd.tsis pinned tov65 - Download the
.d.tsfile
Expected
The imports are pinned to version v65. E.g.:
import * as CSS from 'https://esm.sh/v65/[email protected]/index.d.ts';
Actual
The imports are pinned to the latest version (v85 at this time):
import * as CSS from 'https://esm.sh/v85/[email protected]/index.d.ts';
A second, I think related, issue is that the types package version shifts over time. I just had a build fail because my lock file had
https://esm.sh/v86/@types/[email protected]/global.d.ts etc
where what seems to be needed now is
https://esm.sh/v86/@types/[email protected]/global.d.ts.
The header returned is
$ curl -s -i 'https://esm.sh/[email protected]/jsx-runtime?pin=v86' | grep '^x-typescript-types:'
x-typescript-types: https://esm.sh/v86/@types/react@^18/jsx-runtime~.d.ts
Where you can see it's ^18 not a specific version.
This causes breakage of any lockfile-using builds every time any @types/* package sees a patch release.
It seems ?deps cannot be used to fix this, either:
$ curl -s -i 'https://esm.sh/[email protected]/jsx-runtime?pin=v86&deps=@types/[email protected]' | grep '^x-typescript-types:'
x-typescript-types: https://esm.sh/v86/@types/react@^18/jsx-runtime~.d.ts
This might be related to https://github.com/ije/esm.sh/issues/234 and https://github.com/ije/esm.sh/issues/331
the server returns a fixed @types/react now