#991·rematch

immerPlugin of @rematch/immer doesn't work

Author: frontend-is-magicCreated Jul 12, 2024Updated Jul 13, 2024

Describe the bug

Cannot use immerPlugin of @rematch/immer

To Reproduce

  1. Create a vite-react project
  2. Install packages using yarn add @reduxjs/toolkit react-redux @rematch/core immer @rematch/immer
  3. Follow steps in Getting Started - Installation and Plugins - @rematch/immer of Rematch official website
  4. Input your codes like:
javascript
import {init} from "@rematch/core"
import {count} from './models.js'
import immerPlugin from "@rematch/immer"

const store = init({models: {count}, plugins: [immerPlugin()]})
export default store
  1. You will see error logs as follow:
✘ [ERROR] No matching export in "node_modules/immer/dist/immer.mjs" for import "default"

    node_modules/@rematch/immer/dist/immer.esm.js:1:7:
      1 │ import produce from 'immer';
        ╵        ~~~~~~~

6:35:08 PM [vite] error while updating dependencies:
Error: Build failed with 1 error:
node_modules/@rematch/immer/dist/immer.esm.js:1:7: ERROR: No matching export in "node_modules/immer/dist/immer.mjs" for import "default"
    at failureErrorWithLog (/Users/myName/WebstormProjects/rematch-demo/node_modules/esbuild/lib/main.js:1472:15)
    at /Users/myName/WebstormProjects/rematch-demo/node_modules/esbuild/lib/main.js:945:25
    at /Users/myName/WebstormProjects/rematch-demo/node_modules/esbuild/lib/main.js:1353:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Expected behavior

where it comes fromerror-log

Desktop

  • macOS
  • chrome

Additional context