Skip to content

esm uses process.node.env causing an error. #557

@mmulet

Description

@mmulet

🐛 Bug Report

When using immer.esm.js on browser. We get
Uncaught ReferenceError: process is not defined

<script type="module" src="./testESM.js"></script>
import { produce } from "https://unpkg.com/immer@6.0.2/dist/immer.esm.js";

Declaring the variable ahead of time fixes the issue.

<script>
  let process = {
    env: {
      NODE_ENV: "production"
    }
  };
</script>

Link to repro

Couldn't use code-sandbox because it wanted to import all modules as
node modules instead of as an esm module.
repo

To Reproduce

npm install . && npm test

Observed behavior

On import, throws
Uncaught ReferenceError: process is not defined

Expected behavior

Not throwing an exception

Environment

We only accept bug reports against the latest Immer version.

  • Immer version: latest
  • N/A Occurs with setUseProxies(true)
  • N/A Occurs with setUseProxies(false) (ES5 only)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions