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

fix(webpack-batteries-included-preprocessor): Disable loading babel config files #16980

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

chrisbreiding
Copy link
Contributor

@chrisbreiding chrisbreiding commented Jun 17, 2021

User facing changelog

  • Spec files now properly compile when there is a .babelrc or babel.config.json present in the project

Additional details

This disables loading .babelrc and babel.config.json in the default preprocessor. Since the default preprocessor can't anticipate per-user config, it's best for it to use its own config alone. Users that need custom configuration can utilize the preprocessor plugin API.

How has the user experience changed?

Preprocessing no longer fails when a project has a .babelrc or babel.config.json present. Users no longer need to add an empty .babelrc to the cypress directory as a workaround.

PR Tasks

  • Have tests been added/updated? No tests were directly added or updated, but by adding .babelrc and babel.config.json files to the project, most of the tests will fail without the fix.
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • N/A Has a PR for user-facing changes been opened in cypress-documentation?
  • N/A Have API changes been updated in the type definitions?
  • N/A Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 17, 2021

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Jun 17, 2021



Test summary

8158 0 103 3Flakiness 0


Run details

Project cypress
Status Passed
Commit 6aedc5b
Started Jun 17, 2021 2:07 PM
Ended Jun 17, 2021 2:18 PM
Duration 10:42 💡
OS Linux Debian - 10.8
Browser Multiple

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@flotwig
Copy link
Contributor

flotwig commented Jun 21, 2021

So this is blocking an unintended way that users were accidentally modifying the babel config, correct? Do users not want their babel config to apply to the webpack preprocessor?

From what I can see, the cause of #8364 is that webpack-batteries-included-preprocessor is resolving modules defined in .babelrc from the server's working directory, instead of from the user's project root. Would it also fix #8364 to somehow correct the module resolution for things configured in .babelrc?

I'm probably not totally understanding this, since I've not worked in webpack-batteries-included-preprocessor, so lmk if I'm missing something.

@chrisbreiding
Copy link
Contributor Author

The intention of this package is to provide the webpack configuration (the included batteries) and not need the user to configure it. While it's possible to customize the configuration when using this package directly, that isn't be needed in most circumstances and isn't particularly advocated. If a user needs custom configuration, we recommend they use the base webpack-preprocessor.

This package is what Cypress uses as the default preprocessor, and based on the reproductions in the issue, that's how users are running into this issue. They aren't using this package directly or trying to configure it. It's an unintentional side effect of babel loading these config files. The solution that seems to be accepted by a lot of users is to put an empty .babelrc in their cypress directory, which is essentially the same as not loading it at all.

While we could fix the issue with module resolution, I still think we would want to turn off loading babel config files in this package by default. Especially in its use as the default preprocessor, it could cause problems to load babel plugins on top of the ones we already have configured. Also, it's likely not the intention or expectation of the user to have their source code babel config loaded for their Cypress tests.

@flotwig
Copy link
Contributor

flotwig commented Jun 21, 2021

Alright, that makes sense, thank you for clarifying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants