diff --git a/packages/nuqs/package.json b/packages/nuqs/package.json index 2aa246d1..512f4dd2 100644 --- a/packages/nuqs/package.json +++ b/packages/nuqs/package.json @@ -113,7 +113,7 @@ "scripts": { "dev": "tsup --watch", "prebuild": "rm -rf dist", - "build": "tsup", + "build": "tsc --project tsconfig.build.json", "postbuild": "size-limit --json > size.json", "test": "pnpm run '/^test:/'", "test:types": "tsd", diff --git a/packages/nuqs/src/adapters/custom.ts b/packages/nuqs/src/adapters/custom.ts index 80664974..52b9eb2d 100644 --- a/packages/nuqs/src/adapters/custom.ts +++ b/packages/nuqs/src/adapters/custom.ts @@ -1,3 +1,5 @@ +'use client' + export { renderQueryString } from '../url-encoding' export type { AdapterInterface as unstable_AdapterInterface, diff --git a/packages/nuqs/src/adapters/internal.context.ts b/packages/nuqs/src/adapters/internal.context.ts index 9b646af2..aea5067b 100644 --- a/packages/nuqs/src/adapters/internal.context.ts +++ b/packages/nuqs/src/adapters/internal.context.ts @@ -1,4 +1,10 @@ -import { createContext, createElement, useContext, type ReactNode } from 'react' +import { + createContext, + createElement, + useContext, + type FC, + type ReactNode +} from 'react' import { error } from '../errors' import type { UseAdapterHook } from './defs' @@ -21,7 +27,9 @@ context.displayName = 'NuqsAdapterContext' * @param useAdapter * @returns */ -export function createAdapterProvider(useAdapter: UseAdapterHook) { +export function createAdapterProvider( + useAdapter: UseAdapterHook +): FC<{ children: ReactNode }> { return ({ children, ...props }: { children: ReactNode }) => createElement( context.Provider, diff --git a/packages/nuqs/src/adapters/next.ts b/packages/nuqs/src/adapters/next.ts index 62bfa2c6..5a53606e 100644 --- a/packages/nuqs/src/adapters/next.ts +++ b/packages/nuqs/src/adapters/next.ts @@ -1,3 +1,5 @@ +'use client' + import type { AdapterInterface } from './defs' import { createAdapterProvider } from './internal.context' import { useNuqsNextAppRouterAdapter } from './next/impl.app' diff --git a/packages/nuqs/src/adapters/next/app.ts b/packages/nuqs/src/adapters/next/app.ts index 68910ca4..eb28f545 100644 --- a/packages/nuqs/src/adapters/next/app.ts +++ b/packages/nuqs/src/adapters/next/app.ts @@ -1,3 +1,5 @@ +'use client' + import { createAdapterProvider } from '../internal.context' import { useNuqsNextAppRouterAdapter } from './impl.app' diff --git a/packages/nuqs/src/adapters/next/impl.app.ts b/packages/nuqs/src/adapters/next/impl.app.ts index eee281e3..3be7e4b4 100644 --- a/packages/nuqs/src/adapters/next/impl.app.ts +++ b/packages/nuqs/src/adapters/next/impl.app.ts @@ -1,5 +1,7 @@ +'use client' + import { useRouter, useSearchParams } from 'next/navigation' -import { useCallback, useOptimistic, startTransition } from 'react' +import { startTransition, useCallback, useOptimistic } from 'react' import { debug } from '../../debug' import type { AdapterInterface, UpdateUrlFunction } from '../defs' import { renderURL } from './shared' diff --git a/packages/nuqs/src/adapters/next/pages.ts b/packages/nuqs/src/adapters/next/pages.ts index 4e1e1763..5148850b 100644 --- a/packages/nuqs/src/adapters/next/pages.ts +++ b/packages/nuqs/src/adapters/next/pages.ts @@ -1,3 +1,5 @@ +'use client' + import { createAdapterProvider } from '../internal.context' import { useNuqsNextPagesRouterAdapter } from './impl.pages' diff --git a/packages/nuqs/src/adapters/react-router.ts b/packages/nuqs/src/adapters/react-router.ts index a2c9041d..ca9caffc 100644 --- a/packages/nuqs/src/adapters/react-router.ts +++ b/packages/nuqs/src/adapters/react-router.ts @@ -1,5 +1,6 @@ // Note: this default react-router adapter is for react-router v6. // If you are using react-router v7, please import from `nuqs/adapters/react-router/v7` +'use client' import { useNavigate, useSearchParams } from 'react-router-dom' import { renderQueryString } from '../url-encoding' diff --git a/packages/nuqs/src/adapters/react.ts b/packages/nuqs/src/adapters/react.ts index b35818eb..7afa63c6 100644 --- a/packages/nuqs/src/adapters/react.ts +++ b/packages/nuqs/src/adapters/react.ts @@ -1,3 +1,5 @@ +'use client' + import mitt from 'mitt' import { useEffect, useState } from 'react' import { renderQueryString } from '../url-encoding' diff --git a/packages/nuqs/src/adapters/remix.ts b/packages/nuqs/src/adapters/remix.ts index 4598c341..fc4e09de 100644 --- a/packages/nuqs/src/adapters/remix.ts +++ b/packages/nuqs/src/adapters/remix.ts @@ -1,3 +1,5 @@ +'use client' + import { useNavigate, useSearchParams } from '@remix-run/react' import { renderQueryString } from '../url-encoding' import type { AdapterOptions } from './defs' diff --git a/packages/nuqs/src/index.ts b/packages/nuqs/src/index.ts index b8bc6f51..055299c6 100644 --- a/packages/nuqs/src/index.ts +++ b/packages/nuqs/src/index.ts @@ -1,3 +1,4 @@ +'use client' export type { HistoryOptions, Nullable, Options, SearchParams } from './defs' export * from './parsers' export { createSerializer } from './serializer' diff --git a/packages/nuqs/src/index.server.ts b/packages/nuqs/src/server.ts similarity index 100% rename from packages/nuqs/src/index.server.ts rename to packages/nuqs/src/server.ts diff --git a/packages/nuqs/tsconfig.build.json b/packages/nuqs/tsconfig.build.json index 3a6aa797..6b5f6c05 100644 --- a/packages/nuqs/tsconfig.build.json +++ b/packages/nuqs/tsconfig.build.json @@ -1,5 +1,12 @@ { "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "outDir": "dist", + "declaration": true, + "declarationMap": false, + "incremental": false + }, "include": ["src/**/*.ts"], "exclude": ["src/tests", "src/**/*.test.ts", "src/**/*.test.tsx"] } diff --git a/packages/nuqs/tsup.config.ts b/packages/nuqs/tsup.config.ts index 2120fa7f..9b53b06d 100644 --- a/packages/nuqs/tsup.config.ts +++ b/packages/nuqs/tsup.config.ts @@ -5,7 +5,7 @@ import { defineConfig, type Options } from 'tsup' const commonConfig = { format: ['esm'], - experimentalDts: true, + dts: true, outDir: 'dist', external: [ 'next',