fix(dts-plugin): infer root dir from tsconfig references to fix Vite 8 new template dev server failure#4543
Conversation
🦋 Changeset detectedLatest commit: e8f3806 The changes in this PR will be included in the next version bump. This PR includes changesets to release 45 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75c30dadc5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // if there are project references, infer the commonRoot from references | ||
| if (parsedCommandLine.projectReferences.length) { | ||
| const commonRoot = parsedCommandLine.projectReferences | ||
| .filter((file) => file.originalPath.startsWith('./')) |
There was a problem hiding this comment.
Include all relative references in rootDir inference
The new projectReferences branch only keeps entries whose originalPath starts with "./", so valid relative references like "../shared" or "packages/app" are ignored when computing commonRoot. In those cases the reducer effectively falls back to the first reference directory, which can set rootDir too deep and trigger TS6059 when exposed files live outside that folder. This makes solution-style tsconfigs with non-./ references fail even though they are valid.
Useful? React with 👍 / 👎.
75c30da to
3d0f447
Compare
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/data-prefetch
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
Bundle Size Report11 package(s) changed, 29 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 6.31 MB (+1.1 kB (+0.0%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
Description
When using the new Vite-react template (Vite v8 + Rolldown) with
module-federation/viteplugin, the dev server stopped and throws this error:Error: Can not get effective rootDir, please set compilerOptions.rootDir !see #4542The new template is using composite tsconfig like so:
Root cause
This happens because the
remotePluginmodule cannot retrieve the tsconfig root directory when using config like above. Currently the logic only works for single (non-composite) tsconfig. It infers the root directory from fileNames path of the parsed config.Fix
Add new logic to determine the root dir from the "references" field, by checking the tsconfig in the same directory with the entry
tsconfig.json.Related Issue
This PR closes #4542
Types of changes
Checklist