Skip to content

Commit 74fa145

Browse files
authored
Merge branch 'next' into next
2 parents 3ad73b9 + 4715d87 commit 74fa145

File tree

5 files changed

+83
-15
lines changed

5 files changed

+83
-15
lines changed

.github/workflows/milestone-automation.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Check if PR was in Backlog
1717
id: check_milestone
1818
run: |
19-
milestone_id=$(gh pr view ${{ github.repository }}#${{ github.event.pull_request.number }} --json milestone --jq '.milestone.number')
19+
milestone_id=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} --jq '.milestone.number')
2020
if [[ "$milestone_id" == "3" ]]; then
2121
echo "backlog_milestone=true" >> $GITHUB_OUTPUT
2222
else
@@ -36,7 +36,7 @@ jobs:
3636
- name: Find and update associated issues to "shipping next"
3737
if: steps.check_milestone.outputs.backlog_milestone == 'true'
3838
run: |
39-
issues=$(gh pr view ${{ github.repository }}#${{ github.event.pull_request.number }} --json closingIssuesReferences --jq '.closingIssuesReferences[].number')
39+
issues=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} --jq '.closingIssuesReferences[].number')
4040
for issue in $issues; do
4141
echo "Updating issue #$issue to milestone ID 2 (shipping next)"
4242

errors/NUQS-101.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This package is ESM only.
2+
3+
Since version 2.0.0, `nuqs` is now an [ESM-only package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
4+
5+
## Probable cause
6+
7+
You may have encountered this error when trying to import `nuqs` in a CommonJS
8+
environment, like Jest or ESLint.
9+
10+
## Possible solutions
11+
12+
If you cannot update your project to use ESM (which would be the most future-proof
13+
solution), please refer to the following guides:
14+
15+
### Jest
16+
17+
See the [testing adapter documentation](https://nuqs.47ng.com/docs/testing#with-jest)
18+
for its configuration with Jest.
19+
20+
### ESLint
21+
22+
See issue [#691](https://github.com/47ng/nuqs/issues/691) for more details.
23+
24+
### Something else?
25+
26+
If you are encountering this error in a different context, please
27+
[open an issue](https://github.com/47ng/nuqs/issues/new/choose) with details about
28+
your setup (a reproduction repository would be even better).

packages/docs/content/docs/testing.mdx

+34
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ description: Some tips on testing components that use `nuqs`
66
Since nuqs 2, you can unit-test components that use `useQueryState(s){:ts}` hooks
77
by wrapping your rendered component in a `NuqsTestingAdapter{:ts}`.
88

9+
## With Vitest
10+
911
Here is an example for Vitest and Testing Library to test a button rendering
1012
a counter:
1113

@@ -78,3 +80,35 @@ it('should increment the count when clicked', async () => {
7880
</Tabs>
7981

8082
See issue [#259](https://github.com/47ng/nuqs/issues/259) for more testing-related discussions.
83+
84+
## With Jest
85+
86+
Since nuqs 2 is an [ESM-only package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c),
87+
there are a few hoops you need to jump through to make it work with Jest.
88+
This is extracted from the [Jest ESM guide](https://jestjs.io/docs/ecmascript-modules).
89+
90+
1. Add the following options to your jest.config.ts file:
91+
92+
```ts title="jest.config.ts"
93+
const config: Config = {
94+
// <Other options here>
95+
// [!code highlight:3]
96+
extensionsToTreatAsEsm: [".ts", ".tsx"],
97+
transform: {}
98+
};
99+
```
100+
101+
2. Change your test command to include the `--experimental-vm-modules` flag:
102+
103+
```json title="package.json"
104+
// [!code word:--experimental-vm-modules]
105+
{
106+
"scripts": {
107+
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
108+
}
109+
}
110+
```
111+
112+
<Callout>
113+
Adapt accordingly for Windows with [`cross-env`](https://www.npmjs.com/package/cross-env).
114+
</Callout>

packages/docs/src/app/(pages)/_landing/sponsors.tsx

+18-12
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function SponsorsSection() {
1111
<h2 className="mb-12 text-center text-3xl font-bold tracking-tighter dark:text-white md:text-4xl xl:text-5xl">
1212
Sponsors
1313
</h2>
14-
<ul className="container grid grid-cols-1 gap-y-12 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5">
14+
<ul className="container grid grid-cols-2 gap-y-12 md:grid-cols-3 xl:grid-cols-6">
1515
{sponsors.map(sponsor => (
1616
<li key={sponsor.handle} className="flex flex-col items-center">
1717
<a href={sponsor.url} className="h-32 w-32 rounded-full">
@@ -84,11 +84,16 @@ async function fetchSponsors(): Promise<Sponsors> {
8484
// }
8585
return [
8686
{
87-
handle: 'YoannFleuryDev',
88-
name: 'Yoann Fleury',
89-
url: 'https://www.yoannfleury.dev/',
90-
img: 'https://pbs.twimg.com/profile_images/1594632934245498880/CJTKNRCO_400x400.jpg',
91-
title: 'Front end developer'
87+
handle: 'vercel',
88+
name: 'Vercel',
89+
url: 'https://vercel.com/',
90+
img: 'https://avatars.githubusercontent.com/u/14985020?v=4'
91+
},
92+
{
93+
handle: 'ryanmagoon',
94+
name: 'Ryan Magoon',
95+
url: 'https://x.com/Ryan_Magoon',
96+
img: 'https://avatars.githubusercontent.com/u/5327290?v=4'
9297
},
9398
{
9499
handle: 'pontusab',
@@ -104,12 +109,6 @@ async function fetchSponsors(): Promise<Sponsors> {
104109
</>
105110
)
106111
},
107-
{
108-
handle: 'vercel',
109-
name: 'Vercel',
110-
url: 'https://vercel.com/',
111-
img: 'https://avatars.githubusercontent.com/u/14985020?v=4'
112-
},
113112
{
114113
handle: 'CarlLindesvard',
115114
name: 'Carl Lindesvärd',
@@ -137,6 +136,13 @@ async function fetchSponsors(): Promise<Sponsors> {
137136
</a>
138137
</>
139138
)
139+
},
140+
{
141+
handle: 'YoannFleuryDev',
142+
name: 'Yoann Fleury',
143+
url: 'https://www.yoannfleury.dev/',
144+
img: 'https://pbs.twimg.com/profile_images/1594632934245498880/CJTKNRCO_400x400.jpg',
145+
title: 'Front end developer'
140146
}
141147
]
142148
}

packages/nuqs/esm-only.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
throw new Error(
77
`This package is ESM only.
8-
See https://github.com/47ng/nuqs/issues/691 for more details.`
8+
See https://err.47ng.com/NUQS-101 for more details.`
99
)

0 commit comments

Comments
 (0)