core icon indicating copy to clipboard operation
core copied to clipboard

Attemping to use inject-external-runtime-core-plugin results in error

Open tmpaul opened this issue 1 year ago • 3 comments

Describe the bug

When I try to use @module-federation/inject-external-runtime-core-plugin, I get the following error

ERROR in ../node_modules/@module-federation/runtime/dist/core.esm.mjs 3:0-58

export 'default' (reexported as 'default') was not found in '@module-federation/runtime-core' (possible exports: CurrentGlobal, FederationHost, Global, Module, addGlobalSnapshot, assert, getGlobalFederationConstructor, getGlobalSnapshot, getInfoWithoutType, getRegisteredShare, getRemoteEntry, getRemoteInfo, helpers, isStaticResourcesEqual, loadScript, loadScriptNode, matchRemoteWithNameAndExpose, registerGlobalPlugins, resetFederationGlobalInfo, safeWrapper, satisfy, setGlobalFederationConstructor, setGlobalFederationInstance, types)

The reason for this error is that the "published" file @module-federation/runtime/dist/core.esm.mjs contains the following

 import runtimeCore__default from '@module-federation/runtime-core';
 export * from '@module-federation/runtime-core';
export { default } from '@module-federation/runtime-core';

Notice the third line export { default } from '@module-federation/runtime-core';. There is no default export in this package. This leads to the error above. I can fix this by manually patching the file to remove the extra export { default } line. Interestingly looking at the source, I think rollup is messing up the output.

To reproduce, run the stackblitz link, run npm start and watch the error overlay.

Reproduction

https://stackblitz.com/edit/github-2vfygo-pkyh5azi?file=app1%2Fwebpack.config.js

Used Package Manager

npm

System Info

System:
    OS: macOS 14.7
    CPU: (10) arm64 Apple M1 Max
    Memory: 21.02 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.4 - ~/.nvm/versions/node/v18.20.4/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 8.19.4 - ~/Projects/foo/bar/node_modules/.bin/npm
    bun: 1.1.20 - ~/.bun/bin/bun
  Browsers:
    Chrome: 131.0.6778.265
    Safari: 17.6

Validations

tmpaul avatar Jan 11 '25 04:01 tmpaul

@2heal1 can you have a look

ScriptedAlchemy avatar Jan 13 '25 14:01 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar Mar 14 '25 15:03 github-actions[bot]

@tmpaul do you want to send us a PR. It'll likely get merged faster that way

ScriptedAlchemy avatar Mar 15 '25 09:03 ScriptedAlchemy

Stale issue message

github-actions[bot] avatar May 14 '25 15:05 github-actions[bot]