-
-
Notifications
You must be signed in to change notification settings - Fork 400
Closed
Description
Describe the bug
The new vite react template has composite tsconfig.json, which references 2 other configs. This config style causing the fork-dev-worker cannot find the root directory of the config. This error affects the onboarding experience of Vite 8 new adopters.
// tsconfig.json
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}➜ mfe-app1 git:(main) npm run dev
> mfe-app1@0.0.0 dev
> vite
`resolve.alias` contains an alias with `customResolver` option. This is deprecated and will be removed in Vite 9. Please use a custom plugin with a resolveId hook and `enforce: 'pre'` instead.
VITE v8.0.0 ready in 304 ms
➜ Local: http://localhost:4000/
➜ Network: use --host to expose
➜ press h + enter to show help
node:internal/process/promises:394
triggerUncaughtException(err, true /* fromPromise */);
^
Error: Can not get effective rootDir, please set compilerOptions.rootDir !
at getEffectiveRootDir (/Users/ijal/dev/ags/vite-mfe/mfe-app1/node_modules/@module-federation/vite/node_modules/@module-federation/dts-plugin/dist/fork-dev-worker.js:2462:9)
at readTsConfig (/Users/ijal/dev/ags/vite-mfe/mfe-app1/node_modules/@module-federation/vite/node_modules/@module-federation/dts-plugin/dist/fork-dev-worker.js:2481:19)
at retrieveRemoteConfig (/Users/ijal/dev/ags/vite-mfe/mfe-app1/node_modules/@module-federation/vite/node_modules/@module-federation/dts-plugin/dist/fork-dev-worker.js:2560:20)
at /Users/ijal/dev/ags/vite-mfe/mfe-app1/node_modules/@module-federation/vite/node_modules/@module-federation/dts-plugin/dist/fork-dev-worker.js:2896:45
at Generator.next (<anonymous>)
at /Users/ijal/dev/ags/vite-mfe/mfe-app1/node_modules/@module-federation/vite/node_modules/@module-federation/dts-plugin/dist/fork-dev-worker.js:79:61
at new Promise (<anonymous>)
at __async (/Users/ijal/dev/ags/vite-mfe/mfe-app1/node_modules/@module-federation/vite/node_modules/@module-federation/dts-plugin/dist/fork-dev-worker.js:63:10)
at forkDevWorker (/Users/ijal/dev/ags/vite-mfe/mfe-app1/node_modules/@module-federation/vite/node_modules/@module-federation/dts-plugin/dist/fork-dev-worker.js:2886:10)
at Object.<anonymous> (/Users/ijal/dev/ags/vite-mfe/mfe-app1/node_modules/@module-federation/vite/node_modules/@module-federation/dts-plugin/dist/fork-dev-worker.js:2618:23)
Node.js v22.20.0
Findings
This function assume the project to have a single tsconfig and infers the root dir from the fileNames path
core/packages/dts-plugin/src/core/configurations/remotePlugin.ts
Lines 38 to 50 in 2fc4050
| // if no set rootDir , infer the commonRoot | |
| const files = parsedCommandLine.fileNames; | |
| if (files.length > 0) { | |
| const commonRoot = files | |
| .map((file) => dirname(file)) | |
| .reduce((commonPath, fileDir) => { | |
| while (!fileDir.startsWith(commonPath)) { | |
| commonPath = dirname(commonPath); | |
| } | |
| return commonPath; | |
| }, files[0]); | |
| return commonRoot; | |
| } |
Suggestion
Add new check for tsconfig path that referenced in main tsconfig.json. I filed a PR for this issue #4543
Reproduction
https://github.com/eezhal92/vite-8-beta-mfe-remote
Used Package Manager
npm
System Info
System:
OS: macOS 15.1
CPU: (12) arm64 Apple M4 Pro
Memory: 218.66 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.20.0 - /Users/ijal/.nvm/versions/node/v22.20.0/bin/node
npm: 10.9.3 - /Users/ijal/.nvm/versions/node/v22.20.0/bin/npm
pnpm: 10.21.0 - /Users/ijal/Library/pnpm/pnpm
Browsers:
Chrome: 145.0.7632.162
Firefox: 148.0
Safari: 18.1Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Module federation issue and not a framework-specific issue.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels