From 697736a31975c7696df524508629b4396e1e1d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Best?= Date: Wed, 1 Jan 2025 11:00:50 +0000 Subject: [PATCH] ref: Move all other server exports under a single (explicit) path --- packages/nuqs/package.json | 11 +++------ packages/nuqs/server/README.md | 4 ++-- packages/nuqs/src/index.server.cache.ts | 1 - packages/nuqs/src/index.server.parsers.ts | 2 -- packages/nuqs/src/index.server.serializer.ts | 2 -- packages/nuqs/src/index.server.ts | 24 ++++++++++++------- .../src/index.temporary-react-agnostic.ts | 15 ++++++++++++ packages/nuqs/src/index.ts | 8 ++++++- packages/nuqs/tsup.config.ts | 3 +-- 9 files changed, 44 insertions(+), 26 deletions(-) delete mode 100644 packages/nuqs/src/index.server.parsers.ts delete mode 100644 packages/nuqs/src/index.server.serializer.ts create mode 100644 packages/nuqs/src/index.temporary-react-agnostic.ts diff --git a/packages/nuqs/package.json b/packages/nuqs/package.json index 9e7a21bb..4c97dd0e 100644 --- a/packages/nuqs/package.json +++ b/packages/nuqs/package.json @@ -68,14 +68,9 @@ "import": "./dist/server/cache.js", "require": "./esm-only.cjs" }, - "./server/serializer": { - "types": "./dist/server/serializer.d.ts", - "import": "./dist/server/serializer.js", - "require": "./esm-only.cjs" - }, - "./server/parsers": { - "types": "./dist/server/parsers.d.ts", - "import": "./dist/server/parsers.js", + "./server/temporary-react-agnostic": { + "types": "./dist/server/temporary-react-agnostic.d.ts", + "import": "./dist/server/temporary-react-agnostic.js", "require": "./esm-only.cjs" }, "./adapters/react": { diff --git a/packages/nuqs/server/README.md b/packages/nuqs/server/README.md index a64ea11c..6c226eba 100644 --- a/packages/nuqs/server/README.md +++ b/packages/nuqs/server/README.md @@ -3,7 +3,7 @@ Why just the cache here? Those "top-level" .d.ts files are used to help projects with `moduleResolution: 'node'` resolve the correct imports. -The other two imports under server, `nuqs/server/parsers` and `nuqs/server/serializer` -are temporary and will be removed in nuqs@3.0.0. +The other import under server, `nuqs/server/temporary-react-agnostic` +is temporary (as it says on the tin) and will be removed in nuqs@3.0.0. Also, nuqs@3.0.0 will require a `moduleResolution: 'bundler' | 'nodeNext` setting in your tsconfig.json. diff --git a/packages/nuqs/src/index.server.cache.ts b/packages/nuqs/src/index.server.cache.ts index e9967989..c7dd671c 100644 --- a/packages/nuqs/src/index.server.cache.ts +++ b/packages/nuqs/src/index.server.cache.ts @@ -1,2 +1 @@ export { createSearchParamsCache } from './cache' -export type { HistoryOptions, Nullable, Options, SearchParams } from './defs' diff --git a/packages/nuqs/src/index.server.parsers.ts b/packages/nuqs/src/index.server.parsers.ts deleted file mode 100644 index 2fc2d573..00000000 --- a/packages/nuqs/src/index.server.parsers.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { HistoryOptions, Nullable, Options, SearchParams } from './defs' -export * from './parsers' diff --git a/packages/nuqs/src/index.server.serializer.ts b/packages/nuqs/src/index.server.serializer.ts deleted file mode 100644 index e2c0411d..00000000 --- a/packages/nuqs/src/index.server.serializer.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { HistoryOptions, Nullable, Options, SearchParams } from './defs' -export { createSerializer } from './serializer' diff --git a/packages/nuqs/src/index.server.ts b/packages/nuqs/src/index.server.ts index 88b2ea34..6aa0ed55 100644 --- a/packages/nuqs/src/index.server.ts +++ b/packages/nuqs/src/index.server.ts @@ -1,11 +1,19 @@ -/** @deprecated Import createSearchParamsCache from 'nuqs/server/cache' instead. - * - * This export will be removed from 'nuqs/server' in nuqs@3.0.0, - * to allow non-Next.js server code to use the parsers, serializeres and other - * server-side utilities without depending on React canary for the `cache` function. - */ -export { createSearchParamsCache } from './cache' -export type { HistoryOptions, Nullable, Options, SearchParams } from './defs' +export { + /** @deprecated Import createSearchParamsCache from 'nuqs/server/cache' instead. + * + * This export will be removed from 'nuqs/server' in nuqs@3.0.0, + * to allow non-Next.js server code to use the parsers, serializeres and other + * server-side utilities without depending on React canary for the `cache` function. + */ + createSearchParamsCache +} from './cache' +export type { + HistoryOptions, + Nullable, + Options, + SearchParams, + UrlKeys +} from './defs' export { createLoader, type LoaderFunction, diff --git a/packages/nuqs/src/index.temporary-react-agnostic.ts b/packages/nuqs/src/index.temporary-react-agnostic.ts new file mode 100644 index 00000000..ce2da4f5 --- /dev/null +++ b/packages/nuqs/src/index.temporary-react-agnostic.ts @@ -0,0 +1,15 @@ +export type { + HistoryOptions, + Nullable, + Options, + SearchParams, + UrlKeys +} from './defs' +export { + createLoader, + type LoaderFunction, + type LoaderInput, + type LoaderOptions +} from './loader' +export * from './parsers' +export { createSerializer } from './serializer' diff --git a/packages/nuqs/src/index.ts b/packages/nuqs/src/index.ts index cf144973..d1ada984 100644 --- a/packages/nuqs/src/index.ts +++ b/packages/nuqs/src/index.ts @@ -1,4 +1,10 @@ -export type { HistoryOptions, Nullable, Options, SearchParams } from './defs' +export type { + HistoryOptions, + Nullable, + Options, + SearchParams, + UrlKeys +} from './defs' export { createLoader, type LoaderFunction, diff --git a/packages/nuqs/tsup.config.ts b/packages/nuqs/tsup.config.ts index 96bfb083..1b76c285 100644 --- a/packages/nuqs/tsup.config.ts +++ b/packages/nuqs/tsup.config.ts @@ -36,8 +36,7 @@ const entrypoints = { server: { server: 'src/index.server.ts', 'server/cache': 'src/index.server.cache.ts', - 'server/parsers': 'src/index.server.parsers.ts', - 'server/serializer': 'src/index.server.serializer.ts' + 'server/temporary-react-agnostic': 'src/index.temporary-react-agnostic.ts' } }