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

feat: support webpack-dev-server v5 in @cypress/webpack-dev-server #29306

Merged
merged 13 commits into from
Apr 18, 2024

Conversation

AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Apr 11, 2024

Additional details

This PR introduces support for webpack-dev-server v5 inside @cypress/webpack-dev-server.

To avoid a breaking change, @cypress/webpack-dev-server still ships with wds v4 by default. This PR allows v5 to be discovered and supported if a user has wds v5 installed in their project.

The configuration is almost identical to that of wds v4, but I elected to keep both separate as feature configuration could evolve with v5 and not with v4, allowing us flexibility by keeping these options separate.

I have also added some system tests to verify things work as expected with wds5 and webpack 5. wds 5 does not work with webpack 4, so I added a custom error message inside of @cypress/webpack-dev-server to alert the user if they are using wds5 and webpack 4, as the error thrown under the hood is not graceful nor obvious.

I have also added this as a feat for cypress as this @cypress/webpack-dev-server does ship with cypress by default.

Steps to test

How has the user experience changed?

PR Tasks

@AtofStryker AtofStryker marked this pull request as ready for review April 11, 2024 13:55
@AtofStryker
Copy link
Contributor Author

The changes in the network package have to do with types being installed in @cypress/webpack-dev-server which now installs the forge types and causes conflicts. Since we don't use the types in the network package and they are not compatible with the @types/node-forge package, I opted for a require to ignore the types

Copy link

cypress bot commented Apr 11, 2024

Passing run #54994 ↗︎

0 6027 142 0 Flakiness 0

Details:

Merge branch 'develop' into feat/support_wds5
Project: cypress Commit: f5fe6c1736
Status: Passed Duration: 15:30 💡
Started: Apr 18, 2024 2:50 PM Ended: Apr 18, 2024 3:06 PM

Review all test suite changes for PR #29306 ↗︎

@@ -180,11 +187,10 @@ export function sourceWebpack (config: WebpackDevServerConfig, framework: Source

// Source the webpack-dev-server module from the provided framework or projectRoot.
// If none is found, we fallback to the version bundled with this package.
export function sourceWebpackDevServer (config: WebpackDevServerConfig, framework?: SourcedDependency | null): SourcedWebpackDevServer {
export function sourceWebpackDevServer (config: WebpackDevServerConfig, webpackMajorVersion: 4 | 5, framework?: SourcedDependency | null): SourcedWebpackDevServer {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is 3 the version that is the fallback and why it isn't part of this webpackMajorVersion union here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

luckily for us we don't support webpack v3, only v4 and v5. But with this PR we would support webpack-dev-server v3, v4, and v5.

the package currently ships with webpack-dev-server v4 but will source whatever the user has installed

@jennifer-shehane
Copy link
Member

@AtofStryker Should we regard this as closed when this goes in? Or do we need some extra tests to verify on top of this? #29309

@AtofStryker
Copy link
Contributor Author

AtofStryker commented Apr 11, 2024

@AtofStryker Should we regard this as closed when this goes in? Or do we need some extra tests to verify on top of this? #29309

we need to officially support Angular 18 but this gets us a step closer. I was talking with @jordanpowell88 about this today and sounds like the scope of work isn't massive? i.e. we need some tests on top of it. The ones I know about are the system tests

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Apr 11, 2024

@AtofStryker
Copy link
Contributor Author

cli/CHANGELOG.md Outdated Show resolved Hide resolved
/** Allows us to strip internal types sourced from webpack */
"stripInternal": true,
"importsNotUsedAsValues": "error"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting deprecation warnings and I think I forgot to migrate it to the new flag https://www.typescriptlang.org/tsconfig#preserveValueImports. Ill try adding it back in and see whats up

@@ -42,7 +42,8 @@
"ts-node": "^10.9.2",
"webpack": "npm:webpack@^5",
"webpack-4": "npm:webpack@^4",
"webpack-dev-server-3": "npm:webpack-dev-server@^3"
"webpack-dev-server-3": "npm:webpack-dev-server@^3",
"webpack-dev-server-5": "npm:webpack-dev-server@^5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, why isn't npm:webpack-dev-server@v4 listed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because its installed under webpack-dev-server since its the default that ships with @cypress/webpack-dev-server. Eventually we want to bump it to 5, but that is a breaking change

Copy link
Contributor

@mschile mschile left a comment

Choose a reason for hiding this comment

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

Added a few comments but looks good!

@AtofStryker AtofStryker changed the title feat: support webpack-dev-server v5 in @cypress/wevpack-dev-server feat: support webpack-dev-server v5 in @cypress/webpack-dev-server Apr 16, 2024
@AtofStryker AtofStryker merged commit d7e9d60 into develop Apr 18, 2024
111 of 116 checks passed
@AtofStryker AtofStryker deleted the feat/support_wds5 branch April 18, 2024 15:17
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 18, 2024

Released in 13.8.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.8.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support webpack-dev-server v5 in @cypress/webpack-dev-server
5 participants