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

feat: remove cjs support and raise language level to ESNext #963

Merged
merged 8 commits into from
Jan 4, 2023

Conversation

wesgro
Copy link
Contributor

@wesgro wesgro commented Oct 12, 2022

BREAKING CHANGE

All evergreen browsers fully support the ES6 spec (Even Safari as of Safari 10)

Generating ES5 compliant code introduces unnecessary language polyfills that can bloat bundles and possibly create warnings in rollup (no top level this for example).

Since this library supports React 18 and React 18 no longer supports IE 11 this seems like a good time to raise the floor of the non-ESNext generated code.

If users of this library need to support IE 11 still they can always include this library in their babel config to transpile it down to whatever ES version they need to support.

Fixes #962

@ArttuOll
Copy link
Contributor

ArttuOll commented Oct 14, 2022

I find your reasoning to be sound. ES6 indeed is massively supported.

The only thing that worries me is this statement from the browserlist repo:

Don’t remove browsers just because you don’t know them. Opera Mini has 100 million users in Africa and it is more popular in the global market than Microsoft Edge.

I was able to confirm the 100 million users from the Opera Mini site.

It happens to be the case that Opera Mini does not support ES6. If this change was made, all the developers developing for those 100 million users in Africa would have to transpile this library.

This is all just food for thought. In my opinion, this change would be good. Opera Mini should catch up and add support for ES6. I also checked a bunch of popular React libraries and frameworks (such as react-query and NextJS) and their TypeScript targets also seem to be either es6 or esnext.

What do you think @xobotyi?

@xobotyi
Copy link
Contributor

xobotyi commented Oct 15, 2022

I dont have a decision tbh.
As for my projects i transpile node_modules anyway, since i have to maintain compatibility with console browsers (which is complete mess tbh).

Im not able to imagine how many users pipelines that change would break.
I'd consider hanging it for a while, untill we'll clear all current issues and then make a major version with lang-level upgrade

@wesgro
Copy link
Contributor Author

wesgro commented Oct 15, 2022

Im not able to imagine how many users pipelines that change would break.

Would you be open to only the esm path using es6? ESM would only be in use by browsers that have es6 support already. the cjs path could remain in es5 form.

@JoeDuncko
Copy link
Contributor

Im not able to imagine how many users pipelines that change would break.

Would you be open to only the esm path using es6? ESM would only be in use by browsers that have es6 support already. the cjs path could remain in es5 form.

This sounds like a reasonable compromise to me. Anyone else?

@ArttuOll
Copy link
Contributor

Would you be open to only the esm path using es6? ESM would only be in use by browsers that have es6 support already. the cjs path could remain in es5 form.

Sounds like a really reasonable compromise to me as well.

@xobotyi
Copy link
Contributor

xobotyi commented Oct 23, 2022

I've reduced esnext version to module.
This patch will go as major version as it breaks backwards compatibility. (but is highly doubdt that someone used esnext version =))

It will be slow step forward to fix of #659 and switching to type: "module"

@wesgro
Copy link
Contributor Author

wesgro commented Nov 10, 2022

I see a few breaking changes have gone through, is there a plan for this to get in soon?

@xobotyi
Copy link
Contributor

xobotyi commented Nov 10, 2022

Yes, as soon as we figure current backlog

@xobotyi
Copy link
Contributor

xobotyi commented Nov 10, 2022

*current backlog before this pr

@ArttuOll
Copy link
Contributor

ArttuOll commented Dec 3, 2022

Yes, as soon as we figure current backlog

@xobotyi On our issues list there's currently pretty much nothing in addition to this that we would need to act on. There's open PR's but I don't think any of them are ready to be merged in a while, except for the documentation PRs. Would now be the time to tackle this PR?

@xobotyi
Copy link
Contributor

xobotyi commented Dec 4, 2022

yup - i've planned to handle it on tuesday

@xobotyi
Copy link
Contributor

xobotyi commented Jan 2, 2023

Im thinking of making one more step further and leave only one version - esm, with esnext langlevel.

A bit harsh move, but we'll have make it anyway as we will have to move to module package once infrastructure will be ready. All major bundlers handles module dependencies perfectly.

I'll update this pr now, and leave it here for a couple of days. planned date of merge is 4th Jan.

@wesgro @ArttuOll @JoeDuncko

@xobotyi xobotyi changed the title feat!: raises the target floor for compiled Javascript to ES6 feat: remove cjs support and raise language level to ESNext Jan 2, 2023
@xobotyi
Copy link
Contributor

xobotyi commented Jan 2, 2023

the only downsite - had to temporarily disable built bundle testing due to issue with jest: jestjs/jest#13715

@wesgro
Copy link
Contributor Author

wesgro commented Jan 2, 2023

@xobotyi Would it be possible to retain cjs support? Although many modern bundlers have support there are probably a tonne of legacy bundlers still in use that would need a CJS path (I say greedily, as I have to deal with one of them 😜 )

@xobotyi
Copy link
Contributor

xobotyi commented Jan 2, 2023

Which one? 🤔

@wesgro
Copy link
Contributor Author

wesgro commented Jan 2, 2023

I believe we still have something using webpack 3 and requires us to ship CJS or they can't use our library. They're a different team from us so them changing their build for our teams' needs probably isn't something that will get on their road map any time soon.

Not the end of the world since I could opt to bundle this code when we ship CJS, but not completely ideal either.

@xobotyi
Copy link
Contributor

xobotyi commented Jan 2, 2023

But you have to transpile node_modules anyway, since many tools coming esm only🤔

As for me - I'd cut everything in one move, since it will ease further support and future moving to type: module

@wesgro
Copy link
Contributor Author

wesgro commented Jan 2, 2023 via email

wesgro and others added 7 commits January 4, 2023 12:53
BREAKING CHANGE

All evergreen browsers fully support the ES6 spec (Even Safari as of Safari 10)

Generating ES5 compliant code introduces unnecessary language polyfills that can bloat bundles and possibly create warnings in rollup (no top level this for example).

Since this library supports React 18 and React 18 no longer supports IE 11 this seems like a good time to raise the floor of the non-ESNext generated code.

If users of this library need to support IE 11 still they can always include this library in their babel config to transpile it down to whatever ES version they need to support.
BREAKING CHANGE: remove esnext version, now esmodules serves es esnext
version.
Make use of SWC - it drastically improves tests performance.

Bundle build still performed with ts though.
@xobotyi xobotyi merged commit 477853a into react-hookz:master Jan 4, 2023
xobotyi pushed a commit that referenced this pull request Jan 4, 2023
BREAKING CHANGE: `CJS ES5` and `ESM ES5` versions are removed from distribution, leaving only `ESM ESNext` version.

We understand that this change can break existing pipelines for some developers, but such move eases library maintenance and is one of several moves towards module package.

This change is one of several braking changes that will be released under same major version regarding changes in distribution and importing.

Sorry for any inconvenience.
github-actions bot pushed a commit that referenced this pull request Jan 4, 2023
# [21.0.0](v20.1.0...v21.0.0) (2023-01-04)

### Features

* **no-release:** drop es5 versions support, leave only ESNext ([#963](#963)) ([5a622af](5a622af))

### BREAKING CHANGES

* **no-release:** `CJS ES5` and `ESM ES5` versions are removed from distribution, leaving only `ESM ESNext` version.

We understand that this change can break existing pipelines for some developers, but such move eases library maintenance and is one of several moves towards module package.

This change is one of several braking changes that will be released under same major version regarding changes in distribution and importing.

Sorry for any inconvenience.
@xobotyi
Copy link
Contributor

xobotyi commented Jan 5, 2023

@wesgro in closest release CJS version will be returned🙃

@wesgro
Copy link
Contributor Author

wesgro commented Jan 5, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Raise the cjs and esm target to es6
4 participants