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: force Webpack to emit assets on error #23844

Merged
merged 11 commits into from
Sep 16, 2022

Conversation

astone123
Copy link
Contributor

@astone123 astone123 commented Sep 15, 2022

User facing changelog

Compile errors will now be surfaced in the command log during testing for Angular and Next projects

Additional details

Some frameworks (Angular and Next) configure Webpack to not emit assets that have errored. So, if there's a compile error during development in these projects, instead of serving the module that has the compilation error and throwing it, Webpack serves the successful asset from the previous build. The result is that the compilation error only appears in the console, and our command log and AUT look fine - as if nothing has happened.

This behavior is undesirable because if there is a compilation error, we want to fail the test and make the user aware. This PR adds emitOnErrors: true (noEmitOnErrors: false for Webpack 4) to our default Webpack configuration to override these values and force Webpack to emit modules even when there is an error regardless of the framework configuration.

Steps to test

  1. Revert my changes in makeDefaultWebpackConfig.ts
  2. Run the tests for angular.cy.ts and next.cy.ts in npm/webpack-dev-server
  3. Verify that the tests fail because errors do not appear in the command log when a compilation error is written to the component file
  4. Put the changes to makeDefaultWebpackConfig.ts back and repeat step 2
  5. Verify that the tests pass now and the errors appear in the command log as expected

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 15, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Sep 15, 2022



Test summary

4773 0 373 0Flakiness 1


Run details

Project cypress
Status Passed
Commit 0303a3b
Started Sep 16, 2022 6:54 PM
Ended Sep 16, 2022 7:09 PM
Duration 15:11 💡
OS Linux Debian - 11.3
Browser Electron 102

View run in Cypress Dashboard ➡️


Flakiness

cypress/e2e/e2e/origin/user_agent_override.cy.ts Flakiness
1 user agent override > persists modified user agent after cy.go

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

Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions, nice job!

Copy link
Contributor

@warrensplayer warrensplayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Just need to update the version of the watiForSpecToFinish command

npm/webpack-dev-server/cypress/e2e/angular.cy.ts Outdated Show resolved Hide resolved
},
devServerEvents: new EventEmitter(),
}
const actual = await makeWebpackConfig({
devServerConfig,
sourceWebpackModulesResult: createModuleMatrixResult({
webpack: 4,
webpack: 5,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 5, not 4, since webpack-dev-server v4 uses Webpack 5. Confused yet?

},
devServerEvents: new EventEmitter(),
}
const actual = await makeWebpackConfig({
devServerConfig,
sourceWebpackModulesResult: sourceDefaultWebpackDependencies(devServerConfig),
sourceWebpackModulesResult: createModuleMatrixResult({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this to use createModuleMatrixResult, because we claim to be testing webpack-dev-server v3 in this test, but the version of Webpack was getting resolved to v5, when it should be v4.

Copy link
Contributor

@warrensplayer warrensplayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@astone123 astone123 merged commit 466be9f into develop Sep 16, 2022
@astone123 astone123 deleted the astone123/webpack-force-emit branch September 16, 2022 20:43
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.

Projects for some frameworks don't surface compilation errors/warnings
5 participants