Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@cypress/react/plugins/babel doesn't work in a monorepo #16596

Closed
penx opened this issue May 19, 2021 · 2 comments
Closed

@cypress/react/plugins/babel doesn't work in a monorepo #16596

penx opened this issue May 19, 2021 · 2 comments
Labels
npm: @cypress/react @cypress/react package issues

Comments

@penx
Copy link
Contributor

penx commented May 19, 2021

Current behavior

If you import @cypress/react/plugins/babel in your cypress code in a package in a monorepo, and runyarn cypress open-ct, it doesn't resolve the babel config from the monorepo route and throws an error:

ERROR in ./src/index.test.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: ./packages/example-application/src/index.test.js: Support for the experimental syntax 'jsx' isn't currently enabled (6:9):

This is due to babel not searching upwards for the babel config by default.

Desired behavior

Babel should be configurable to search upwards in a monorepo to find the babel config.

As explained here:

https://babeljs.io/docs/en/config-files#monorepos

        loader: 'babel-loader',
        options: {
          rootMode: "upward",
        },

rootMode: "upward" needs to be optionally specified in getBabelWebpackConfig.

I will open a PR to allow this to be sent via a config option.

Test code to reproduce

https://github.com/govuk-react/govuk-react/tree/c7aea92bec8d5d6b0c65a6cb821ddf60cfb11233

Versions

"@cypress/react": "^5.7.0",
"@cypress/webpack-dev-server": "^1.3.0",
"cypress": "^7.3.0",
penx added a commit to penx/cypress that referenced this issue May 19, 2021
Allow babel loader options to be configurable to support running within a monorepo.

Fixes cypress-io#16596
@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label May 19, 2021
@lmiller1990 lmiller1990 added the npm: @cypress/react @cypress/react package issues label May 20, 2021
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs review The PR code is done & tested, needs review stage: work in progress labels May 20, 2021
lmiller1990 added a commit that referenced this issue May 21, 2021
* Allow babel loader options to be configurable

Allow babel loader options to be configurable to support running within a monorepo.

Fixes #16596

* new configuration option in cypress.schema.json

* Revert "new configuration option in cypress.schema.json"

This reverts commit 0a39322.

* support custom webpack configuration via config function

* fix linting issue

* Update getBabelWebpackConfig.js

* linting

Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 21, 2021

The code for this is done in cypress-io/cypress#16597, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label May 21, 2021
@lmiller1990
Copy link
Contributor

It's out in cypress/react 5.8.0.

Brookke pushed a commit to Brookke/cypress that referenced this issue May 22, 2021
* Allow babel loader options to be configurable

Allow babel loader options to be configurable to support running within a monorepo.

Fixes cypress-io#16596

* new configuration option in cypress.schema.json

* Revert "new configuration option in cypress.schema.json"

This reverts commit 0a39322.

* support custom webpack configuration via config function

* fix linting issue

* Update getBabelWebpackConfig.js

* linting

Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
pashidlos pushed a commit to pashidlos/cypress that referenced this issue May 24, 2021
* Allow babel loader options to be configurable

Allow babel loader options to be configurable to support running within a monorepo.

Fixes cypress-io#16596

* new configuration option in cypress.schema.json

* Revert "new configuration option in cypress.schema.json"

This reverts commit 0a39322.

* support custom webpack configuration via config function

* fix linting issue

* Update getBabelWebpackConfig.js

* linting

Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm: @cypress/react @cypress/react package issues
Projects
None yet
Development

No branches or pull requests

3 participants