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

Provide named exports, fixes #27 #37

Merged
merged 15 commits into from May 2, 2024

Conversation

broofa
Copy link
Contributor

@broofa broofa commented Apr 26, 2024

[Deleted previous description.]

Adds support for named exports. This is achieved by declaring all functions and constants as named exports, first, and then using them to compose the default object API.

All that other guff about ava and xo, etc... has been reverted. 😄

Fixes #27

@sindresorhus
Copy link
Owner

It's generally best to focus on the issue at hand and not cramp in lots of unrelated changes. I'm using XO and AVA in all my projects and I don't plan to remove them here. I also prefer keeping the default export to not break backwards compatibility, but also because I think it's a better API.

@broofa broofa changed the title (Refactor for 2024 - incomplete?): Switch to named exports, update test matrix, use node --test for testing, fixes #27 Provide named exports, fixes #27 Apr 26, 2024
@broofa
Copy link
Contributor Author

broofa commented Apr 26, 2024

@sindresorhus : Reverted all changes not essential to #27 . If you could take another look, that'd be great. If you're still not interested, go ahead and close I suppose. Cheers!

@sindresorhus
Copy link
Owner

You can use this trick to avoid having to specify the named exports manually for the default export: https://github.com/sindresorhus/query-string/blob/main/index.js

@sindresorhus
Copy link
Owner

You can use this trick to avoid having to specify the named exports manually for the default export: sindresorhus/query-string@main/index.js

Also for index.d.ts

@broofa
Copy link
Contributor Author

broofa commented Apr 29, 2024

@sindresorhus Updated the *.d.ts file to use the same index/base pattern. Note that this uses the "export * as default from '...'" pattern for the default export in index.d.ts. This was the only pattern that seemed to keep both TypeScript (in VSCode) from complaining, and also satisfy tsd in the unit test.

@sindresorhus sindresorhus merged commit d383ae1 into sindresorhus:main May 2, 2024
3 checks passed
@sindresorhus
Copy link
Owner

Thanks :)

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.

Named exports instead of default export?
2 participants