instrument-cra
instrument-cra copied to clipboard
Yarn workspace support requires hoisted react-scripts
In #63 there was support added for yarn workspaces.
Unfortunately this requires react-scripts
to be be hoisted to the workspace root to work.
In our case, we explicitly opted out of hoisting (no-hoisted) react-scripts
, because we have multiple versions of react-scripts
in our repo. instrument-cra
worked flawlessly, up until we remove the hoisted version (which mismatched in some projects). So instrument-cra
might also currently instrument a different webpack.config.js
than CRA actually uses.
IMHO the code should be adopted to the following:
- search for
cypressWebpackConfigPath
at the following locations in this order:- current package
- workspace root
- if
cypressWebpackConfigPath
is not defined, look forwebpack.config.js
at the following locations:-
<current package>/node_modules/react-scripts/config/webpack.config.js
-
<workspace root>/node_modules/react-scripts/config/webpack.config.js
-
I'm experiencing the same issue. I even set the cypressWebpackConfigPath
in my package.json
, but it still won't load. Shows as "undefined" in the verbose logging. It's looking for the webpack config in the root, not in my sub-project in our monorepo
❯ yarn start
instrument-cra finding webpack config { workspaceRoot: '/Users/cjackson/Documents/coil', cypressWebpackConfigPath: undefined } +0ms
instrument-cra path to react-scripts own webpack.config.js: /Users/cjackson/Documents/coil/node_modules/react-scripts/config/webpack.config.js +3ms
node:internal/modules/cjs/loader:949
throw err;
^
Error: Cannot find module '/Users/cjackson/Documents/coil/node_modules/react-scripts/config/webpack.config.js'
R