immerjs / immer

Create the next immutable state by mutating the current one
https://immerjs.github.io/immer/
MIT License
27.37k stars 846 forks source link

Options for older browser support in v10 (or continuing to use v9 somehow?) #1118

Open glenjamin opened 3 months ago

glenjamin commented 3 months ago

🙋‍♂ Question

I'm currently working on upgrading to RTK 2.0 - which brings with it an upgrade to immer v10.

Our application needs to support older browsers like smart TVs which tend to bundle pretty old versions of chrome, so we continue to compile down to ES5.

Do I have any options for making this work?

I see that v10 dropped support for the ES5 fallback, but it's unclear to me whether I can use polyfills or a v9 override to get around this.

The FAQ entry is rather terse on this point: https://immerjs.github.io/immer/installation/#immer-on-older-javascript-environments

Link to repro

n/a

Environment

We only accept questions against the latest Immer version.

markerikson commented 3 months ago

Unfortunately this is the "price of progress" :) As tools modernize, they drop support for legacy platforms... and if you still have to support that legacy platform, you can end up stuck and not being able to update.

In this case, yeah, RTK 2.0 intentionally updates to Immer 10, and Immer 10 does not have the ES5 fallback support.

The biggest question is whether those old versions of Chrome have support for Proxies. If they do, then you could at least use Immer 10 and if necessary transpile packages in node_modules (Immer, RTK, etc) back to ES5 syntax.

If those versions of Chrome do not have Proxy support, then you would need to stick with Immer 9. At that point things get more complicated:

glenjamin commented 3 months ago

Thanks for the quick response!

I'm keen to adopt the selectors-in-slices model, it's a shame that brings with it a bunch of extra complications!

We have various possible plans for finally dropping support, but so far every issue we've run into has had a fairly cheap workaround.

The Smart TVs tend to be a bit mysterious about what they actually support, but I suspect most of them do actually support Proxy, so perhaps I'll get away with this.

Do you know if there are any intentional API changes between 9 and 10 aside from the ES5 compat flag?

Your second suggestion is pretty much what I had in mind to try. Even if there is a small difference I figure I can probably swap in a shim using either the bundler or npm to override.

I'll give this a whirl and report back, hopefully I'll have something that can be added to the docs

markerikson commented 3 months ago

Looking at https://github.com/immerjs/immer/releases/tag/v10.0.0 , I don't immediately see any other obvious API changes listed. Worth a shot!

mweststrate commented 3 months ago

Default export was removed, but that probably won't bite RTK, only direct default imports need to be updated

On Tue, 23 Apr 2024, 23:33 Mark Erikson, @.***> wrote:

Looking at https://github.com/immerjs/immer/releases/tag/v10.0.0 , I don't immediately see any other obvious API changes listed. Worth a shot!

— Reply to this email directly, view it on GitHub https://github.com/immerjs/immer/issues/1118#issuecomment-2073494298, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBGST37MVEWUTKIWCJ3Y63HRVAVCNFSM6AAAAABGVMIFM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZTGQ4TIMRZHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>