Skip to content

Commit

Permalink
Add default option to exports in package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 1, 2024
1 parent 9a03549 commit 7f11861
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/auto-import-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
},
"main": "./index.ts",
"module": "./index.ts",
"types": "./index.ts",
"publishConfig": {
"main": "./index.mjs",
"module": "./index.mjs",
"types": "./index.d.mts",
"exports": {
".": {
"types": "./index.d.mts",
"import": "./index.mjs"
"import": "./index.mjs",
"default": "./index.mjs"
}
},
"directory": "dist",
Expand Down
8 changes: 6 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"exports": {
".": {
"types": "./index.d.mts",
"import": "./index.mjs"
"import": "./index.mjs",
"default": "./index.mjs"
}
},
"directory": "dist",
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-helper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ 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) {
const fullPath = path.join(dir, entry.name);

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);
Expand Down

0 comments on commit 7f11861

Please sign in to comment.