-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Removal of baseUrl from .nuxt/tsconfig.json in nuxt v3.7.0 breaks Cypress tsconfig.json path aliasing #26512
Comments
Would you be able to provide a reproduction? 🙏 More infoWhy do I need to provide a reproduction?Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. What will happen?If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect. If How can I create a reproduction?We have a couple of templates for starting with a minimal reproduction: 👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as minimal as possible. See more details in our guide. You might also find these other articles interesting and/or helpful: |
@danielroe I've created an reproduction link with instructions here: https://github.com/JasonLandbridge/Cypress-Path-Alias-Reproduction Please let me know if I can provide more information! |
It feels like this is an upstream issue in Here's an example of how to do that: https://github.com/nuxt/module-builder/blob/main/src/commands/build.ts#L279-L295 |
Workaround: aleclarson/vite-tsconfig-paths#123 (comment) In the root {
"extends": "./.nuxt/tsconfig.json",
"compilerOptions": {
"baseUrl": "./.nuxt/", //<-- Add this
} then inherrit from this {
"extends": "../tsconfig.json", // Needed for the path aliases
} |
Environment
Working directory: /mnt/PROJECTS/ProjectA 12:37:32 PM
Nuxt project info: 12:37:32 PM
Reproduction
Reproduction link: https://github.com/JasonLandbridge/Cypress-Path-Alias-Reproduction
Describe the bug
When using Nuxt in combination with Cypress and Cypress-Vite it is recommended to have the following tsconfig layout:
Cypress Typescript support:
Where each
tsconfig.json
extends from the other to allow Typescript path aliasing to work correctly in Cypress E2E tests.This worked great until Nuxt v3.7.0 where in PR #22410 the
baseUrl
was removed from the.nuxt/tsconfig.json
However, this
baseUrl
is crucial for Cypress to correctly translate path aliasing to the real path.Consider the following
tsconfig.json
files:The project path in this case is
/mnt/PROJECTS/ProjectA/
Before v3.7.0
vite:resolve-details [fs] /mnt/PROJECTS/ProjectA/src/mock-data/mock-base -> /mnt/PROJECTS/ProjectA/src/mock-data/mock-base.ts +0ms
After v3.7.0
vite:resolve-details [fallthrough] @mock +0ms # The Project folder is now missing from the path vite:resolve-details [fallthrough] /mnt/PROJECTS/src/mock-data +0ms
But, when I manually add
"baseUrl": "./",
to.nuxt/tsconfig.json
, when onv3.7.0
, then everything works again as it should and the paths get resolved correctly.It seems as if there is a
../
to many when resolving the paths in the newer Nuxt versions.Would it be possible to have a
nuxt.config.ts
option that will add back"baseUrl": "./",
to.nuxt/tsconfig.json
or is there some other workaround possible?Thanks!
The text was updated successfully, but these errors were encountered: