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

redux-toolkit.legacy-esm.js not actually compatible with Webpack 4 due to optional chaining #4282

Closed
Zacqary opened this issue Mar 20, 2024 · 3 comments · Fixed by #4284
Closed
Labels
bug Something isn't working

Comments

@Zacqary
Copy link

Zacqary commented Mar 20, 2024

Upgrading to Redux Toolkit 2.x on a Webpack 4 repo fails due to this line:

if (cache?.has(value))

Webpack 4 doesn't support optional chaining without some additional plugins that can break many large projects. Is it possible to switch back to the pre-2.x transpiling method for the legacy build?

@markerikson
Copy link
Collaborator

markerikson commented Mar 20, 2024

Yeah, you're right, that's not getting transpiled properly - that build should have optional chaining being compiled away.

......

whoa. That's clearly not right:

  // ESM, embedded `process`: fallback for Webpack 4,
  // which doesn't support `exports` field or optional chaining
  {
    format: 'esm',
    name: 'legacy-esm',
    target: 'esnext',
    minify: false,
    env: '',
  },

That should be target: 'es2017'.

I can try to fix that this evening.

Actually rather surprised no one reported this yet.

@Zacqary
Copy link
Author

Zacqary commented Mar 20, 2024

Actually rather surprised no one reported this yet.

I guess this is useful data on how many codebases still on Webpack 4 are trying to upgrade Redux (not many).

Thanks for the quick response!

@markerikson
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants