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

Initial support for es module exports #1973

Closed

Conversation

belgattitude
Copy link
Contributor

@belgattitude belgattitude commented Oct 20, 2022

Do not merge yet. I'd like to add more ci tests. Dual packaging is hard when going into details.

Rework publishing iteration 1.

  • Add es module exports.
  • Keep dual packaging (and packaging hazards that comes along)

Why ?

It paves the way to:

  • Avoid duplicates instances of react-i18next in some situations (at least in the long run and esm only)
  • Prepare a shift to esm only. Warning: recent nextjs will work, not older ones. Jest is almost there, but there's probably a lot of old installs. So I'll try to keep a conservative approach
  • Explicitly declare subpaths

Version

Minor version. Should not break anything.

Risks

Dual packaging is always tricky. There's risks to add the exports field. Out of my mind (not exhaustive):

  • Typescript (< 4.9) still have issues when dealing with types and subpaths exports (like serverSideProps). Fixed by typeConfig
  • Older webpack consider the non-standard 'import' field (rather than modules), so I kept it there with comment

Next iterations

I'll detail soon. But I see a lot of potential for either size-reduction, either normalization. Other packages i18next, react-i18next will have to be updated too to bring full potential.

Size history

Before:

image

After:

No size regression

@belgattitude belgattitude changed the title chore(babel): move to babel.config in js (do not merge) Rework publishing iteration 1 Oct 20, 2022
@belgattitude belgattitude changed the title Rework publishing iteration 1 Rework publishing iteration 1 (do not merge) Oct 20, 2022
@@ -1,4 +1,10 @@
{
const browsersList = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to not expose yet the browsersList into package.json. In next pr iteration I'll probably move this.

},
"./package.json": "./package.json"
},
"typesVersions": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@belgattitude belgattitude changed the title Rework publishing iteration 1 (do not merge) Rework publishing iteration 1 (to be reviewed) Oct 21, 2022
@belgattitude
Copy link
Contributor Author

@adrai I've tested on few IDE and seems to work fine (at least with a recent typescript version)

It's a first step, I tried to not optimize the bundle yet and keep what did exists. On the user side it does not bring improvements (yet) but there's a slight possibility of issues.

2 options:

  • we merge it (so it will be included in v13) and I'll provide size-reduction on a 13.1. That way not everything is sent at the same time.
  • we keep here for a while.

@belgattitude belgattitude changed the title Rework publishing iteration 1 (to be reviewed) Initial support for es module exports Oct 21, 2022
@belgattitude
Copy link
Contributor Author

FYI: In a later step, I'd like to introduce rollup 3, completely rework/refresh the babel config, get real es modules (the current esm build is not)... Let me know the approach and if it's fine for you

@adrai
Copy link
Member

adrai commented Oct 21, 2022

I would wait for the feedback regarding the peer dep change first...
and then since it's a major we can release all together with v13...

@belgattitude
Copy link
Contributor Author

Redone in #1998

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.

None yet

2 participants