I made a package with a macro.cjs file, that added to package.json:exports, please note package.json has type: module.
Describe the bug
I got an error:
Cannot find module '@effector/patronum/macro' from '/home/runner/work/patronum/patronum/integration/cra/src'
Require stack:
src/App.js
src/App.test.js
However, Jest was able to find:
'./demo.test.ts'
'./demo.ts'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
I checked up babel-plugin-macros has support for .cjs macros: https://github.com/kentcdodds/babel-plugin-macros/blob/master/src/index.js#L5
Did you try recovering your dependencies?
Yep
Which terms did you search for in User Guide?
Environment
Environment Info:
current version of create-react-app: 4.0.3
running from /Users/sova/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: macOS 11.5.2
CPU: (8) arm64 Apple M1
Binaries:
Node: 16.5.0 - ~/.nvm/versions/node/v16.5.0/bin/node
Yarn: 1.22.11 - ~/.nvm/versions/node/v16.5.0/bin/yarn
npm: 7.19.1 - ~/.nvm/versions/node/v16.5.0/bin/npm
Browsers:
Chrome: 94.0.4606.81
Edge: Not Found
Firefox: 90.0.2
Safari: 14.1.2
npmPackages:
react: ^17.0.1 => 17.0.2
react-dom: ^17.0.1 => 17.0.2
react-scripts: ^4.0.3 => 4.0.3
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
Also, I made an integration test for CRA:
- I publish the package to the GitHub registry
- Installed it to the app based on CRA
- Ran tests on file
Expected behavior
CRA should load macro with .cjs extension from another package.
Actual behavior

Reproducible demo
https://github.com/effector/patronum/tree/main/integration/cra/src
https://github.com/effector/patronum/runs/3848203844
I can't change .cjs to .js in type:module, because module system will think it is ESModule in .js file.

But CRA doesn't allow me to import macro.cjs
I made a package with a
macro.cjsfile, that added topackage.json:exports, please note package.json hastype: module.Describe the bug
I got an error:
I checked up babel-plugin-macros has support for
.cjsmacros: https://github.com/kentcdodds/babel-plugin-macros/blob/master/src/index.js#L5Did you try recovering your dependencies?
Yep
Which terms did you search for in User Guide?
Environment
Steps to reproduce
Also, I made an integration test for CRA:
Expected behavior
CRA should load macro with .cjs extension from another package.
Actual behavior
Reproducible demo
https://github.com/effector/patronum/tree/main/integration/cra/src
https://github.com/effector/patronum/runs/3848203844
I can't change
.cjsto.jsintype:module, because module system will think it is ESModule in.jsfile.But CRA doesn't allow me to import
macro.cjs