Skip to content

Commit 7d73ec8

Browse files
lucacasonatoAugustinMauroycrowlKats
authored
1 parent 635a1a6 commit 7d73ec8

File tree

9 files changed

+188
-83
lines changed

9 files changed

+188
-83
lines changed

api/src/docs.rs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ lazy_static::lazy_static! {
8888
"alert-important",
8989
"alert-warning",
9090
"alert-caution",
91+
"or-bar"
9192
],
9293
)
9394
.link_rel(Some("nofollow"))
@@ -1215,44 +1216,44 @@ impl deno_doc::html::UsageComposer for DocUsageComposer {
12151216

12161217
if !self.runtime_compat.deno.is_some_and(|compat| !compat) {
12171218
map.insert(
1218-
UsageComposerEntry {
1219-
name: "Deno".to_string(),
1220-
icon: Some(
1221-
r#"<img src="/logos/deno.svg" alt="deno logo" draggable="false" />"#.into(),
1222-
),
1223-
},
1224-
format!("Add Package\n```\ndeno add jsr:{scoped_name}\n```{import}\n---- OR ----\n\nImport directly with a jsr specifier\n{}\n", usage_to_md(&format!("jsr:{url}"), Some(self.package.as_str()))),
1225-
);
1219+
UsageComposerEntry {
1220+
name: "Deno".to_string(),
1221+
icon: Some(
1222+
r#"<img src="/logos/deno.svg" alt="deno logo" draggable="false" />"#.into(),
1223+
),
1224+
},
1225+
format!("Add Package\n```\ndeno add jsr:{scoped_name}\n```{import}\n<div class='or-bar'>or</div>\n\nImport directly with a jsr specifier\n{}\n", usage_to_md(&format!("jsr:{url}"), Some(self.package.as_str()))),
1226+
);
12261227
}
12271228

12281229
if !self.runtime_compat.node.is_some_and(|compat| !compat) {
12291230
map.insert(
1230-
UsageComposerEntry {
1231-
name: "npm".to_string(),
1232-
icon: Some(
1233-
r#"<img src="/logos/npm_textless.svg" alt="npm logo" draggable="false" />"#.into(),
1234-
),
1235-
},
1236-
format!("Add Package\n```\nnpx jsr add {scoped_name}\n```{import}"),
1237-
);
1231+
UsageComposerEntry {
1232+
name: "pnpm".to_string(),
1233+
icon: Some(
1234+
r#"<img src="/logos/pnpm_textless.svg" alt="pnpm logo" draggable="false" />"#.into(),
1235+
),
1236+
},
1237+
format!("Add Package\n```\npnpm i jsr:{scoped_name}\n```\n<div class='or-bar'>or (using pnpm 10.8 or older)</div>\n\n```\npnpm dlx jsr add {scoped_name}\n```{import}"),
1238+
);
12381239
map.insert(
1239-
UsageComposerEntry {
1240-
name: "Yarn".to_string(),
1241-
icon: Some(
1242-
r#"<img src="/logos/yarn_textless.svg" alt="yarn logo" draggable="false" />"#.into(),
1243-
),
1244-
},
1245-
format!("Add Package\n```\nyarn dlx jsr add {scoped_name}\n```{import}"),
1246-
);
1240+
UsageComposerEntry {
1241+
name: "Yarn".to_string(),
1242+
icon: Some(
1243+
r#"<img src="/logos/yarn_textless.svg" alt="yarn logo" draggable="false" />"#.into(),
1244+
),
1245+
},
1246+
format!("Add Package\n```\nyarn add jsr:{scoped_name}\n```\n<div class='or-bar'>or (using Yarn 4.8 or older)</div>\n\n```\nyarn dlx jsr add {scoped_name}\n```{import}"),
1247+
);
12471248
map.insert(
1248-
UsageComposerEntry {
1249-
name: "pnpm".to_string(),
1250-
icon: Some(
1251-
r#"<img src="/logos/pnpm_textless.svg" alt="pnpm logo" draggable="false" />"#.into(),
1252-
),
1253-
},
1254-
format!("Add Package\n```\npnpm dlx jsr add {scoped_name}\n```{import}"),
1255-
);
1249+
UsageComposerEntry {
1250+
name: "npm".to_string(),
1251+
icon: Some(
1252+
r#"<img src="/logos/npm_textless.svg" alt="npm logo" draggable="false" />"#.into(),
1253+
),
1254+
},
1255+
format!("Add Package\n```\nnpx jsr add {scoped_name}\n```{import}"),
1256+
);
12561257
}
12571258

