Skip to content

fix: prevent multiple processing of await plugin output #328

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

Merged
merged 1 commit into from
Jul 27, 2025

Conversation

pcfreak30
Copy link
Contributor

I ran into an edge case recently during some experimentation.

If you try running multiple module federation plugin instances in 1 vite config, the top await rewriter plugin will try to process itself multiple times. Around the 3rd time it created a duplicate const and the AST parse failed.

This is a simple fix that prevents that edge case.

This is part of a series of PR's to upstream my R&D.

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 for your help @pcfreak30
Can you shared a reproduction repository for this? I would like to double check it.
It looks good to me though

@pcfreak30
Copy link
Contributor Author

Thanks for your help @pcfreak30 Can you shared a reproduction repository for this? I would like to double check it. It looks good to me though

no. I don't have anything simple ready.

what I can say is it would ideally crash the vite server if you stick a host and a remote such that you have 2 federation() plugin objects in 1 vite config.

You can view a dev env I recently made to get an idea of some of what I was doing (https://github.com/LumeWeb/web/blob/b1dd36f3307f59a7039f40156c860c6829c064fc/libs/portal-framework-core/src/vite/plugin.ts), but while im no longer trying to stuff multiple federation builds in 1 vite instance... I figured i can submit the fix anyways. I was using a custom virtual folder as well for the remote.

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.

pnpm fmt will solve the error in the pipeline
Thanks

@pcfreak30 pcfreak30 force-pushed the fix-multiple-await branch from 3d3d888 to 2a530bb Compare July 27, 2025 15:02
@pcfreak30 pcfreak30 force-pushed the fix-multiple-await branch from 2a530bb to 0a02b2e Compare July 27, 2025 15:03
@pcfreak30
Copy link
Contributor Author

@gioboa done

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.

It looks straightforward and this will add an extra check in the process.
It's a good addition @pcfreak30 👌

@gioboa gioboa merged commit f76706b into module-federation:main Jul 27, 2025
4 checks passed
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.

2 participants