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

Support es modules #1998

Closed
wants to merge 8 commits into from

Conversation

belgattitude
Copy link
Contributor

@belgattitude belgattitude commented Oct 26, 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)
  • Decrease size-limits to account for new peer-deps (treeshakes)

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:

Route (pages)                              Size     First Load JS
┌ ● /                                      1.08 kB        97.9 kB
├   /_app                                  0 B            94.6 kB
├ ○ /[40](https://github.com/i18next/next-i18next/actions/runs/3330057611/jobs/5508051889#step:8:41)4                                   181 B          94.8 kB
└ λ /second-page                           799 B          97.7 kB
+ First Load JS shared by all              94.6 kB
  ├ chunks/framework-3b5a00d5d7e8d93b.js   [45](https://github.com/i18next/next-i18next/actions/runs/3330057611/jobs/5508051889#step:8:46).4 kB
  ├ chunks/main-2b5cf5964c9408ce.js        26.5 kB
  ├ chunks/pages/_app-6e90689c67c1aa69.js  22 kB
  └ chunks/webpack-8fa1640cc84ba8fe.js     750 B

After:

Route (pages)                              Size     First Load JS
┌ ● /                                      1.08 kB        97.9 kB
├   /_app                                  0 B            94.6 kB
├ ○ /[40](https://github.com/i18next/next-i18next/actions/runs/3330057611/jobs/5508051889#step:8:41)4                                   181 B          94.8 kB
└ λ /second-page                           799 B          97.7 kB
+ First Load JS shared by all              94.6 kB
  ├ chunks/framework-3b5a00d5d7e8d93b.js   [45](https://github.com/i18next/next-i18next/actions/runs/3330057611/jobs/5508051889#step:8:46).4 kB
  ├ chunks/main-2b5cf5964c9408ce.js        26.5 kB
  ├ chunks/pages/_app-6e90689c67c1aa69.js  22 kB
  └ chunks/webpack-8fa1640cc84ba8fe.js     750 B

No regressions

@socket-security
Copy link

socket-security bot commented Nov 5, 2022

Socket Security Pull Request Report

👍 No new dependency issues detected in pull request

Pull request report summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script confusion ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Non-existent author ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues
Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@2.4.2

Powered by socket.dev

@stale
Copy link

stale bot commented Nov 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2022
@belgattitude
Copy link
Contributor Author

Not stale

@stale stale bot closed this Nov 22, 2022
@adrai adrai reopened this Nov 23, 2022
@adrai adrai removed the stale label Nov 23, 2022
@stale
Copy link

stale bot commented Dec 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 16, 2022
@stale stale bot closed this Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants