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

[RTK Alpha]: Is ESNext output for all modules intended? #3210

Closed
rschristian opened this issue Feb 25, 2023 · 2 comments
Closed

[RTK Alpha]: Is ESNext output for all modules intended? #3210

rschristian opened this issue Feb 25, 2023 · 2 comments
Milestone

Comments

@rschristian
Copy link
Contributor

rschristian commented Feb 25, 2023

At the moment, all output files seem to be targeting esnext, which limits the support to the past couple years at a maximum. Fair enough if this was intended, but thought I'd ask, as there's a few comments in the build script which seem to indicate the idea (for the ESM at least) was to target ES2017:

// ESM, embedded `process`, ES2017 syntax: modern Webpack dev

For example, here's the CJS output with optional chaining, an ES2020 feature: https://www.runpkg.com/?@reduxjs/toolkit@2.0.0-alpha.2/dist/cjs/redux-toolkit.cjs.development.js#1097

Edit: Generally, for maximum compatibility, you'd want to limit the output to ES2017 and only provide that via "exports". There's no guarantees that something consuming "main" or "module" can consume ES2017+.

Edit2: I know optional chaining in particular will trip Webpack 4's parser, so users would need to make sure rtk is transpiled (which is very possible, of course): webpack/webpack#10227

@markerikson markerikson added this to the 2.0 milestone Feb 25, 2023
@markerikson
Copy link
Collaborator

Yeah, the comments need to be updated there.

And yes, my intent is to ship 100% modern syntax with no transpiling if at all possible, and have it be up to users to transpile if their own build system / target app environment needs it:

https://github.com/reduxjs/redux-toolkit/releases/tag/v2.0.0-alpha.0

That said, yeah, the Webpack 4 situation is the one thing that would make me hesitate slightly. I've been debating whether the main/module artifacts ought to have that output limited.

@rschristian
Copy link
Contributor Author

Oh wow, nice! Apologies, Ididn't check the release notes there.

I think just about everyone using Webpack is happy to add babel-loader and/or a bit of custom config to tranpsile rtk if needed, so (IMO) that shouldn't hold you back too much.

Happy to close this / have this closed, wanted to avoid adding in another issue / PR if it was an accident as it'd easily get buried.

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

No branches or pull requests

2 participants