Skip to content

require('ts-pattern') not work on react-scripts 5 but work on react-scripts 4. #12725

Closed
@ChengOuyang

Description

@ChengOuyang

Describe the bug

const tsPattern = require('ts-pattern');

The tsPattern is a string but not a module on react-scripts 5, and other library is work.

Did you try recovering your dependencies?

(Write your answer here.)

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

(paste the output of the command here.)

Steps to reproduce

(Write your steps here:)

  1. npx create-react-app ts-pattern-test
  2. cd ts-pattern-test
  3. pnpm add ts-pattern
  4. code in src/index.js:
const tsPattern = require('ts-pattern');

Expected behavior

The tsPattern should be a module be return a string on react-scripts 5, and other library is work.

Actual behavior

(Write what happened. Please add screenshots!)

Reproducible demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions