Open oscarotero opened 4 months ago
The problem is that import maps don't understand the semantics of the version in the URL, it must literally match the URL of the import.
If you look at the module https://jsr.io/@oak/commons/0.10.1/media_types.ts you'll see that it imports:
jsr:@std/media-types@0.222/type-by-extension
(ie. without the patch .1
part of the version)
So the import map will only match that whole value, or maybe one with a trailing /
, so the following mapping may work:
"jsr:@std/media-types@0.222/type-by-extension": "jsr:@std/media-types@0.223.0/type-by-extension"
or
"jsr:/@std/media-types@0.222/": "jsr:/@std/media-types@0.223.0/"
(not 100% sure on this, try it with and without the /
after the jsr:
scheme)
I have a similar case where a package is using older versions of @std/path
, I can dedupe with the following:
"jsr:@std/path@0.213": "jsr:@std/path@^0.223.0"
Thanks @jollytoad I can confirm that the following import map does the job:
{
"imports": {
"jsr:@std/media-types@0.222/type-by-extension": "jsr:@std/media-types@0.223.0/type-by-extension"
}
}
But I think it's a very unfortunate behavior. If JSR dependencies can have different specifiers for the same file, it's really painful to work with import maps.
What seems like a bug here is that this doesn't seem to work:
"jsr:@std/media-types@0.222": "jsr:@std/media-types@0.223.0"
But I think it's a very unfortunate behavior. If JSR dependencies can have different specifiers for the same file, it's really painful to work with import maps.
Yeah, there needs to be a better way here.
An annoying thing (the main reason I hate exports
feature of JSR packages) is the file is imported as /type-by-extension
(with dashes) but deno info
shows /type_by_extension.ts
(with extension and underscores) which makes even more complicated to figure out what's the file that need to be mapped.
And another inconsitency: it seems that the scope must be defined in http format and the imports in jsr format.
// This works
{
"scopes": {
"https://jsr.io/@oak/commons/0.10.1/media_types.ts": {
"jsr:@std/media-types@0.222/type-by-extension": "jsr:@std/media-types@0.223.0/type-by-extension"
}
},
}
// This doesn't work
{
"scopes": {
"jsr:@oak/commons@0.10.1/media-types": {
"jsr:@std/media-types@0.222/type-by-extension": "jsr:@std/media-types@0.223.0/type-by-extension"
}
},
}
// This neither
{
"scopes": {
"https://jsr.io/@oak/commons@0.10.1/media_types.ts": {
"https://jsr.io/@std/media-types@0.222/type_by_extension.ts": "https://jsr.io/@std/media-types@0.223.0/type_by_extension.ts"
}
},
}
Version: Deno 1.42.4
I have the following script:
deno info
outputs the following dependencies tree:As you can see, there are two different versions of the same package:
@std/media/0.223.0
andstd/media/0.222.1
. I want to use import maps to fix this:But it doesn't work. I've tried different strategies:
But seems that none of them fixes this issue,
deno info
outputs the same tree, ignoring the import maps. Are import maps supported in JSR dependencies?FYI I found the same issue with NPM #23459