Skip to content

Use ESM build in modern browser (<script type="module" ...>) #631

Closed
@mmulet

Description

@mmulet

Current Behavior

babel-plugin-dev-expression replaces all instances of __DEV__ with process.env.NODE_ENV !== 'production'. As the process variable may not be available outside of nodejs, it introduces an incompatibility with modern browsers.

Suggested solution(s)

There are several different ways we could approach fixing this:

  1. Add an option to tsdx.config.js that allows users to opt out of babel-plugin-dev-expression, or replace with a different plugin.
  2. Replace babel-plugin-dev-expression with another plugin that works in both browser and nodejs environments. I made a quick fork of babel-plugin-dev-expression that does just that.

Additional context

Affects these issues:
immer
an open issue in
babel-plugin-dev-expression

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: featureNew feature or requestsolution: intended behaviorThis is not a bug and is expected behaviorsolution: unresolvedIssue has been closed by OP but root cause has not necessarily been resolvedsolution: workaround availableThere is a workaround available for this issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions