`deno vendor`: help with import_map.json changes from deno.land to jsr?
Hi - I'm hoping to get some guidance of best practices of migrating a (n admittedly complicated) import_map.json file from using https://deno.land/std@0.224.0 to
jsr
Our import map at Quarto currently contains entries like this:
We use this syntax because it allows us to do imports in our TS code like this:
import { Tar } from "archive/tar.ts";
import { Zip } from "archive/zip.ts";
, etc.
This allows our import map to not worry about which of the tar.ts
, zip.ts
are going to be ultimately imported in our code.
My specific problem is I'm having a hard time converting that to a jsr
import, say
If I maintain the trailing /
in the syntax, I get a failure like this when calling deno vendor
:
But if I switch to an import_map statement like
then it seems that I need to declare each of the imports (tar, zip, etc) separately in the import map itself. That would be a big bummer and a source of ongoing maintenance toil for us, because the import_map will become much more brittle than before. Is there a way to import from jsr and retain the flexibility with paths we used to have in import maps and deno vendor
? Thanks for the help!17 Replies
the problem is JSR removed the file extensions. So you have to do
import { Tar } from "archive/tar";
(removing the file extension).That doesn't work:
That is the error with the
"archive": "jsr:@std/archive@^0.224.0",
entry in the import mapyou have to add the trailing
/
With
"archive/": "jsr:@std/archive@^0.224.0/",
I get a different error:
oh
I see. That's is because std is now splitted into multiple packages
oh, never mind
no idea. It should work
the message implies that the import map code is expecting a URL and is getting confused by a
jsr:
prefixare you using the lastest Deno version?
that's on 1.46.3
yeah, I have the same error
looks like jsr imports cannot end with trailing slashes. this works to me:
But then you can't do eg
import * as tar from "archive/tar";
or even import { Tar } from "archive/tar"
, which is the point of my original question above.import { Tar } from "archive/tar";
this works in my endI get
Note that this is specifically a
deno vendor
questionah, I think
deno vendor
is deprecatedI apologize - I should have been clearer wrt
deno vendor
, I now see I only mentioned that in the other postWe need
deno vendor
because we need deno bundle
(yes, I know that's also deprecated)
And then that syntax you suggest fails with