Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reorder exports to set default last #488

Merged
merged 1 commit into from
Aug 8, 2022

Conversation

saibotsivad
Copy link
Contributor

@saibotsivad saibotsivad commented Aug 8, 2022

From #486 and the NodeJS docs, the default entry should always be last. Bug introduced in #484

For posterity, this is the code I used to fix this:

import { readdir, readFile, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
const ROOT = 'packages'
const dirs = await readdir(ROOT)
for (const dir of dirs) {
	const filepath = join(ROOT, dir, 'package.json')
	const pkg = JSON.parse(await readFile(filepath))
	const { default: d, ...remaining } = pkg.exports['.']
	pkg.exports['.'] = { ...remaining, default: d }
	writeFile(filepath, JSON.stringify(pkg, undefined, 2), 'utf8')
}

@angus-c
Copy link
Owner

angus-c commented Aug 8, 2022

thanks for the quick fix!

@angus-c angus-c merged commit 386d87d into angus-c:master Aug 8, 2022
angus-c pushed a commit that referenced this pull request Aug 8, 2022
@angus-c
Copy link
Owner

angus-c commented Aug 8, 2022

Applied to all packages and published as patch versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants