From 464506b82296248647a153e0199a21073ed8e09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Best?= Date: Wed, 23 Oct 2024 13:25:10 +0200 Subject: [PATCH] fix: Add stub CJS exports for old ESLint plugins (#701) Closes #691. --- packages/nuqs/esm-only.cjs | 9 +++++++++ packages/nuqs/package.json | 33 ++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 packages/nuqs/esm-only.cjs diff --git a/packages/nuqs/esm-only.cjs b/packages/nuqs/esm-only.cjs new file mode 100644 index 00000000..a5f63c64 --- /dev/null +++ b/packages/nuqs/esm-only.cjs @@ -0,0 +1,9 @@ +// ESM only manifesto: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c + +// This stub file was added to let some old ESLint plugins resolve +// the import paths correctly, as setting exports.*.require: null in package.json didn't work. + +throw new Error( + `This package is ESM only. + See https://github.com/47ng/nuqs/issues/691 for more details.` +) diff --git a/packages/nuqs/package.json b/packages/nuqs/package.json index 7149d793..8633b556 100644 --- a/packages/nuqs/package.json +++ b/packages/nuqs/package.json @@ -40,7 +40,8 @@ "adapters/remix.d.ts", "adapters/react-router.d.ts", "adapters/custom.d.ts", - "adapters/testing.d.ts" + "adapters/testing.d.ts", + "esm-only.cjs" ], "type": "module", "sideEffects": false, @@ -49,43 +50,53 @@ "exports": { ".": { "types": "./dist/index.d.ts", - "import": "./dist/index.js" + "import": "./dist/index.js", + "require": "./esm-only.cjs" }, "./server": { "types": "./dist/server.d.ts", - "import": "./dist/server.js" + "import": "./dist/server.js", + "require": "./esm-only.cjs" }, "./adapters/react": { "types": "./dist/adapters/react.d.ts", - "import": "./dist/adapters/react.js" + "import": "./dist/adapters/react.js", + "require": "./esm-only.cjs" }, "./adapters/next": { "types": "./dist/adapters/next.d.ts", - "import": "./dist/adapters/next.js" + "import": "./dist/adapters/next.js", + "require": "./esm-only.cjs" }, "./adapters/next/app": { "types": "./dist/adapters/next/app.d.ts", - "import": "./dist/adapters/next/app.js" + "import": "./dist/adapters/next/app.js", + "require": "./esm-only.cjs" }, "./adapters/next/pages": { "types": "./dist/adapters/next/pages.d.ts", - "import": "./dist/adapters/next/pages.js" + "import": "./dist/adapters/next/pages.js", + "require": "./esm-only.cjs" }, "./adapters/remix": { "types": "./dist/adapters/remix.d.ts", - "import": "./dist/adapters/remix.js" + "import": "./dist/adapters/remix.js", + "require": "./esm-only.cjs" }, "./adapters/react-router": { "types": "./dist/adapters/react-router.d.ts", - "import": "./dist/adapters/react-router.js" + "import": "./dist/adapters/react-router.js", + "require": "./esm-only.cjs" }, "./adapters/custom": { "types": "./dist/adapters/custom.d.ts", - "import": "./dist/adapters/custom.js" + "import": "./dist/adapters/custom.js", + "require": "./esm-only.cjs" }, "./adapters/testing": { "types": "./dist/adapters/testing.d.ts", - "import": "./dist/adapters/testing.js" + "import": "./dist/adapters/testing.js", + "require": "./esm-only.cjs" } }, "scripts": {