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

fix: #156 ssr: require is not defined #250

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

poenneby
Copy link

@poenneby poenneby commented Feb 6, 2025

Further to this discussion: #156 (comment)

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Thanks @poenneby for your help 🤗

@poenneby
Copy link
Author

poenneby commented Feb 7, 2025

@gioboa Running the multi-example with these changes correctly export default exportModule but at runtime I get "unexpected token: default"
Tracing this back in the code the export default gets incorrectly identified as a named export in src/plugins/pluginDevProxyModuleTopLevelAwait.ts

The transpiled code that causes the error:

// node_modules/__mf__virtual/host__loadRemote__remote_mf_1_Product__loadRemote__.js
var import_node_module = __toESM(require_node_module());
var { loadRemote } = require2("@module-federation/runtime");
var { initPromise } = require2("__mf__virtual/host__mf_v__runtimeInit__mf_v__.js");
var res = initPromise.then((_) => loadRemote("remote/Product"));
var exportModule = (
  /*mf top-level-await placeholder replacement mf*/
  initPromise.then((_) => res)
);
var require2 = (0, import_node_module.createRequire)(import.meta.url);
var host_loadRemote_remote_mf_1_Product_loadRemote_default = exportModule;

              const __mfproxy__awaitdefault = await default(); <-- HERE
              const __mfproxy__default = () => __mfproxy__awaitdefault;
            
export { __mfproxy__default as default };

Any ideas?

@gioboa
Copy link
Collaborator

gioboa commented Feb 7, 2025

I see, I will check it. Thanks for the deep investigation

@rafal-akiro
Copy link

Hey @gioboa any update on this?

@gioboa
Copy link
Collaborator

gioboa commented Feb 10, 2025

I did look at it yet. But eventually we can continually change the code if an SSR env is detected

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

Successfully merging this pull request may close these issues.

3 participants