vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.82k stars 1.04k forks source link

Hot Reload Modules #2820

Open Logic-Bits opened 7 months ago

Logic-Bits commented 7 months ago

Hello,

would it be possible to have Plugins being hot-reloaded?

https://docs.nestjs.com/recipes/hot-reload

so plugin updates can be rolled out independend, or even something like a store can be enabled by this.

Thanks!

michaelbromley commented 5 months ago

Hi,

I'm not sure - but if you'd like to try a proof-of-concept then I'd be interested to hear if you get it to work, and we can consider incorporating any needed changes into the core.

Logic-Bits commented 5 months ago

maybe you can point me in the right direction. We would need to publish a "lets reload module X" Event - to all instances and workers (in theory). Would the EventBus be the right choice?

Thanks

michaelbromley commented 5 months ago

I'm not really familiar with the internal workings of HMR, but I don't think the EventBus should be involved since that is for events that occur within the system itself, not in modifications to source code.

Maybe what would be needed is a custom file watcher process which is able to find the associated Module (or VendurePlugin) for any given modified file. This can be done by traversing the TypeScript AST using something like ts-morph.

And is HMR only supported if you use Webpack when developing? Because by default, projects generated with @vendure/create do not use Webpack.

dlhck commented 2 months ago

@Logic-Bits this would mean we would need to switch the dev build process to Webpack. Generally I think this is not a bad idea. I moved it to "under consideration" as we need to do some more research.

Logic-Bits commented 2 months ago

@dlhck sounds good, thank you

dlhck commented 2 months ago

This will be covered by #3086