From 499e6cb0a87070dfc3d4d70c4a27ec31c3451c4d Mon Sep 17 00:00:00 2001
From: Peter Knittl-Frank
Date: Wed, 26 Jul 2023 12:41:45 +0200
Subject: [PATCH] Update package.json - add types to exports
when changing moduleResolution from node to bundler (as in https://github.com/vercel/next.js/pull/51957/files#diff-066cacecd32e0ca72d47360ddb35c19a676835816eed05163e05564ec0874590)in tsconfig.json following errors occurs:
./pages/sitemap.xml/index.tsx:2:36
Type error: Could not find a declaration file for module 'next-sitemap'. 'C:/dev/frontend/project/node_modules/next-sitemap/dist/esm/index.js' implicitly has an 'any' type.
There are types at 'C:/dev/frontend/project/node_modules/next-sitemap/dist/@types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'next-sitemap' library may need to update its package.json or typings.
1 | import type { GetServerSideProps } from "next";
> 2 | import type { ISitemapField } from "next-sitemap";
The error can be fixed via copying the types to the exports "." section in package.json (as described here: https://stackoverflow.com/a/76212193/1548552)
---
packages/next-sitemap/package.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/packages/next-sitemap/package.json b/packages/next-sitemap/package.json
index 47959841..7834b0ca 100644
--- a/packages/next-sitemap/package.json
+++ b/packages/next-sitemap/package.json
@@ -8,7 +8,8 @@
"exports": {
".": {
"import": "./dist/esm/index.js",
- "require": "./dist/cjs/index.js"
+ "require": "./dist/cjs/index.js",
+ "types": "./dist/@types/index.d.ts"
}
},
"files": [