create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Add support for CJS files

Open fryorcraken opened this issue 3 years ago • 0 comments

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: https://github.com/facebook/create-react-app/issues/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:[email protected]
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:

  • https://github.com/facebook/create-react-app/pull/12605
  • https://github.com/facebook/create-react-app/pull/12578
  • https://github.com/facebook/create-react-app/pull/12021
  • https://github.com/facebook/create-react-app/pull/11674
  • https://github.com/facebook/create-react-app/pull/12352

fryorcraken avatar Sep 02 '22 02:09 fryorcraken