Skip to content

Add exports to package.json - #5662

Closed
coolassassin wants to merge 1 commit into
styled-components:mainfrom
coolassassin:exports-fix
Closed

coolassassin wants to merge 1 commit into
styled-components:mainfrom
coolassassin:exports-fix

Conversation

@coolassassin

@coolassassin coolassassin commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

It is a redo for this PR

I have updated to the latest release, and my Vitest setup is failing again after this commit:
788e8c0

I have tried to reproduce the bug, which is described in the commit, but I have no results
Maybe only the second part of the fix is really necessary?

Also, I want to add that if we talk about these issue:
#5648
We can see that the issue has been present since 6.3.7.
But exports were added in 6.3.8

@changeset-bot

changeset-bot Bot commented Feb 10, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 11301b4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@quantizor quantizor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is needed — the `exports` field enables proper ESM/CJS resolution for modern bundlers. The condition ordering looks correct (react-native → browser → default).

A few notes for rebase:

  • Main has changed significantly since this was opened
  • The `exports` field previously caused TS2742 issues in composite projects — please verify with `tsc --composite` in a consuming project
  • Consider adding `"./package.json": "./package.json"` (already present in your diff, good)

Would welcome a rebase onto current main!

@quantizor

Copy link
Copy Markdown
Contributor

Closing — we've tried adding exports before and it caused TS2742 errors in composite TypeScript projects and module resolution ordering issues. The current main/module/browser field approach is the most compatible.

If you're hitting a specific resolution issue with a modern bundler, please open an issue with the exact error and bundler config so we can evaluate targeted fixes.

@quantizor quantizor closed this Mar 19, 2026
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.

2 participants