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

Use cjs for commonjs exports #1825

Closed
wants to merge 2 commits into from
Closed

Use cjs for commonjs exports #1825

wants to merge 2 commits into from

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Jan 29, 2022

Fixes #1822

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 29, 2022

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 4e285a6:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

@shuding
Copy link
Member

shuding commented Jan 29, 2022

My only concern is if threre's some bundler that doesn't support extensions other than .js...

@huozhi
Copy link
Member Author

huozhi commented Jan 29, 2022

My only concern is if threre's some bundler that doesn't support extensions other than .js...

At least we need to move forward with the new standard. Now esm.js is the fallback for .mjs, and .js is the fallback for .cjs, containing all of them in the publish assets to fit the bundler whos don't support it is wired, which makes swr keep staying behind the new standard.

There's some bundler like metro (for RN) seems doesn't support cjs nor the exports field so far, and the issue is not updated. It's uncertain if they're going to support it or not (probably not).
However expo bundler supports them pretty well so it works if you play RN with expo.

One idea is to learn from RN community:

  • if there's any possibility to switch bundler?
  • how much the rough percentage is metro taking so far?

Then could propbably make better decisions to support it or drop it.

@shuding
Copy link
Member

shuding commented Jan 30, 2022

At least we need to move forward with the new standard.

I agree this is important, however we have to maintain backward compatibility as well, if possible. I'd personally choose "not broken" over "featureful".

@huozhi
Copy link
Member Author

huozhi commented Jan 30, 2022

Then maybe we could test with 3 extensions together js, esm.js, cjs, mj together for now. And decide a time to drop the esm.js and js together with announcement

@huozhi
Copy link
Member Author

huozhi commented Feb 5, 2022

Since it's the yarn 3 issue we can close the inproper fix

@huozhi huozhi closed this Feb 5, 2022
@huozhi huozhi deleted the fix/cjs branch February 5, 2022 18:45
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.

[Bug] 1.2.0 breaks Nextjs/Yarn 3 PnP/Zero Install
2 participants