12581259
if !self.runtime_compat.bun.is_some_and(|compat| !compat) {

frontend/docs/introduction.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ project.
1818
# deno
1919
deno add jsr:@luca/cases
2020

21-
# npm (use any of npx, yarn dlx, pnpm dlx, or bunx)
22-
npx jsr add @luca/cases
21+
# pnpm 10.9+
22+
pnpm add jsr:@luca/cases
23+
24+
# yarn 4.9+
25+
yarn add jsr:@luca/cases
26+
27+
# npm, bun, and older versions of yarn or pnpm
28+
npx jsr add @luca/cases # replace npx with any of yarn dlx, pnpm dlx, or bunx
2329
```
2430

2531
After adding the package, you can import and use it in ES modules like so:

frontend/docs/npm-compatibility.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,20 @@ downloaded from jsr.io and installed in your `node_modules` directory.
1919

2020
## Installing and using JSR packages
2121

22-
You can add JSR packages to your project using the `jsr` CLI:
22+
If you are using a recent version of pnpm (10.9+) or Yarn (4.9+), you can
23+
install JSR packages using `pnpm install` or `yarn add` without any additional
24+
configuration. These versions of pnpm and Yarn both support JSR out of the box.
25+
26+
```sh
27+
pnpm install jsr:@luca/cases
28+
```
29+
30+
```sh
31+
yarn add jsr:@luca/cases
32+
```
33+
34+
If you are using npm, an older version of pnpm or Yarn, or Bun, you can use the
35+
JSR CLI to install JSR packages:
2336

2437
```sh
2538
npx jsr add @luca/cases
@@ -28,13 +41,15 @@ npx jsr add @luca/cases
2841
This will add the `@luca/cases` package to your `package.json` file, and install
2942
it to your `node_modules` directory using your preferred package manager.
3043

31-
The package manager to use will be automatically detected based on the presence
32-
of a `package.lock`, `yarn.lock` or `pnpm-lock.yaml` file in your project. You
33-
can also specify the package manager to use explicitly using the `--npm`,
34-
`--yarn`, or `--pnpm` flags to the `jsr add` command.
44+
When using the JSR CLI, the package manager to use will be automatically
45+
detected based on the presence of a `package.lock`, `yarn.lock` or
46+
`pnpm-lock.yaml` file in your project. You can also specify the package manager
47+
to use explicitly using the `--npm`, `--yarn`, or `--pnpm` flags to the
48+
`jsr add` command.
3549

36-
> You should check the `.npmrc` file that is created into source control. This
37-
> enables future calls to `npm install` / `yarn` / `pnpm install` to succeed.
50+
> When using the JSR CLI, you should check the `.npmrc` file that is created
51+
> into source control. This enables future calls to `npm install` and alike to
52+
> succeed.
3853
3954
You can then use the JSR package from your code:
4055

@@ -72,9 +87,14 @@ you cannot publish packages to it. You can only use it to install jsr packages
7287
from npm.
7388

7489
The `@jsr` npm scope is served from the JSR registry at `https://npm.jsr.io`.
75-
This means that you need to configure your package manager to use this registry
76-
to install JSR packages. When adding packages with the `jsr` CLI, this is done
77-
automatically.
90+
91+
Recent versions of `yarn` and `pnpm` automatically configure pull packages in
92+
the `@jsr` scope from `https://npm.jsr.io`, so you don't need to do anything
93+
special to use JSR packages with these package managers.
94+
95+
For other package managers, and older versions of `yarn` and `pnpm`, you need to
96+
configure your package manager to use the JSR registry to install JSR packages.
97+
When adding packages with the `jsr` CLI, this is done automatically.
7898

7999
Instead of using the `jsr` CLI to install JSR packages, you can also manually
80100
configure your package manager to support installing JSR packages.

frontend/docs/using-packages.md

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ example below will add the most recent version of
1515
[`@luca/cases`](https://jsr.io/@luca/cases) to your project.
1616

1717
```bash
18-
# deno
18+
# deno, pnpm 10.9+, and yarn 4.9+ with first class JSR support
1919
deno add jsr:@luca/cases
20+
pnpm add jsr:@luca/cases
21+
yarn add jsr:@luca/cases
2022

21-
# npm (one of the below, depending on your package manager)
23+
# npm, bun, and older versions of yarn or pnpm
2224
npx jsr add @luca/cases
25+
bunx jsr add @luca/cases
2326
yarn dlx jsr add @luca/cases
2427
pnpm dlx jsr add @luca/cases
25-
bunx jsr add @luca/cases
2628
```
2729

2830
If you're using Deno, the `deno add` command will add an
@@ -38,24 +40,41 @@ something like this:
3840
}
3941
```
4042

41-
For npm and npm-compatible package managers, the `jsr` command will add the
42-
dependency to your `package.json` file, along with a `.npmrc` file to your
43-
project root with the necessary config to use JSR with npm. Learn more about
43+
For npm compatible package managers, the dependency will be added to your
44+
`package.json` file, and the package will be installed to your `node_modules`
45+
directory.
46+
47+
For npm, older versions of pnpm and Yarn, and for Bun, the `jsr` command will
48+
additionally add a `.npmrc` file to your project root with the necessary config
49+
to use JSR with npm. Learn more about
4450
[JSR's npm compatibility layer](/docs/npm-compatibility).
4551

46-
After installation with `npx jsr add`, your package.json will contain a
47-
dependency entry that looks something like this:
52+
After installation with any npm compatible package manager, your package.json
53+
will contain a dependency entry that looks like one of these configurations:
54+
55+
```json
56+
// pnpm 10.9+ and yarn 4.9+
57+
{
58+
"dependencies": {
59+
"@luca/cases": "jsr:@luca/cases@^1.0.1"
60+
}
61+
}
62+
```
63+
64+
or
4865

4966
```json
67+
// npm, bun, and older versions of yarn or pnpm
5068
{
5169
"dependencies": {
5270
"@luca/cases": "npm:@jsr/luca__cases@^1.0.1"
5371
}
5472
}
5573
```
5674

57-
This npm dependency configuration makes use of a special custom scope called
58-
`@jsr`, which is now configured for you in `.npmrc`:
75+
In npm, Bun, and older versions of yarn or pnpm the dependency configuration
76+
makes use of a special custom scope called `@jsr`, which is configured for you
77+
in `.npmrc`:
5978

6079
```
6180
@jsr:registry=https://npm.jsr.io
@@ -99,41 +118,49 @@ If you only care about the major version, you can specify just the major
99118
version:
100119

101120
```bash
102-
# deno
121+
# deno, pnpm 10.9+ and yarn 4.9+
103122
deno add jsr:@luca/cases@1
123+
pnpm add jsr:@luca/cases@1
124+
yarn add jsr:@luca/cases@1
104125

105-
# npm (and npm-like systems)
126+
# npm (and bun, and older versions of yarn or pnpm)
106127
npx jsr add @luca/cases@1
107128
```
108129

109130
If you want to use a specific minor version, you can specify the minor version:
110131

111132
```bash
112-
# deno
133+
# deno, pnpm 10.9+ and yarn 4.9+
113134
deno add jsr:@luca/[email protected]
135+
pnpm add jsr:@luca/[email protected]
136+
yarn add jsr:@luca/[email protected]
114137

115-
# npm (and npm-like systems)
138+
# npm (and bun, and older versions of yarn or pnpm)
116139
npx jsr add @luca/[email protected]
117140
```
118141

119142
If you want to use a specific patch version, you can specify the patch version:
120143

121144
```bash
122-
# deno
145+
# deno, pnpm 10.9+ and yarn 4.9+
123146
deno add jsr:@luca/[email protected]
147+
pnpm add jsr:@luca/[email protected]
148+
yarn add jsr:@luca/[email protected]
124149

125-
# npm (and npm-like systems)
150+
# npm (and bun, and older versions of yarn or pnpm)
126151
npx jsr add @luca/[email protected]
127152
```
128153

129154
If you want to use at least a specific patch version, but do want to allow\
130155
updates, you can specify the patch version with a `^` prefix:
131156

132157
```bash
133-
# deno
158+
# deno, pnpm 10.9+ and yarn 4.9+
134159
deno add jsr:@luca/cases@^1.0.1
160+
pnpm add jsr:@luca/cases@^1.0.1
161+
yarn add jsr:@luca/cases@^1.0.1
135162

136-
# npm (and npm-like systems)
163+
# npm (and bun, and older versions of yarn or pnpm)
137164
npx jsr add @luca/cases@^1.0.1
138165
```
139166

frontend/docs/with/cloudflare-workers.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,28 @@ First, create a new Cloudflare Worker project:
1616
npm create cloudflare@latest
1717
yarn create cloudflare
1818
pnpm create cloudflare
19+
bun create cloudflare
1920
```
2021

21-
You can then add JSR packages with the `jsr` CLI. This will add the package to
22-
your `package.json` and install it into your `node_modules` folder using your
23-
preferred package manager (npm, yarn, or pnpm).
22+
You can then add JSR packages using your package manager. This will add the
23+
package to your `package.json` and install it into your `node_modules` folder
24+
using your preferred package manager (npm, yarn, or pnpm).
2425

2526
```shell
27+
# pnpm 10.9+ and yarn 4.9+
28+
pnpm add jsr:@std/encoding
29+
yarn add jsr:@std/encoding
30+
31+
# npm, bun, and older versions of yarn or pnpm
2632
npx jsr add @std/encoding
33+
bunx jsr add @std/encoding
34+
yarn dlx jsr add @std/encoding
35+
pnpm dlx jsr add @std/encoding
2736
```
2837

29-
> Note: You should check the `.npmrc` file that is created into source control.
30-
> Without this, future calls to `npm install` / `yarn` / `pnpm install` will not
38+
> Note: A `.npmrc` file is created when using the JSR CLI. The `.npmrc` file
39+
> that is created should be checked into source control. Without this, future
40+
> calls to `npm install` / `yarn` / `pnpm install` / `bun install` will not
3141
> succeed.
3242
3343
You can then import JSR packages in your code:

frontend/docs/with/nextjs.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,28 @@ First, create a new Next.js project:
1515
npx create-next-app@latest
1616
yarn create next-app
1717
pnpm create next-app
18+
bun create next-app
1819
```
1920

20-
You can then add JSR packages with the `jsr` CLI. This will add the package to
21-
your `package.json` and install it into your `node_modules` folder using your
22-
preferred package manager (npm, yarn, or pnpm).
21+
You can then add JSR packages using your package manager. This will add the
22+
package to your `package.json` and install it into your `node_modules` folder
23+
using your preferred package manager (npm, yarn, or pnpm).
2324

2425
```shell
26+
# pnpm 10.9+ and yarn 4.9+
27+
pnpm add jsr:@std/encoding
28+
yarn add jsr:@std/encoding
29+
30+
# npm, bun, and older versions of yarn or pnpm
2531
npx jsr add @std/encoding
32+
bunx jsr add @std/encoding
33+
yarn dlx jsr add @std/encoding
34+
pnpm dlx jsr add @std/encoding
2635
```
2736

28-
> Note: You should check the `.npmrc` file that is created into source control.
29-
> Without this, future calls to `npm install` / `yarn` / `pnpm install` will not
37+
> Note: A `.npmrc` file is created when using the JSR CLI. The `.npmrc` file
38+
> that is created should be checked into source control. Without this, future
39+
> calls to `npm install` / `yarn` / `pnpm install` / `bun install` will not
3040
> succeed.
3141
3242
You can then import JSR packages in your code:

frontend/docs/with/node.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,25 @@ JSR packages can be used in Node.js by using
1212
JSR packages are always ESM-only, so your project must be using
1313
`"type": "module"` in your `package.json` to use JSR packages.
1414

15-
You can then add JSR packages with the `jsr` CLI. This will add the package to
16-
your `package.json` and install it into your `node_modules` folder using your
17-
preferred package manager (npm, yarn, or pnpm).
15+
You can then add JSR packages using your package manager. This will add the
16+
package to your `package.json` and install it into your `node_modules` folder
17+
using your preferred package manager (npm, yarn, or pnpm).
1818

1919
```shell
20-
npx jsr add @std/fmt
20+
# pnpm 10.9+ and yarn 4.9+
21+
pnpm add jsr:@std/encoding
22+
yarn add jsr:@std/encoding
23+
24+
# npm, bun, and older versions of yarn or pnpm
25+
npx jsr add @std/encoding
26+
bunx jsr add @std/encoding
27+
yarn dlx jsr add @std/encoding
28+
pnpm dlx jsr add @std/encoding
2129
```
2230

23-
> Note: You should check the `.npmrc` file that is created into source control.
24-
> Without this, future calls to `npm install` / `yarn` / `pnpm install` will not
31+
> Note: A `.npmrc` file is created when using the JSR CLI. The `.npmrc` file
32+
> that is created should be checked into source control. Without this, future
33+
> calls to `npm install` / `yarn` / `pnpm install` / `bun install` will not
2534
> succeed.
2635
2736
You can then import JSR packages in your code:

0 commit comments

Comments
 (0)