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

Hoisted runtime feature doesn't work #3341

Open
5 tasks done
smelukov opened this issue Dec 10, 2024 · 5 comments
Open
5 tasks done

Hoisted runtime feature doesn't work #3341

smelukov opened this issue Dec 10, 2024 · 5 comments

Comments

@smelukov
Copy link

smelukov commented Dec 10, 2024

Describe the bug

Seems like experiments: { federationRuntime: 'hoisted' } does not work as expected - embedded runtime is ignoring by webpack

  1. create a simple mf-project or get some basic mf-examples
  2. add experiments: { federationRuntime: 'hoisted' } to remote
  3. start dev server
  4. open host in browser and go to the network tab
  5. try to find some part of embedded runtime code in bundles (for example Federation runtime accessed before instantiation or installation)

There is nothing to find

Expected behaviour:

  • host creates a real runtime
  • remotes use hoisted option, so use already created runtime

Reproduction

see above

Used Package Manager

pnpm

System Info

seems like it doesn't matter

Validations

@smelukov smelukov changed the title Hoisted runtime doesn't work Hoisted runtime feature doesn't work Dec 10, 2024
@ScriptedAlchemy
Copy link
Member

Sounds like you are using a ESM output, set library.type = 'import' not module
federation remotes are external, when hoisting the runtime you can end up in a situation where the imports that need the runtime are eagerly loaded before the runtime.

if you set it to import, it will use import(), and thus not have this issue as import from

@ScriptedAlchemy
Copy link
Member

also if its modernjs, dont add hoisted runtime - we probably handle it under the hood.

@smelukov
Copy link
Author

Sounds like you are using a ESM output, set library.type = 'import' not module

Nope, we have a webpack config with mf-plugin that does not specify any library.type

@ScriptedAlchemy
Copy link
Member

can you share a repo or your build configs

@ScriptedAlchemy
Copy link
Member

Hoisted runtime does not allow recycling the runtime across host remote, it hoists the modules into each runtime - and out of the entrypoints.

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