Estoy usando reactstrap@8.6.0 con nx y mecanografiado. Pero si se incluye algún componente de reactstrap, la aplicación se bloquea con el siguiente error
index.js:3 Uncaught ReferenceError: global is not defined at Object.../../../node_modules/has-symbols/index.js (index.js:3) at __webpack_require__ (bootstrap:79) at Object.../../../node_modules/get-intrinsic/index.js (index.js:54) at __webpack_require__ (bootstrap:79) at Object.../../../node_modules/call-bind/callBound.js (callBound.js:3) at __webpack_require__ (bootstrap:79) at Object.../../../node_modules/is-arguments/index.js (index.js:4) at __webpack_require__ (bootstrap:79) at Object.../../../node_modules/deep-equal/index.js (index.js:2) at __webpack_require__ (bootstrap:79) Como se sugiere aquí, probé la siguiente configuración en jest.config.js pero no tuve suerte.
module.exports = { name: 'cadence', preset: '../../jest.config.js', transform: { '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest', '^.+\\.[tj]sx?$': [ 'babel-jest', { cwd: __dirname, configFile: './babel-jest.config.json' }, ], }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], coverageDirectory: '../../coverage/apps/cadence', setupFilesAfterEnv: ['./jest.setup.js'], target: 'node', node: { global: true }, };Cualquier ayuda será muy apreciada.
Tuve un problema similar y lo resolví modificando la configuración del paquete web: agregue webpack.config.js a apps/your-react-app/webpack.config.js con:
const nrwlConfig = require('@nrwl/react/plugins/webpack.js'); module.exports = (config, context) => { nrwlConfig(config); return { ...config, node: { global: true, }, }; };