Skip to content

Upgrading @module-federation/rsbuild-plugin from v0.19 or below to any version greater than or equal to v0.20.0 causes #TYPE-001 warning for the same rslib/rsbuild configs #4272

@AlaDouagi

Description

@AlaDouagi

Describe the bug

This console warning started to appear for the same rsbuild and rslib configs I use, only after upgrading @module-federation/rsbuild-plugin to any version greater than or equal to v0.20.0:

 MyLibrary  pnpm dev

> my-library@0.0.0 dev C:\Users\<path>
> rslib mf-dev

  Rslib v0.18.4

start   build started...
Federated types created correctly
Federated mocks created correctly
ready   built in 3.88 s
[ Module Federation DTS ] Error: Failed to generate type declaration. Execute the below cmd to reproduce and fix the error. #TYPE-001
args: {"cmd":"npx tsc --project 'C:\\Users\\<path>\\node_modules\\.federation\\tsconfig.96bd01d70bd036d2dcbbb566d9ed3041.json'"}
View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/type/TYPE-001
    at C:\Users\<path>\node_modules\.pnpm\@module-federation+dts-plugin@0.20.0_typescript@5.9.3\node_modules\@module-federation\dts-plugin\dist\fork-generate-dts.js:416:13
    at Generator.throw (<anonymous>)
    at rejected (C:\Users\<path>\node_modules\.pnpm\@module-federation+dts-plugin@0.20.0_typescript@5.9.3\node_modules\@module-federation\dts-plugin\dist\fork-generate-dts.js:73:29)

Running npx tsc --project ... gives me an empty output, indicating that there are no TypeScript errors in my project.

Here is a sample of my rslib.config.ts

import { resolve } from "node:path";

import { NativeFederationTestsRemote } from "@module-federation/native-federation-tests/rspack";
import { NativeFederationTypeScriptRemote } from "@module-federation/native-federation-typescript/rspack";
import { pluginModuleFederation } from "@module-federation/rsbuild-plugin";
import { pluginReact } from "@rsbuild/plugin-react";
import { defineConfig } from "@rslib/core";

const peerDependencies = require("./package.json").peerDependencies;

const moduleFederationConfig = {
  name: "my_library",
  exposes: {
    "./shadcn/ui/alert": "./src/shadcn/ui/alert",
  },
  shared: {
    react: {
      requiredVersion: peerDependencies.react,
      singleton: true,
      eager: true,
    },
    "react-dom": {
      requiredVersion: peerDependencies["react-dom"],
      singleton: true,
      eager: true,
    },
  },
};

export default defineConfig({
  resolve: {
    alias: {
      "@/shadcn": resolve(__dirname, "./src/shadcn"),
    },
  },
  lib: [
    {
      format: "mf",
      source: {
        entry: {
          alert: "./src/shadcn/ui/alert.tsx",
        },
      },
      output: {
        target: "web",
        assetPrefix: "auto",
      },
      dev: {
        assetPrefix: undefined,
        lazyCompilation: false,
      },
      plugins: [pluginModuleFederation(moduleFederationConfig, {})],
    },
  ],
  tools: {
    rspack: {
      plugins: [
        NativeFederationTypeScriptRemote({ moduleFederationConfig }),
        NativeFederationTestsRemote({
          moduleFederationConfig,
          additionalBundlerConfig: { format: "esm" },
        }),
      ],
      lazyCompilation: false,
    },
  },
  source: {
    tsconfigPath: "./tsconfig.build.json",
  },
  server: {
    port: 3000,
  },
  plugins: [pluginReact()],
});

PS: The Alert file is a simple React component file with .tsx extension.

Reproduction

https://stackoverflow.com/help/minimal-reproducible-example

Used Package Manager

npm

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (14) x64 Intel(R) Core(TM) Ultra 7 165U
    Memory: 16.25 GB / 31.43 GB
  Browsers:
    Chrome: 142.0.7444.177
    Edge: Chromium (140.0.3485.54)
    Firefox: 140.6.0 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @rslib/core: ^0.18.4 => 0.18.4

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions