- Видео 43
- Просмотров 70 287
Russell Canfield
США
Добавлен 1 янв 2021
Zephyr Cloud - The only sane way to do microfrontends
In this video we'll explore Zephyr Cloud, a cloud and framework agnostic microfrontend platform. Sub second build and deployments, version management and more? Whats not to love.
Links:
www.zephyr-cloud.io/
docs.zephyr-cloud.io/
github.com/RussellCanfield/zephyr-demo
Links:
www.zephyr-cloud.io/
docs.zephyr-cloud.io/
github.com/RussellCanfield/zephyr-demo
Просмотров: 289
Видео
Wingman-AI build a NextJS application from scratch!
Просмотров 9728 дней назад
In this video Wingman-AI will generate a brand new NextJS application from scratch using composer mode. We'll start with an empty directory and end up with a simple application, walking through using composer mode and how to use it. After we generate the application, we'll walk through a simple code review. Documentation: wingman.squadron-ai.com/
Rslib - Federating npm packages
Просмотров 340Месяц назад
In this video I'll show you how to setup Rslib as a package and as a federated module. Then consume the library as a microfrontend in a rsbuild application, using module federation. Rslib: github.com/web-infra-dev/rslib Repo: github.com/RussellCanfield/rslib-federation
Micro Frontends - Vite, RSBuild and Module Federation V2
Просмотров 9202 месяца назад
In this video we'll be exploring the new Vite module federation package, supporting federation v2! We'll setup a small monorepo with a Vite host, Vite remote and rsbuild remote. Official package: github.com/module-federation/vite
Wingman AI - Composer
Просмотров 2082 месяца назад
Deep dive into an upcoming release of Wingman AI, an open source VSCode extension that features advanced AI code assistant capabilities like chat, code-completion, refactor, documentation generation and compose! Documentation: wingman.squadron-ai.com/ Marketplace: marketplace.visualstudio.com/items?itemName=WingMan.wing-man
Micro Frontends - Module Federation Dynamic Remotes with fallback (v2).
Просмотров 1,8 тыс.4 месяца назад
In this video I'll show you how to setup dynamic remotes using Module Federation V2. Dynamic remotes refer to loading a module at runtime by fetching the module URLs from a configuration service. This can be useful if you need to evaluate which modules a particular user receives or loading them back on some other criteria without a rebuild. Repository: github.com/RussellCanfield/nx-rspack-micro...
Squadron AI - AI pull request code reviews, chat and more!
Просмотров 1504 месяца назад
Lets dive into Squadron AI, a GitHub app that provides best in class code reviews on pull requests, real-time chat, issue analysis and more! Squadron AI has the only cross file context that is based on the actual code you are editing. Not RAG mechanisms that can be inaccurate. Check out the free trial! www.squadron-ai.com/ x.com/Squadron_AI
OpenAI - Assistants API using code interpreter
Просмотров 1,2 тыс.6 месяцев назад
In this video I'll cover the OpenAI Assistant API and how to use the code interpreter tool to write code and generate tests for that code! Code from the video is available on my github repo link below. Links: platform.openai.com/docs/assistants/overview github.com/RussellCanfield/openai-assistant-demo
Micro frontends - Module Federation runtime, plugins, dynamic remotes and preloading
Просмотров 1,8 тыс.6 месяцев назад
In this video we'll dive into Module Federation v2 and how to setup dynamic remotes using a runtime plugin. And how to preload a remote to increase performance in your application. Links: github.com/RussellCanfield/nx-rspack-microfrontend-demo
Micro frontends - NX, Rspack, Module Federation with new Federated Types!
Просмотров 2,6 тыс.8 месяцев назад
In this video we'll dive into upgrading our NX Monorepo using Module Federation with webpack over to rspack and the new Module Federation plugins from "@module-federation/enhanced". This will give us federated types out of the box! Links: github.com/RussellCanfield/nx-rspack-microfrontend-demo nx.dev/nx-api/rspack www.npmjs.com/package/@module-federation/enhanced?activeTab=readme
Wingman AI, the free VSCode AI powered assistant
Просмотров 4169 месяцев назад
Wingman AI the free and open source AI powered assistant for VSCode. In this video I'll be covering how Wingman works, how to set it up and ways to get more power out of the extension. Use the link below to get started! marketplace.visualstudio.com/items?itemName=WingMan.wing-man
Micro Frontends - Module Federation v1.5 Plugins with rspack
Просмотров 5529 месяцев назад
In this video we'll continue our Micro Frontend journey by adding a simple plugin to Module Federation v1.5 which allows us to log the share scope to investigate how our modules are sharing dependencies at runtime. @module-federation/runtime: github.com/module-federation/universe/tree/main/packages/runtime Repos: github.com/RussellCanfield/microfrontend-demo/tree/pnpm-rspack
Micro Frontends - Rspack and Module Federation v1.5
Просмотров 1,8 тыс.10 месяцев назад
In this video we'll continue our Micro Frontend journey by converting an existing monorepo using webpack and Module Federation v1 to using rspack and Module Federation v1.5. This is surprisingly straight forward and brings a ton of performance improvements. Federated type support via: github.com/module-federation/universe/tree/main/packages/native-federation-typescript Repos: github.com/Russell...
Wingman - AI (VSCode extension) - Chat refactor code
Просмотров 52611 месяцев назад
Here is an example of the chat feature refactoring code in the VSCode Extension, Wingman-AI. This example is running the deepseek model. marketplace.visualstudio.com/items?itemName=wingman.wingman
Wingman - AI (VSCode extension) - Chat write a unit test
Просмотров 72211 месяцев назад
Here is an example of the chat feature, writing a unit test in the VSCode Extension, Wingman-AI. This example is running the deepseek model. marketplace.visualstudio.com/items?itemName=wingman.wingman
Wingman - AI (VSCode extension) - Code completion in action
Просмотров 1,4 тыс.11 месяцев назад
Wingman - AI (VSCode extension) - Code completion in action
How to build your own LLM Framework with Open Source models. (OpenAI Function Calling)
Просмотров 1,5 тыс.11 месяцев назад
How to build your own LLM Framework with Open Source models. (OpenAI Function Calling)
How to build a custom React chat application using a LLM (RAG and Langchain)
Просмотров 3,6 тыс.Год назад
How to build a custom React chat application using a LLM (RAG and Langchain)
Micro Frontends - Module Federation Web Workers
Просмотров 841Год назад
Micro Frontends - Module Federation Web Workers
Micro Frontends - Custom dynamic remote loader
Просмотров 2,1 тыс.Год назад
Micro Frontends - Custom dynamic remote loader
Micro Frontends - Sharing State between applications
Просмотров 5 тыс.Год назад
Micro Frontends - Sharing State between applications
Micro Frontends - Routing between remotes
Просмотров 7 тыс.Год назад
Micro Frontends - Routing between remotes
Web API, Intersection Observer - Performant Scroll Detection
Просмотров 128Год назад
Web API, Intersection Observer - Performant Scroll Detection
Micro Frontends - Dynamic Remotes and Typescript with NX
Просмотров 3,1 тыс.Год назад
Micro Frontends - Dynamic Remotes and Typescript with NX
Micro Frontends - NX and Module Federation
Просмотров 8 тыс.Год назад
Micro Frontends - NX and Module Federation
React - events and more with Broadcast Channel
Просмотров 1,2 тыс.Год назад
React - events and more with Broadcast Channel
Micro Frontends - From Monolith to Micro Frontend using React in a Monorepo
Просмотров 4,8 тыс.Год назад
Micro Frontends - From Monolith to Micro Frontend using React in a Monorepo
Web API, Resize Observer in React with a Custom Hook
Просмотров 163Год назад
Web API, Resize Observer in React with a Custom Hook
Micro Frontends - The why and how to get started!
Просмотров 2,8 тыс.Год назад
Micro Frontends - The why and how to get started!
Unity Culling Group - How to spawn NPCs
Просмотров 685Год назад
Unity Culling Group - How to spawn NPCs
Can we instead import an object from a remote module that has a key:value pair where key is used to locate the component and the value is essentially a lazily loaded component ? For example: import ComponentA from "./a"; export const registry = { testA: ComponentA; } This is in the remote and then use it in the host with loadRemote()
That is basically the purpose of federation and it's container entry. Federation needs to know about the components in order to split the bundles correctly. This could cause issues at runtime
Is it possible to use the runtime loadRemote and native imports with the Webpack ModuleFederationPlugin for the same module federation remote? Trying to switch a larger project over to using the runtime and would like to be able to do it incrementally. Getting errors when trying to load the same remote with the runtime as with the Webpack ModuleFederationPlugin.
It should work, what is the error? If you register a remote in the plugin, I believe it loads automatically. You could try the v2 webpack plugin to see if it helps
@@russellcanfield Thanks, will try checking the webpack plugin version. The error I am seeing when trying to register remotes for the same remoteEntry.js in both the plugin and runtime is "Container initialization failed as it has already been initialized with a different share scope".
@@yjk5737 Ok, make sure both are using the "default" share scope
@@russellcanfield I don't have any packages listed in "shared". It seemed like share scope would be something specific to items listed under "shared", but I'll admit I'm not too familiar with that part.
@@yjk5737 it seems like the remote is registered, is it in your plugin configuration in your webpack config?
can i share context, or jotai states when using @module-federation/enhanced/runtime
Yep, you can check out my other video on sharing state but it will work the same.
Hi Russel, can you use a Redux context provider on the window object in the same way as the Create context version? Or is this not a good idea?
You can share context, now the problem with sharing a global reference is that react won't re-render I believe because you aren't going through their API. There are a few approaches, you can useSynxExternalStore and sync the contexts - which will re-render as you expect, this can be done with a simple "event bus" approach as well to decouple things. You could also use an external package and share it as a singleton, the host can mount it in the DOM and you can use hooks to interface with the context as if the remote modules have it mounted - except you would not mount it in the remote modules.
Also is there a github link for the Jotai example?
@@Dadaadad268 I apparently do not :( you can use a similar approach with Jotai, share some store atoms globally by reference (singleton module), useSyncExternal store, or use Jotai's subscription feature
@@russellcanfield Thanks Russell. I'm trying the Jotai approach putting the reference on the window object. The imported module isn't updating the state though. I'm building the imported module first and running it in vite preview, the core app that imports it is running in dev mode. Should this still work?
Updating the window object doesn't re-render the component, so this would be the issue...
Hi Russell, I want to understand more on micro frontend and how things are working here. Like I just discovered this. Could you help me with some resource or you could make some videos for your audience. I can see you are the few initial ones who is creating content on this.
@@christmas7056 hey! Sure I have several videos under this playlist that should help
@@russellcanfield Found it, Thank you very much
Is this possible to setup nextjs application?
Very helpful video. Any insights on how we can perform error handling for the remotes, especially when preloading them? I have implemented the errorLoadRemote hook in my plugin, but I still do get an error as it tries to load the manifest. Is there a way we can tweak the beforePreloadRemote implementation in a way that will handle errors for fetching manifest if the remote is offline?
Thanks! Without trying it, I think the hook beforePreloadRemote could be used to serve a "known good remote" - but otherwise you need to handle it in the UI framework like React with maybe an error boundary
That is really good. Once I finish implementing I will let you know where is this used. I am going to make you proud. Thank you once again!
If my project is using vite, can I still use dynamic remotes?, I'm trying this approach but getting errors to load the remotes.
Hi, Yes you should be able to do it through the federation runtime
Great video, it was easy to understand. Can you make follow-up with building UI library that's federated and enables you to share CSS and types as well? I struggle to finish this part. 😒 It propagates props correctly, but types say I am wrong. Type '{ size: string; primary: true; label: string; onClick: () => void; }' is not assignable to type 'IntrinsicAttributes'. Property 'size' does not exist on type 'IntrinsicAttributes'.
@@BleedingDev sure any specific style library? I have a repo for a tailwind one with rslib
@@russellcanfield I used default template from Rslib and it seems to work, but now I struggle with types. :D It seems that my @mf-types.d.ts is wrong, but I am only guessing. I'll probably make a repo, where everything is clearly visible, rather than spamming the comments here. :) Content of it: export type RemoteKeys = 'REMOTE_ALIAS_IDENTIFIER'; type PackageType<T> = T extends 'REMOTE_ALIAS_IDENTIFIER' ? typeof import('REMOTE_ALIAS_IDENTIFIER') :any; PS: Tailwind example would be awesome. That's my primary style choice. 🤩🤩
Thank you for the video, I think the only one or one of the few that show the use of the new plugin. Running it locally work perfectly fine, but when deployed it doesn't. I tried also to just build it and serve it from the dist folder and same thing. Are there any special steps to prepare MFE architecture for deployment or to run in prod?
You may need to set the public path to auto for remotes and “/“ for the host. What errors are you seeing?
@@russellcanfield Tahnk you for your reply. Right now from the example in the video I have: virtual:mf-REMOTE_ENTRY_ID:28 Uncaught Error: Module ./modulepreload-polyfill does not exist in container. at Module.getExposes (virtual:mf-REMOTE_ENTRY_ID:28:44
And by public path I assume you mean base? not working sadly
@@SymyonYY Are you using module preloads? If you are, try to limit them just to the libraries you are sharing such as react for example. You need the function implementation of module preload
@@russellcanfield THe index.html in the dist folder does preload modules, particullarily for the runtimeInit artifact. But how do you limit what it gets in there? By the way code is 1 to 1 from the video, I don't do anything else, I am tryin gto have a 100% working example so I can work on my project afterwards.
Hi Russell, thanks for such a great videos. When we have such decoupled mf-s, is there a recommended approach on handling feature flags for each mf as well as for host? for host it needs to decide which mf to show and for mf it needs to hide some UI parts.
If you just need the host to decide which MF to show you can use a sort of configuration service. You could use feature flags and do more advanced scenarios like claims based, etc. For the remote, you can use a similar approach.
Is there a reason to manually target Chrome89 instead of leaving that blank?
@@RyanGarant-l5z yes you need it to support top level await
Thx for your video, could you add nested react router dom to your example?
Could you configure how to make the imported modules usable in the worker? Thank you so much
I would probably keep my worker intact and not federate into it. You could federate the worker itself though
Hi Russel!!, what happen if i don't want to work inside a mono repo?
@@ozzolim you don’t have to, the federation plug-in takes a url in the config or you can load remotes dynamically
Can you sharing a video talk about deployment mfe on PROD env? Thanks
I briefly touch on the topic in this video, but I do have a follow up one coming about Zephyr Cloud ruclips.net/p/PLemTpfu9eAGERzgHBYU_ibWJ_clKpTWfI&si=GHEm_YCW9zeWMGXn
Can you make a video on how to use shared config in init function? It is bit confusing. Under which circumstances we will need it. Consumer app can add share dependencies in build plugin itself, isn't it?
You can configure sharing either at runtime or build time. I would likely do it at build time
HI! Thx for the lesson, it's really helpful. Could give a tip How to correctly implement useRemote if remote entity (for example app1) exposes whole app with ReduxProvider. When I am trying to load a such component with useRemote I always face with an errors like "calling hook inside, lose useContext, etc". If I only expose foolish component like a button everything work ok with useRemote. I have tried to manipulate with shared deps, tried to use singleton, etc... but it did not work if I use Redux for remote component. P.S. I use webpack + react
@@matrixhasyou979 those errors are usually issues with sharing react, make sure you have the bootstrap file setup on the host, and both set to share react and react-dom
@@russellcanfield thx, for you answer. I have tried to as you suggested. But it still does not work. I have added into init (Host) shared deps (react, react-dom, react-redux, react-router-dom): init({ name: "host", remotes: [], shared: { react: { shareConfig: { eager: false, singleton: true, requiredVersion: "18.3.1", }, ........ }, and also I have added the same shared into remote app. Remote app totally independent app with it's own redux and router and I expose all app. But still face with an error like this: - Uncaught TypeError: Cannot read properties of null (reading 'useMemo') - React Router caught the following error during render TypeError: Cannot read properties of null (reading 'useMemo') Maybe I missed something?
Very cool! Great work. Might give this a shot when available to build out a basic Issues Tracker using PHP, mySQL, and HTMX.
Thanks for the video, I missed a year of content :) is the initial code available to follow your steps ? Thank you
I think the repo still has it, minor updates in terms of a plugin or dynamic remote loading
Thanks for the video. React.lazy() shouldn't be used in a component, as it executes the callback (promise to load remote) in every re-render. It should always be defined at the top level.
Thanks for pointing that out! You could probably wrap it in a useMemo, or put the component in state for extra optimization
Hi russell ..too good a video.. how will routing happen between 2 remote mfes? Like if i want to route to say /contact/form from another mfe route product/pdp where product is another remote mfe?
@@tafsianvickey you should be able to use routes as normal and either approach should work.
@@russellcanfield thanks for replying...i tried.. currently using hashrouter.. did useNavigate('/assisted/gridwall') from another mfe currently route /digital/plan but i get an error in console regarding react router-dom and all routes are handled from a host mfe which routes to root of assisted mfe and digital mfe
Thank you for informational video. How to load remote app redux sagas and reducers into host or shell app.
@@Guruboggarapu-w2b you can use similar code or a generic import statement, you don’t have to put the result in a React component. A component is just a JavaScript function basically. But I would think through why you’d need the saga in the shell. Components should be self contained as much as possible and state sharing limited
@@russellcanfieldI have a shell app and bunch of remote apps connected from shell using module federation. When link corresponding to remote app clicked trying to inject all corresponding reducers and sagas into shell store before loading remote components. Please let me know if you think of any better solution. Thanks.
@@Guruboggarapu-w2b the modules can’t have their state directly? Do they need to put state in the shell?
Your videos have been extremely helpful. Thank you. Can you make a video on tanstack router nested routing with module federation. A topic which is getting very popular but dint find any documentation / articles on it.
I am not using nx mono repo I am having problem with react query (tanstack v5) when I wrap QueryProvider in host and MFE the problem I am having is when I add a product I use queryClient.invalidateQueries to reload data in MFE but when I go to host I have to F5 again. So is there any way to sync data immediately without F5 in host? Thank you
It should be sharing react-query as a singleton but the double QueryProviders may be to blame. By default react-query creates a react context, so if you create 2 query providers it might be creating two context providers
@@russellcanfield thank bro ❤❤. I have solved it now but there is a big problem that I have tried to search but still have not found a solution. If on the dev environment everything is fine but when I build to the production environment, there is a situation when I directly enter the url of a router with a remote to an MFE, the error is 404 The requested path could not be found, but if I click on the Link with the same path, the MFE can be loaded but reloading the page gives an error 404 The requested path could not be found, when I reload, in the Sources section of the dev tool there is no remote loaded. Can you give me some advice? Thank you
@@tranvansi6302 in dev you are probably hitting a URL fallback in webpack dev server, forget the setting name. But in production you may need a redirect back to your index.html so that react router can intercept and apply the routing rules. There are a few articles online with like nginx to setup for a SPA
@@russellcanfield Can you give me some resources or keywords to solve this problem. Thank you.
@@tranvansi6302 Sure, try this if you are using nginx dev.to/paulmojicatech/nginx-and-angular-spa-redirect-11ji
I'm wondering if the authentication part should be separated into an MFE or left on host. Thanks bro
I would let the host handle the majority of the work, login, token renewal, etc. and remotes should just have access to the tokens/general auth state. Few ways to share the state, but you don’t want multiple consumers trying to perform refreshes
@@russellcanfield If I separate an auth MFE, is there any problem? In my case, I will manage the app host and the members will work on a separate MFE. If there is an MFE that needs authentication, I can remote to the auth MFE, but is there any problem?. Thank bro ❤❤❤❤❤❤
@@tranvansi6302 you probably could, I’ve used packages for it usually and shared them as singleton. But it could be a MFE I suppose, you’d just need to be careful controlling versions
@@russellcanfield Thanks for the great answer
when working with MFE how will it work when on host there are layouts while MFE is just component. Thanks
So you'll have to decide what that MFE needs. In some cases maybe the MFE is a "page" of an application that lives under the host. It could share the same layout as the host. Maybe it needs a special layout, you could own that in the MFE or have the host own it. Really depends on the requirements. The MFE should try to own as much as it can so there is little friction and dependencies upstream
@@russellcanfield In my case, I have a fixed layout with a sidebar that contains two links: "users" and "products". When clicking on "users", it should load the corresponding remote MFE for users, and when clicking on "products", it should do the same for products. Should I let the MFE manage the layout, or should the host manage it?.Thank bro ❤❤❤❤
@@tranvansi6302 I'd let the host determine that, routes rarely change
@@russellcanfield thank bro ❤❤
Thanks Russell, these are excellent videos. I have been trying to use Nx for module federation, this seems easier to understand. There are two areas though that I can't find any decent information about anywhere that you could make a couple of videos following on from this. So let's assume I have a host and multiple remotes running perfectly on my localhost but now I want to deploy them into another environment, like Azure Container Services using Docker. Firstly - what is the CORRECT way to dockerize and deploy them and secondly, how can we use the features here to switch the paths to remotes between dev (localhost) and different environments (e.g. staging or production).
Thanks! So you probably want to avoid dockerizing a react app, I would say put them in Azure Storage under separate folders inside a Container and drop a CDN infront of it. It's likely cheaper and easier to deploy; plus no vulnerabilities in docker images and managing NGINX inside of the image to serve the static content. Then deciding which remote to load involves either "hard coding" them at build time in the host. Or use a dynamic loader which allows you to make HTTP calls and pass in user information or hit some configuration service to retrieve the URL, then pass that down into federation. If it's v2 federation, you can call registerRemote with the URL, then loadRemote after :)
@@russellcanfield - not sure how to do that. BTW It's an Angular 18 application.
I have used this dynamic Loader logic but when I use react hooks like(useState,useEffect) in child app then it gives me script errors why is that ?
Are you sharing React and React DOM? Make sure it’s wrapped in a suspense on the host application
Can we also import cross platform, Like Host in React and One MF is on Angular with Module Federation 2.0 ?
Yes you can, check out the official examples
Nice topic and informative video. Thanks for this, but I have a question "Why we need to have all routes in host app, I think any child MF can have its own routes and can run browser routes. If any MF is exporting single componet then it make sense to have routes in host, otherwise child should have its own routing as whole frontend app". Can you get some time to explain downside of this approach or there is some technical difficuties. Thanks
You definitely can have routes in the child, mainly you need to be careful about route conflicts and ensure you share a singleton of react router with similar versions. It really depends on the complexity of the applications and what makes sense. But in some cases, owning routes can leech requirements down into the child modules
@@russellcanfield agree 👍 thanks again
Nice video!
Thanks!
Which version of NX library are you using?
This is an older version, here is a newer video which I believe is v19 Micro frontends - NX, Rspack, Module Federation with new Federated Types! ruclips.net/video/oJY92rZV8NE/видео.html
This is actually insanely good! Thanks
Thanks!
Nice, Why can't we use the runtime types. You explained in brief. What about directional. Host n remote Why can't we load the remote ts normal file?
Sorry what do you mean by runtime type? Types are only available in your IDE. Bi-directional should work fine, there were early versions in MFv1 where the types plugin would stall if it had to resolve type but that is resolved
@@russellcanfield loading modular config at run time like in bootstrap? Is it good/ bad to have all MFE's work as both host and remote? Will it affect the performance?
Fantastic video - very useful :)
Hi Russell, In my angular microfrontend project i have migrated to newer version of NX, now i am getting weird issue , any help would be apricated, I could not get any valid response on internet Uncaught TypeError: Failed to resolve module specifier "module". Relative references must start with either "/", "./", or "../". core.mjs:31064 Angular is running in development mode. app.module.ts:18 ERROR ChunkLoadError at __webpack_require__.f.j (jsonp chunk loading:27:1) at ensure chunk:6:1 at Array.reduce (<anonymous>) at __webpack_require__.e (ensure chunk:5:1) at Object.loadChildren (app.module.ts:18:26) at loadChildren (router.mjs:4365:37) at RouterConfigLoader.loadChildren (router.mjs:4340:40) at router.mjs:4029:46 at doInnerSub (mergeInternals.js:19:19) at outerNext (mergeInternals.js:14:57)
That offical example is gone?
This is good
Your all videos are in small font, please make future videos or remake these videos with zoom in fonta
ok, like you mentioned, nesting routers are very complex. So the easy way is to have all routes in host, and basically each nested route is a separate microfrontend? /users - microfrontend1 /users/:id - - microfrontend2 /users/:id/hobbies - microfrontend3 products - microfrontend4 products/:id - microfrontend5 In example above, routing will work without any problems.
yeah, im facing this situation right now, but what if my mfe has more than one page or has to manipulate the url params, it will not work
Great video, helped me a lot. However there is one scenario I struggle with. I want to be able to dynamically register remotes and then reload the module so that it now displays my other newly registered module. It works well on the federation side, however the module itself stays put and doesn't update (no matter if I use Suspence or not. Would it be interexsting for you to explore this scenario? The idea is to create a system with dynamic plugins that can be registered and deregistered at any time, so the client gets updates on currently active plugins and lets the user choose a plugin with automatic refresh of the plugin widget area. It's very easy to do with an iFrame, but it's a much more heavy solution.
@@moristar maybe introduce some sort of simple state, that when it registers it will update and trigger a re-render
@@russellcanfield I almost gave up until I realized that my two widgets have the same name in the rspack config :) It seems that if the modules have the same name where they were defined it will still work on the consumer side, but only for the first assignment and after that it will be stuck on the first remote no matter what. Here is the sample code for the module consumer. import './App.css'; import { lazy, useState, Suspense } from 'react'; import { loadRemote, registerRemotes } from '@module-federation/enhanced/runtime' const App = () => { const [CurrentWidget, setCurrentWidget] = useState(() => null); const [port, setCurrentPort] = useState(() => 3001); registerRemotes([ { name: "widgets", entry: "localhost:3000/mf-manifest.json" }, { name: "widgets_new", entry: "localhost:3001/mf-manifest.json" } ]); const reloadWidget = async () => { if (port === 3000) setCurrentPort(() => port + 1); else setCurrentPort(() => port - 1); const widgetName = 'widgets'+ (port === 3001 ? '_new' : '') + '/button'; console.log('Port: ' + port + '. Reloading from: ' + widgetName); setCurrentWidget(() => lazy(() => loadRemote(widgetName))); console.log(CurrentWidget); } return ( <div className="content"> <h1>Rsbuild with React</h1> <p>Start building amazing things with Rsbuild.</p> <button onClick={reloadWidget}>Reload</button> <div> <Suspense fallback={<div>Loading...</div>}> {CurrentWidget && <CurrentWidget />} </Suspense> </div> </div> ); }; export default App;
thanks alot for your video please make more video about micro frontend
Sure thing!
Awesome video! Like the way you introduce and explain everything. Btw, could you maintain repo react-nested-router with rspack and mf v2? Many thanks!
Any chance you could provide a tutorial for configuring a react host application that can load standalone remote Angular mfes as routes in nx? I can't find anything anywhere else that makes sense
Hi Russel, thanks a lot for your work. I wanna know if you have any idea about react router history.push not working in remote apps if the routing path is within the host app and how to fix this weird issue
Is react router shared as a singleton? You may need to make sure you are working on the same object reference
@russellcanfield Yes, the react router and react-router-dom are shared as singletons. And I don't have the routes redeclared in the remote app because I expect it to use the routes in the parent but it's still not working unfortunately. And it is also using the same routing history object reference that is declared in the host
couldnt find a tutorial on this topic, this is a great tutorial and explanation, thank you for this
Glad it was helpful!
Very good video, thanks for your content, I have tried to adopt Runtime for my project but I have encountered the problem of how to load a Stere from Jotai, before I was using import useStore from “button_provider/store”. const [count, setCount] = useCount(); But I have not been able to do the same with loadRemote and React.Lazy
I really like the pace. It feels like you actually want the users to understand module federation well! Been watching all your videos top G. Keep going!
Thanks! The videos to me always feel long but I try to walk through doing the work. I appreciate it.
@@russellcanfield IMO the module federation videos are primarily for us senior devs and slower pace is good for us.