From 7f11861ed93c227d51790dd2b1009d80eaa91df9 Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Fri, 1 Nov 2024 06:06:39 +0000 Subject: [PATCH] Add `default` option to exports in package.json --- packages/auto-import-resolver/package.json | 4 +++- packages/core/package.json | 8 ++++++-- packages/metadata/package.json | 3 ++- scripts/build-helper.mjs | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/auto-import-resolver/package.json b/packages/auto-import-resolver/package.json index cf6ee16c3..42bec241c 100644 --- a/packages/auto-import-resolver/package.json +++ b/packages/auto-import-resolver/package.json @@ -15,6 +15,7 @@ }, "main": "./index.ts", "module": "./index.ts", + "types": "./index.ts", "publishConfig": { "main": "./index.mjs", "module": "./index.mjs", @@ -22,7 +23,8 @@ "exports": { ".": { "types": "./index.d.mts", - "import": "./index.mjs" + "import": "./index.mjs", + "default": "./index.mjs" } }, "directory": "dist", diff --git a/packages/core/package.json b/packages/core/package.json index 633ed000b..7f386c42b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -14,6 +14,7 @@ "url": "https://github.com/primefaces/primevue/issues" }, "main": "./src/index.js", + "module": "./src/index.js", "types": "./src/index.d.ts", "exports": { "./api": "./src/api/Api.js", @@ -31,15 +32,18 @@ }, "publishConfig": { "main": "./index.mjs", + "module": "./index.mjs", "types": "./index.d.ts", "exports": { ".": { "types": "./index.d.ts", - "import": "./index.mjs" + "import": "./index.mjs", + "default": "./index.mjs" }, "./*": { "types": "./*/index.d.ts", - "import": "./*/index.mjs" + "import": "./*/index.mjs", + "default": "./*/index.mjs" } }, "directory": "dist", diff --git a/packages/metadata/package.json b/packages/metadata/package.json index 79981b47d..51849e995 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -23,7 +23,8 @@ "exports": { ".": { "types": "./index.d.mts", - "import": "./index.mjs" + "import": "./index.mjs", + "default": "./index.mjs" } }, "directory": "dist", diff --git a/scripts/build-helper.mjs b/scripts/build-helper.mjs index 41e3f29db..4e7774e7a 100644 --- a/scripts/build-helper.mjs +++ b/scripts/build-helper.mjs @@ -76,7 +76,7 @@ export function copyDependencies(inFolder, outFolder, subFolder) { }); } -export async function renameDTSFile(dir, newName) { +export async function renameDTSFile(dir, newName, resolver) { const entries = await fs.readdir(dir, { withFileTypes: true }); for (const entry of entries) { @@ -84,7 +84,7 @@ export async function renameDTSFile(dir, newName) { if (entry.isDirectory()) { await renameDTSFile(fullPath, newName); - } else if (entry.name.endsWith('.d.ts')) { + } else if (entry.name.endsWith('.d.ts') && (resolver?.(entry.name, dir) ?? true)) { const newFullPath = path.join(dir, `${newName}.d.ts`); await fs.rename(fullPath, newFullPath);