From 30e0711d7ce56169b23e57d2bb96448b38153baa Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Tue, 19 Nov 2024 16:22:20 +0100 Subject: [PATCH] fix exports --- package.json | 4 ++-- src/plugins/next-mocks/alias/headers/index.ts | 2 +- src/plugins/next-mocks/compatibility/compatibility-map.ts | 6 ++++-- tsup.config.ts | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index dcfd968..4a2bf61 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "./browser/mocks/legacy-image": "./dist/plugins/next-image/alias/next-legacy-image.js", "./browser/mocks/image-default-loader": "./dist/plugins/next-image/alias/image-default-loader.js", "./browser/mocks/image-context": "./dist/plugins/next-image/alias/image-context.js", - "./browser/mocks/draft-mode": "./dist/plugins/next-mocks/compatibility/draft-mode.compat.js", + "./browser/mocks/draft-mode.compat": "./dist/plugins/next-mocks/compatibility/draft-mode.compat.js", "./node/mocks/cache": "./dist/plugins/next-mocks/alias/cache/index.cjs", "./node/mocks/navigation": "./dist/plugins/next-mocks/alias/navigation/index.cjs", "./node/mocks/headers": "./dist/plugins/next-mocks/alias/headers/index.cjs", @@ -50,7 +50,7 @@ "./node/mocks/legacy-image": "./dist/plugins/next-image/alias/next-legacy-image.cjs", "./node/mocks/image-default-loader": "./dist/plugins/next-image/alias/image-default-loader.cjs", "./node/mocks/image-context": "./dist/plugins/next-image/alias/image-context.cjs", - "./node/mocks/draft-mode": "./dist/plugins/next-mocks/compatibility/draft-mode.compat.cjs" + "./node/mocks/draft-mode.compat": "./dist/plugins/next-mocks/compatibility/draft-mode.compat.cjs" }, "scripts": { "prepublishOnly": "pnpm build", diff --git a/src/plugins/next-mocks/alias/headers/index.ts b/src/plugins/next-mocks/alias/headers/index.ts index 464eac5..0a9c5b8 100644 --- a/src/plugins/next-mocks/alias/headers/index.ts +++ b/src/plugins/next-mocks/alias/headers/index.ts @@ -8,7 +8,7 @@ export { headers } from "./headers"; export { cookies } from "./cookies"; // re-exports of the actual module -export * from "next/dist/server/request/headers"; +export { UnsafeUnwrappedHeaders } from "next/dist/server/request/headers"; // passthrough mocks - keep original implementation but allow for spying const draftMode: Mock<() => ReturnType> = fn( diff --git a/src/plugins/next-mocks/compatibility/compatibility-map.ts b/src/plugins/next-mocks/compatibility/compatibility-map.ts index 6a6a7fc..67b528f 100644 --- a/src/plugins/next-mocks/compatibility/compatibility-map.ts +++ b/src/plugins/next-mocks/compatibility/compatibility-map.ts @@ -28,10 +28,12 @@ export const getCompatibilityAliases = (env: Env) => { const version = getNextjsVersion(); const result: Record = {}; + const compatMap = mapping(env); + // biome-ignore lint/complexity/noForEach: - Object.keys(mapping).forEach((key) => { + Object.keys(compatMap).forEach((key) => { if (semver.intersects(version, key)) { - Object.assign(result, mapping(env)[key]); + Object.assign(result, compatMap[key]); } }); diff --git a/tsup.config.ts b/tsup.config.ts index 38104a2..3983a72 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -17,7 +17,7 @@ export default defineConfig([ "src/plugins/next-mocks/alias/rsc/server-only.ts", "src/plugins/next-mocks/alias/dynamic/index.tsx", "src/mocks/storybook.global.ts", - "src/plugins/next-mocks/alias/compatibility/draft-mode.compat.ts", + "src/plugins/next-mocks/compatibility/draft-mode.compat.ts", ], splitting: false, clean: true,