Skip to content

Bug: @module-federation/dts-plugin throws SyntaxError: Named export not found for fs-extra in ESM context #4503

@Staremang

Description

@Staremang

Describe the bug

When @module-federation/dts-plugin is executed in an ESM context (e.g. Node.js workers, direct execution with "type": "module"), it throws:

import fse, { ensureDirSync, existsSync, writeFileSync } from "fs-extra";
                             ^^^^^^^^^^
SyntaxError: Named export 'existsSync' not found. The requested module 'fs-extra' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'fs-extra';
const { ensureDirSync, existsSync, writeFileSync } = pkg;

Reproduce

  • @module-federation/vite 1.12.0
  • ESM module resolution

Reproduction

Internal repo with a patch

Used Package Manager

pnpm

System Info

System:
    OS: macOS 26.3
    CPU: (14) arm64 Apple M4 Pro
    Memory: 1.08 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.10.0 - /opt/homebrew/bin/node
    npm: 11.6.0 - /opt/homebrew/bin/npm
    pnpm: 9.12.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Safari: 26.3

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