How should you use an import map if you're not using Deno?
In the "Dependency manifest" section of the "Publishing packages" page it indicates that there are options for using an import map other than deno.json.
How would that work? Does it need to be named import_map.json (I prefer dash-case for file names and from what I've seen dash-case is common)? Does it need to be at the top level (ie. not nested under some other directory)? Does it need to be referenced in jsr.json at all? Is the following the right format (maybe it's different for a non deno.json import map)?
Context: I currently have the NPM package @adamzerner/rfui-react but want to ditch NPM and publish to JSR instead. rfui-library/rfui is the repo I created for the new JSR module. I have:
import_map.json
{
"imports": {
"react": "npm:[email protected]"
}
}
but when I do npx jsr publish I get the following error:
code/rfui [master●] » npx jsr publish
error: Failed resolving types. Relative import path "react" not prefixed with / or ./ or ../
at file:///Users/adamzerner/code/rfui/src/atoms/badge.tsx:1:48
Child process exited with: 1
Here are the two imports (file):
import type { ComponentProps, ReactNode } from "react";
import * as React from "react";
You may name it anything you like. You can pass the path to the import map to the publish command using the --import-map flag.
You may name it anything you like. You can pass the path to the import map to the publish command using the
--import-mapflag.
@lucacasonato That doesn't seem to be working:
code/rfui [master●] » npx jsr publish --import-map=import-map.json
Downloading JSR binary...
[00:06] [#################################################>] 40.5 MiB/40.6 MiB
error: unexpected argument '--import-map' found
Usage: deno publish [OPTIONS]
For more information, try '--help'.
Child process exited with: 1
code/rfui [master●] » npx jsr publish --import-map import-map.json
Need to install the following packages:
[email protected]
Ok to proceed? (y) y
error: unexpected argument '--import-map' found
Usage: deno publish [OPTIONS]
For more information, try '--help'.
Child process exited with: 1
code/rfui [master●] » npx jsr publish --import-map="import-map.json"
error: unexpected argument '--import-map' found
Usage: deno publish [OPTIONS]
For more information, try '--help'.
Child process exited with: 1
@bartlomieju PTAL