immerjs / immer

Create the next immutable state by mutating the current one

Home Page:https://immerjs.github.io/immer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eliminate the `?.` operator for some lower-end devices.

wenerme opened this issue Β· comments

πŸš€ Feature Proposal

I want to use immer in wechat miniprogram, but the immer container ?. which is not supported.

Motivation

Just eliminate the ?. by config bundler ?

Can this be solved in user-land code?

Rebundle ?

Example

Immer 10 includes a legacy-esm build artifact that has been transpiled to ES2017, which includes removing any ?. uses. You'll want to configure your bundler to use that (via some kind of alias or resolution bundler config option):

https://unpkg.com/browse/immer@10.0.2/dist/immer.legacy-esm.js

@markerikson Thanks, but I use use-immer, which imports immer. I'll find out how to remap immer to legacy-esm.

Yes, that's my point. You'd need to configure your bundler so that any attempt to import "immer" actually imports "node_modules/immer/dist/immer.legacy-esm.js" instead.

Thanks, after pnpm patch, works as expected.

@wenerme what's the patch that fixed it?