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 exports field #5626

Merged
merged 2 commits into from
May 3, 2023
Merged

Fix exports field #5626

merged 2 commits into from
May 3, 2023

Conversation

emmatown
Copy link
Collaborator

@emmatown emmatown commented May 2, 2023

closes #5595
closes #4859

The exports field added in #5559 was wrong in a few ways, arethetypeswrong explains this well:

🐛 Imports of all entrypoints under resolution modes that use the import condition in package.json "exports" resolved through a conditional package.json export, but only after failing to resolve through an earlier condition. This behavior is a TypeScript bug and should not be relied upon.

🚭 The implementation resolved at all entrypoints uses ESM syntax, but the detected module kind is CJS. This will be an error in Node (and potentially other runtimes and bundlers). The module kind was decided based on the nearest package.json’s lack of a "type": "module" field.

This PR makes react-select use Preconstruct's exports field feature which does things correctly, I've also checked the build output on this branch with arethetypeswrong and it reports no errors. Of note is that there is still no bundle for Node ESM, the .mjs file used when the import condition matches just re-exports from the CJS bundle but fixes the default export (this is new to Preconstruct and is what "importConditionDefaultExport": "default" is doing), the lack of a Node ESM bundle is intentional so the dual package hazard can't happen. Bundlers will use the module condition to still have ESM there. There is also intentionally no types condition, that's unnecessary because Typescript will resolve to the import or default conditions and use the .d.mts and .d.ts files next to the implementations.

@changeset-bot
Copy link

changeset-bot bot commented May 2, 2023

🦋 Changeset detected

Latest commit: 603bd7a

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

This PR includes changesets to release 1 package
Name Type
react-select 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

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 2, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 603bd7a:

Sandbox Source
react-codesandboxer-example Configuration

@emmatown emmatown marked this pull request as draft May 2, 2023 00:34
joshuahhh added a commit to engraftdev/engraft that referenced this pull request May 2, 2023
@emmatown emmatown marked this pull request as ready for review May 2, 2023 23:41
Copy link
Owner

@JedWatson JedWatson left a comment

Choose a reason for hiding this comment

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

Thanks @emmatown

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