core icon indicating copy to clipboard operation
core copied to clipboard

Module Federation Plugin for Vite

Open douglaszaltron opened this issue 1 year ago • 8 comments

Clear and concise description of the problem

With the advent of @module-federation/esbuild, can we expect an official plugin to work with Vite? I say this because Vite has a large adoption. This would be wonderful for the module federation ecosystem.

Suggested solution

Today, for Vite, we have some options, but none integrated with the core of module federation, as the @module-federation/vite plugin still depends on @softarc/native-federation-esbuild.

Alternative

No response

Additional context

No response

Validations

  • [X] Read the Contributing Guidelines.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

douglaszaltron avatar Jul 20 '24 01:07 douglaszaltron

Happily this is something we can expect to see as "officially" supported. @yyx990803 has put this on the roadmap for Rolldown which is going to be the basis for the next version of Vite.

zackarychapple avatar Jul 20 '24 03:07 zackarychapple

I am implementing this plugin, and I would like to ask here, how should I handle the first parameter of init and the shared of init, whether @module-federation/runtime should provide a merge api, or who can tell me how to do it, I am only one step away from completion

https://github.com/zhangHongEn/module-federation-vite/blob/9c3713ec24cb459f5f998ccb820c176cef65ae5c/packages/module-federation-vite/src/index.js#L48

zhangHongEn avatar Jul 22 '24 12:07 zhangHongEn

fantastic news @zhangHongEn! Will work on getting you answers asap.

@ScriptedAlchemy @zmzlois can we dig into this.

zackarychapple avatar Jul 23 '24 01:07 zackarychapple

Can we just make this work with vite ? https://github.com/MadaraUchiha-314/rollup-plugin-module-federation

It already uses the runtime and the sdk and has solved most of the problems related to supporting MF 2.0

Happy to collaborate on this. @zhangHongEn

FYI, I have been collaborating with @ScriptedAlchemy on this for the past few months and it's almost close to completion

MadaraUchiha-314 avatar Jul 23 '24 17:07 MadaraUchiha-314

how should I handle the first parameter of init and the shared of init

https://github.com/MadaraUchiha-314/rollup-plugin-module-federation/blob/main/packages/rollup-plugin-module-federation/src/index.ts#L585

This is how you use the shareScope that's passed into init ^

MadaraUchiha-314 avatar Jul 23 '24 17:07 MadaraUchiha-314

how should I handle the first parameter of init and the shared of init

https://github.com/MadaraUchiha-314/rollup-plugin-module-federation/blob/main/packages/rollup-plugin-module-federation/src/index.ts#L585

This is how you use the shareScope that's passed into init ^

Thanks, this is very useful

I already support dev and build modes of vite, and have all the main features, but I haven't done other enhancements of 2.0, such as manifest.json and runtime plugins, etc. Can I PR here and then we can improve it together? https://github.com/module-federation/vite/issues/4

zhangHongEn avatar Jul 24 '24 00:07 zhangHongEn

@zhangHongEn would love to check your PR and work on it together too

zmzlois avatar Jul 31 '24 15:07 zmzlois

@zhangHongEn would love to check your PR and work on it together too

pr is here, it can speed up some progress

zhangHongEn avatar Jul 31 '24 16:07 zhangHongEn

Stale issue message

github-actions[bot] avatar Sep 30 '24 15:09 github-actions[bot]

https://github.com/module-federation/vite

douglaszaltron avatar Sep 30 '24 17:09 douglaszaltron