Build fails with a failed to resolve "extends":"../../tsconfig.json"
Describe the bug
I am trying to build a new React (Typescript) app but I get this error:
[vite:esbuild] failed to resolve "extends":"../../tsconfig.json" in /Users/me/my-app/node_modules/@my-library/my-package/tsconfig.json
This comes from my organization's monorepo. Is there any way to solve this? I can see from the documentation that using extends can affect the build.
Reproduction
Unfortunately I cannot post any code since this is a private repo but the build fails on my package that get's imported from my organisation's monorepo (lerna, workspaces).
System Info
System:
OS: macOS 11.5.2
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 318.47 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.22.7 - ~/.nvm/versions/node/v12.22.7/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v12.22.7/bin/npm
Browsers:
Brave Browser: 97.1.34.81
Chrome: 97.0.4692.99
Chrome Canary: 100.0.4862.3
Edge: 97.0.1072.76
Firefox: 91.0.2
Firefox Developer Edition: 97.0
Safari: 14.1.2
npmPackages:
@vitejs/plugin-react: ^1.0.7 => 1.1.4
vite: ^2.7.2 => 2.7.13
Used Package Manager
yarn
Logs
[vite:esbuild] failed to resolve "extends":"../../tsconfig.json" in /Users/me/my-app/node_modules/@my-library/my-package/tsconfig.json
file: /Users/me/my-app/node_modules/@my-library/my-package/index.ts
error during build:
TSConfckParseError: failed to resolve "extends":"../../tsconfig.json" in /Users/me/my-app/node_modules/@my-library/my-package/tsconfig.json
at resolveExtends (/Users/me/my-app/node_modules/vite/dist/node/chunks/dep-f5552faa.js:22291:11)
at parseExtends (/Users/me/my-app/node_modules/vite/dist/node/chunks/dep-f5552faa.js:22275:34)
at parse$e (/Users/me/my-app/node_modules/vite/dist/node/chunks/dep-f5552faa.js:22226:24)
at async loadTsconfigJsonForFile (/Users/me/my-app/node_modules/vite/dist/node/chunks/dep-f5552faa.js:22567:24)
at async transformWithEsbuild (/Users/me/my-app/node_modules/vite/dist/node/chunks/dep-f5552faa.js:22404:36)
at async Object.transform (/Users/me/my-app/node_modules/vite/dist/node/chunks/dep-f5552faa.js:22488:32)
at async transform (/Users/me/my-app/node_modules/rollup/dist/shared/rollup.js:21959:16)
at async ModuleLoader.addModuleSource (/Users/me/my-app/node_modules/rollup/dist/shared/rollup.js:22192:30)
[!] Error: unfinished hook action(s) on exit:
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [ ] The provided reproduction is a minimal reproducible example of the bug.
adding @dominikg as you made tsconfk and might know the reason
It looks like that package extends a tsconfig that is outside of it's own directory.
"extends":"../../tsconfig.json" in /Users/me/my-app/node_modules/@my-library/my-package/tsconfig.json would be
/Users/me/my-app/node_modules/tsconfig.json
Does that file exist? I guess not. Also i'm not sure why there is typescript in node_modules. shouldn't that be a built version of my-package? This might have something to do with lerna (not familiar with it) but without a reproduction, i'm not sure what could be going on here.
Hello @iakovosvo. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.
I have exactly the same issue with this package : @axa-fr/react-oidc-redux You could add it and you will see that yarn build faild with the same error message.
I use react-ts template with yarn 3 with pnp mode.
I have exactly the same issue with this package : @axa-fr/react-oidc-redux You could add it and you will see that yarn build faild with the same error message.
see https://github.com/AxaGuilDEv/react-oidc/issues/671
it seems in that case the issue is that their package.json contains a legacy "jsnext:main" entry that takes precedence in vite. @iakovosvo you may want to check your project for a similar field
I use react-ts template with yarn 3 with pnp mode.
esm support with yarn pnp has been less than pleasant (read: not working) in the past. does it work now?
Thank's for your answer. Yarn dev works perfectly. I have only this issue with yarn build.