Replies: 3 comments 3 replies
-
I believe Vite has the config and configResolved methods that could be used here as a potential solution here. Technically you would build your config in the config function, and then you publish it to Vite's global and its available on configResolved. |
Beta Was this translation helpful? Give feedback.
-
Just to clarify, there seem to be two separate issues that are not fundamentally related here:
I think we should address these separately - also, I assume we are discussing this specifically in the context of the Zephyr plugin which wraps the Vite MF plugin? Plugins being able to access other plugins' config optionsThe fundamental issue here is that Rollup / Vite / Rolldown plugins are just objects - and exposing a factory function that take options is just a convention. Which means most plugins just return the actual plugin object without storing the options anywhere. Assuming the use case here is for the Zephyr plugin to read MF plugin's config, then it's really up to the MF plugin to expose the options somewhere - it can be just an extra property like Plugin SequencingAgain I assume what you want is the following order:
You want function withZephyr(options, plugins) {
return [
federation(),
...plugins,
zephyr()
]
} Then in config: export default {
plugins: withZephyr({ /* ... */ }, [
svgr()
])
} |
Beta Was this translation helpful? Give feedback.
-
Agree and yes :)
Thanks for the answer - fixed waiting to get merged (the type error scared everyone to do it 😭): module-federation/vite#175
function withZephyr(options, plugins) {
return [
federation(),
...plugins,
zephyr()
]
} second answer is super helpful as well 🚀 🙏 will keep you posted this is great!! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Current behavior
When we are processing user's configuration in Vite (tried on both rollup and rolldown), there isn't any ways for us to process user's configuration from other plugin ("we", "us" as a plugin)
Example with vite(rollup and rolldown) running build with
svgr()
options:Exmple with ModuleFederationPlugin in webpack with module federation options:
Repo for this comparison
Proposed behavior
If user passed in configuration options to other plugins, it should be available for other plugins, or somewhere can be tapped into to see, keeping
load: [Function: load]
is cool atm.Why is this beneficial
Reference in Webpack
Q1. How does webpack fundamentally prevent ordering issues?
No sequencing of "pre" or "post", the sequence relying on the lifecycle hooks. Plugin author could keep a statistics track of bundling process, lifecycle hook processing, even it is the same lifecycle hook, you could be handle it similar to a
z-index
on how sooner or later this hook should run.Reference
Beta Was this translation helpful? Give feedback.
All reactions