Skip to content

Add support for CJS files #12700

Open
Open
@fryorcraken

Description

@fryorcraken

Describe the bug

If a dependency contains a .cjs file, then said file is not processed by babel due to the default webpack config, meaning it will not be loaded.

Also, some cjs file are not excluded when needed: #11889

Did you try recovering your dependencies?

Tried but did not help

Which terms did you search for in User Guide?

CJS, ESM, commonjs

Environment

Environment Info:p@5.0.1
Ok to proceed? (y) y
  current version of create-react-app: 5.0.12c87c: timing idealTree:#root Completed in 1377ms
  running from /home/fryorcraken/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: Linux 5.18 Fedora Linux 36 (Workstation Edition)
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
  Browsers:
    Chrome: 104.0.5112.101
    Firefox: 103.0.2
  npmPackages:
    react: Not Found
    react-dom: Not Found
    react-scripts: Not Found
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

Use any npm package that contains *.cjs files.

Expected behavior

The .cjs files are correctly loaded and the functions, variable, classes, defined in them are available.

Actual behavior

The .cjs files notloaded and the functions, variable, classes, defined in them are undefined.

Reproducible demo

I don't believe this is necessary as there at least 5 PRs opened to fix this issue:

Related issues

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