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(clerk-react,remix,shared): Make exports.types the first key in exports #1835

Merged
merged 3 commits into from
Oct 6, 2023

Conversation

nikosdouvlis
Copy link
Member

@nikosdouvlis nikosdouvlis commented Oct 6, 2023

Description

The TypeScript docs recommends so, but it's also because the "exports" field is order-based.

For example, a scenario where both the "types" and "import" condition could be active, "types" should be first so that it matches and returns a .d.ts file, rather than a .js file from the "import" condition.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

@nikosdouvlis nikosdouvlis requested a review from a team as a code owner October 6, 2023 08:52
@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2023

🦋 Changeset detected

Latest commit: 3f560d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/shared Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
gatsby-plugin-clerk Patch
@clerk/nextjs Patch
@clerk/backend Patch
@clerk/clerk-js Patch
@clerk/fastify Patch
@clerk/clerk-sdk-node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

The TypeScript docs (https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing) recommends so, but it's also because the "exports" field is order-based.

For example, a scenario where both the "types" and "import" condition could be active, "types" should be first so that it matches and returns a .d.ts file, rather than a .js file from the "import" condition.
@nikosdouvlis nikosdouvlis changed the title fix(clerk-react,remix,shared): Move exports.types to the top fix(clerk-react,remix,shared): Make exports.types the first key in exports Oct 6, 2023
".": "./dist/index.js",
"./ssr.server": "./dist/ssr/index.js",
"./api.server": "./dist/api/index.js"
".": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anagstef @LekoArts
Could you please verify that this is correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looking at https://webpack.js.org/guides/package-exports/#conditional-syntax

The last condition in the object might be the special "default" condition, which is always matched.

I'm not 100% sure if we could use require here, but default seems like a safe bet for now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly - used default as it should mimic the exports behavior we had before. Thank you!

@nikosdouvlis nikosdouvlis enabled auto-merge October 6, 2023 11:41
@nikosdouvlis nikosdouvlis added this pull request to the merge queue Oct 6, 2023
Merged via the queue into main with commit 7636abc Oct 6, 2023
@nikosdouvlis nikosdouvlis deleted the nikos/JS-790 branch October 6, 2023 12:07
@clerk-cookie clerk-cookie mentioned this pull request Oct 6, 2023
@clerk-cookie
Copy link
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Oct 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants