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-dev-server): Pass in jsconfig to get webpack config for Next.js >= 13.2.1 #26005

Merged
merged 4 commits into from
Mar 6, 2023

Conversation

astone123
Copy link
Contributor

@astone123 astone123 commented Mar 3, 2023

Additional details

With the release of Next.js 13.2.1, we need to pass the JS/TS config into getBaseWebpackConfig, otherwise the config won't be respected when running the dev server. This PR adds some logic to get the user's JS/TS configuration and pass it to getBaseWebpackConfig.

Steps to test

  1. Create a Next.js project (v13.2.1) that uses the src/ dir (it's in the generator options)
  2. Configure Cypress for CT
  3. Have a tsconfig.json file in the project root with these options
{
  "compilerOptions": {
    // ...
    "paths": {
      "*": ["src/*"]
    },
  }
  "baseUrl": '.'
}
  1. In cypress/support/component.ts, import a stylesheet like this
import 'styles/globals.css'
  1. Run a component test and verify that Webpack is able to resolve this import

Also test on < v13.2.1 and make sure that everything still works.

How has the user experience changed?

PR Tasks

@astone123 astone123 self-assigned this Mar 3, 2023
@astone123
Copy link
Contributor Author

Thoughts about testing this with a system test? I looked into it for a while but was having some problems and started questioning whether or not it would be worth the effort. I was able to test it pretty well manually using some example projects.

Copy link
Contributor

@ZachJW34 ZachJW34 left a comment

Choose a reason for hiding this comment

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

I think a system-test covering this would be beneficial

npm/webpack-dev-server/src/helpers/nextHandler.ts Outdated Show resolved Hide resolved
npm/webpack-dev-server/src/helpers/nextHandler.ts Outdated Show resolved Hide resolved
@cypress
Copy link

cypress bot commented Mar 3, 2023

5 flaky tests on run #44547 ↗︎

0 5113 78 0 Flakiness 5

Details:

add system test project
Project: cypress Commit: 909924132f
Status: Passed Duration: 13:50 💡
Started: Mar 6, 2023 3:12 PM Ended: Mar 6, 2023 3:26 PM
Flakiness  commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-chrome:beta

View Output Video

Test Artifacts
network stubbing > intercepting request > can delay and throttle a StaticResponse Output Video
Flakiness  e2e/origin/commands/navigation.cy.ts • 1 flaky test • 5x-driver-chrome:beta

View Output Video

Test Artifacts
cy.origin navigation > #consoleProps > .go() Output Video
Flakiness  cypress/cypress.cy.js • 3 flaky tests • 5x-driver-chrome:beta

View Output Video

Test Artifacts
... > correctly returns currentRetry Output Video
... > correctly returns currentRetry Output Video
... > correctly returns currentRetry Output Video

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@marktnoonan
Copy link
Contributor

I'm following the directions to test and trying a couple of things, but I consistently get

 Cannot find module '@/styles/globals.css'

I wonder if I am missing some little detail.

Copy link
Contributor

@marktnoonan marktnoonan left a comment

Choose a reason for hiding this comment

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

Confirmed this works as expected for me. +1 to a system test

@astone123 astone123 merged commit a9ab4c7 into develop Mar 6, 2023
@astone123 astone123 deleted the next-13.2.1-jsconfig branch March 6, 2023 15:31
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.

Component testing broken with NextJS 13.2.1
4 participants