jsr-io / jsr-npm

A cli tool to make installing packages form jsr.io in node easy
https://npmjs.com/package/jsr
MIT License
102 stars 13 forks source link

feat: add --from-jsr-config option #68

Open marvinhagemeister opened 8 months ago

marvinhagemeister commented 8 months ago

Based on a feature request on discord:

This option is useful for testing Deno-first JSR packages in Node. Passing this flag installs all jsr:* and npm:* packages defined in the "imports" field as npm package which effectively adds it to package.json.

Input:

// jsr.json or deno.json (or their *.jsonc variants)
{
  "imports": {
    "@std/encoding": "jsr:@std/encoding@^0.216.0"
    "preact": "npm:preact@10.20.0"
  }
}

Run: npx jsr i --from-jsr-config

Result:

// package.json
{
  "dependencies": {
    "@std/encoding": "npm:@jsr/std__encoding@^0.216.0",
    "preact": "10.20.0"
  }
}