fix(clerk-react,remix,shared): Make exports.types the first key in exports - #1835
Conversation
🦋 Changeset detectedLatest commit: 3f560d3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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.
aeaa44a to
801a892
Compare
exports.types to the topexports.types the first key in exports
| ".": "./dist/index.js", | ||
| "./ssr.server": "./dist/ssr/index.js", | ||
| "./api.server": "./dist/api/index.js" | ||
| ".": { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Exactly - used default as it should mimic the exports behavior we had before. Thank you!
|
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. |
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 testruns as expected.npm run buildruns as expected.Type of change
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-extensiongatsby-plugin-clerkbuild/tooling/chore