Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named export not found when using @module-federation/rsbuild-plugin in ESM package #3395

Open
5 tasks done
tbaliukynas opened this issue Dec 23, 2024 · 1 comment
Open
5 tasks done

Comments

@tbaliukynas
Copy link

tbaliukynas commented Dec 23, 2024

Describe the bug

Trying to import pluginModuleFederation from @module-federation/rsbuild-plugin in an ESM package, results in the following error:

import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
         ^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'pluginModuleFederation' not found. The requested module '@module-federation/rsbuild-plugin' 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 '@module-federation/rsbuild-plugin';
const { pluginModuleFederation } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

To reproduce this, execute the following:

npm init -y
npm pkg set type="module"
npm i -D @module-federation/rsbuild-plugin
"import { pluginModuleFederation } from '@module-federation/rsbuild-plugin'" > index.js
node index.js

Reproduction

Described above

Used Package Manager

npm

System Info

OS: Windows 11 10.0.22631
Node: 20.16.0
npm: 10.8.1

Validations

@2heal1
Copy link
Member

2heal1 commented Jan 8, 2025

Hmm currently not support esm yet , let me know which scene will meet the issue , cause the build plugin always run in cjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants