Skip to content

fix(dts-plugin): infer root dir from tsconfig references to fix Vite 8 new template dev server failure#4543

Open
eezhal92 wants to merge 2 commits intomodule-federation:mainfrom
eezhal92:rootdir-solution-style
Open

fix(dts-plugin): infer root dir from tsconfig references to fix Vite 8 new template dev server failure#4543
eezhal92 wants to merge 2 commits intomodule-federation:mainfrom
eezhal92:rootdir-solution-style

Conversation

@eezhal92
Copy link

Description

When using the new Vite-react template (Vite v8 + Rolldown) with module-federation/vite plugin, the dev server stopped and throws this error: Error: Can not get effective rootDir, please set compilerOptions.rootDir ! see #4542

  VITE v8.0.0  ready in 397 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)

The new template is using composite tsconfig like so:

{
  "files": [],
  "references": [
    { "path": "./tsconfig.app.json" },
    { "path": "./tsconfig.node.json" }
  ]
}

Root cause

This happens because the remotePlugin module 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

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2026

🦋 Changeset detected

Latest commit: e8f3806

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 45 packages
Name Type
@module-federation/dts-plugin Patch
@module-federation/cli Patch
@module-federation/enhanced Patch
@module-federation/manifest Patch
@module-federation/metro Patch
@module-federation/rspack Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/runtime Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/treeshake-server Patch
@module-federation/treeshake-frontend Patch
@module-federation/esbuild Patch
@module-federation/utilities Patch

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

@netlify
Copy link

netlify bot commented Mar 14, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit e8f3806
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69b76a6c0f573b000874ede8
😎 Deploy Preview https://deploy-preview-4543--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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('./'))

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@eezhal92 eezhal92 force-pushed the rootdir-solution-style branch from 75c30da to 3d0f447 Compare March 14, 2026 04:04
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 16, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@4543

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@4543

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@4543

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/@module-federation/data-prefetch@4543

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@4543

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@4543

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@4543

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@4543

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@4543

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@4543

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@4543

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@4543

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@4543

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@4543

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@4543

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@4543

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@4543

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@4543

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@4543

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@4543

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@4543

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@4543

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@4543

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@4543

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@4543

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@4543

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@4543

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@4543

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@4543

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@4543

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@4543

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@4543

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@4543

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@4543

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@4543

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@4543

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@4543

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@4543

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@4543

commit: e8f3806

@github-actions
Copy link
Contributor

Bundle Size Report

11 package(s) changed, 29 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/cli 26.7 kB no change 786 B no change
@module-federation/core 39.1 kB no change 173 B no change
@module-federation/devtools 473.2 kB no change 3.9 kB no change
@module-federation/dts-plugin 302.3 kB +1.1 kB (+0.4%) 4.5 kB +3 B (+0.1%)
@module-federation/enhanced 810.7 kB no change 672 B no change
@module-federation/managers 69.9 kB no change 334 B no change
@module-federation/manifest 138.4 kB no change 182 B no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/node 189.2 kB no change 217 B no change
@module-federation/storybook-addon 76.8 kB no change 100 B no change
@module-federation/utilities 110.6 kB no change 328 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/cli 2.3 kB -34 B (-1.4%) 2.3 kB -34 B (-1.4%)
@module-federation/core 1.1 kB -32 B (-2.9%) 1.0 kB -31 B (-2.9%)
@module-federation/devtools 20.8 kB -26 B (-0.1%) 20.8 kB -26 B (-0.1%)
@module-federation/dts-plugin 13.9 kB +58 B (+0.4%) 13.9 kB +58 B (+0.4%)
@module-federation/enhanced 3.0 kB -43 B (-1.4%) 3.0 kB -43 B (-1.4%)
@module-federation/managers 2.4 kB -27 B (-1.1%) 2.4 kB -27 B (-1.1%)
@module-federation/manifest 6.2 kB -38 B (-0.6%) 6.2 kB -38 B (-0.6%)
@module-federation/metro-plugin-rnc-cli 411 B -26 B (-5.9%) 411 B -26 B (-5.9%)
@module-federation/node 9.2 kB -29 B (-0.3%) 9.2 kB -29 B (-0.3%)
@module-federation/storybook-addon 1.9 kB -24 B (-1.2%) 1.7 kB -23 B (-1.3%)
@module-federation/utilities 2.6 kB -31 B (-1.2%) 2.6 kB -31 B (-1.2%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 19.5 kB -19 B (-0.1%) 20.5 kB -28 B (-0.1%) +1.0 kB -9 B

Total dist (raw): 6.31 MB (+1.1 kB (+0.0%))
Total ESM gzip: 73.4 kB (+3 B (+0.0%))
Total web bundle (gzip): 178.1 kB (-252 B (-0.1%))
Total node bundle (gzip): 178.6 kB (-250 B (-0.1%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.5 kB (no change)
Tracked ./bundler node bundle (gzip): 4.5 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dts-plugin throws: "Can not get effective rootDir" error in new vite 8+rolldown template project

2 participants