esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Pinning does not propagate in .d.ts files

Open zaboco opened this issue 3 years ago • 1 comments

Issue

Pinning a TS type definition file does not propagate to the imported files.

Reproduction

  1. Request react pinned to an older esm.sh version (e.g. v65) - https://esm.sh/[email protected]?pin=v65
  2. Get the .d.ts URL from the x-typescript-types header - https://esm.sh/v65/@types/react@^18/index.d.ts. This step works fine, the root d.ts is pinned to v65
  3. Download the .d.ts file

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';

zaboco avatar Jun 01 '22 11:06 zaboco

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

tv42 avatar Jul 09 '22 21:07 tv42

the server returns a fixed @types/react now

ije avatar Mar 23 '23 12:03 ije