Module Federation Into Production

  Рет қаралды 13,462

Jack Herrington

Jack Herrington

Күн бұрын

Пікірлер
@DrSarge37
@DrSarge37 3 жыл бұрын
Next do it with dynamic URLs. The reason I suggest that is because there could be different environments people work on.
@ajay.canada
@ajay.canada Жыл бұрын
I am getting a CORS error on host site when following the same steps you mentioned, Any idea how to fix that?
@aybo339
@aybo339 Жыл бұрын
Hi, Iam also getting a CORS error, were you able to fix it?
@Rutvik_Choudhary
@Rutvik_Choudhary 8 ай бұрын
Hey jack, constantly following you for micro-frontend concepts and really amazing content. I wanted to know when we are exposing the module the remoteEntry.js file is also accessible to the consumer app. How to add some authentication to that endpoint. i don't want everyone to use it. Thank you.
@jherr
@jherr 8 ай бұрын
Remote modules are just Javascript files. They should be deployed via S3 or CDN and do not rely on the host application running in order to serve them. You could put some security around the modules, I suppose, but do you do that with the JavaScript you deploy now? Secure your API endpoints, thats the most important thing.
@avanishpatel4936
@avanishpatel4936 Жыл бұрын
Hi Jack, Great video, I'm wondering how the versioning and deployment would work with AWS S3 or some other storage?
@Silverforger
@Silverforger 2 ай бұрын
Thanks for this man, was looking how to setup different URL paths for development and production because all I'm getting was a blank white page (like you showed early on the video ^^).
@Andreagilmour
@Andreagilmour Жыл бұрын
very nice video, is possible specify a branch name for shared header ? i.e. in header repository creata a branch named "blue" , in the consumer app in the remote section i can specify the branch "blue"?
@grishavasilyan
@grishavasilyan 2 жыл бұрын
Hi Thanks, What I understand every part of micro-frontend after deploying should be run on the different port. Is it right?
@jherr
@jherr 2 жыл бұрын
No, that's not right. We only run them on different ports in development. In production everything should be deployed to something like S3 and served off of port 80 or 443.
@grishavasilyan
@grishavasilyan 2 жыл бұрын
@@jherr Thanks for answer. I got it
@grishavasilyan
@grishavasilyan 2 жыл бұрын
@@jherr In vercel can we do somthing like that?
@EveryDayAIProgrammer
@EveryDayAIProgrammer 4 жыл бұрын
In the consumer app we are referring to /remoteEntry.js but in actual production we would have some CDN which will append some kind of HTTP Cache hearders which will cache this file, so how to version remoteEntry.js so that caching this remoteEntry File is not a issue
@jherr
@jherr 4 жыл бұрын
I'd set the caching on remoteEntry short and the caching on everything else to long.
@vipulnema
@vipulnema Жыл бұрын
Thanks Jack, This is very helpful and practical video. I had some queries, after going through comments and your reply, all resolved now, But if you create new video that include these comments questions-answers then it would be so helpful to others .
@georgeiliadis2236
@georgeiliadis2236 3 жыл бұрын
How would you go about exporting the consumer project into production, without the module federation. Would it be possible to fetch and include the federated modules into a bundle?
@jherr
@jherr 3 жыл бұрын
So you just want to version lock it by copying the current version of the module to defeat the runtime loading?
@geoili
@geoili 3 жыл бұрын
@@jherr Pretty much, when i run build, i want to be able to deploy that without having to worry hosting the base project somewhere for it to fetch the shared components. Essentially I just want to federate modules during development only, and when i make my production build I need it to be autonomous.
@jherr
@jherr 3 жыл бұрын
@@geoili Ok... I haven't heard that particular use case, but my recommendation would be to use a monorepo, and have your federated modules shared both as hard dependencies and also federated dependencies. Then in the case of prod mode just remove the module federation configuration from the webpack config.
@geoili
@geoili 3 жыл бұрын
​@@jherr hmm, that's essentially doing the same thing twice though isn't it? Thank you for the quick response!
@jherr
@jherr 3 жыл бұрын
@@geoili yeah, but you do want to do two thing. you want to have a build time dependency in one case and a runtime dependency in another. you could do some fun automation in there with something like NX to automatically create the runtime dependency, but... something is going to have to do that work.
@andrejnsimoes
@andrejnsimoes 4 жыл бұрын
Great :) thanks. Is it possible to conditionally use the deployed header or the local one (production vs development)?
@jherr
@jherr 4 жыл бұрын
Blargh! I knew there was something I forgot to add to the video. I was intending to cover that and to use environment variables for it. So like: > LOCAL_REMOTES=header yarn dev And then I'd do: const localRemotes = (process.env.LOCAL_REMOTES || "").split(','); To break it out into an array in webpack.config.js. Then in the `remotes` key definition I'd switch on localRemotes.includes('header') or something like that.
@shanaullahkhan1279
@shanaullahkhan1279 Жыл бұрын
I want to keep code in one repo and divide into separate features like ProductPage, CartPage, CategoryListingPage and different team is working on each separate features. I want a freedom on build & Deployment of features separately without running on multiple ports, can you please suggest approach, tool to achieve this requirement
@jherr
@jherr Жыл бұрын
Use a monorepo like Nx or Turborepo and have each team have their own module with their own features. Or if you are using the App Router you can use route groups to give each team their own dedicated folder.
@shashankjoshi8250
@shashankjoshi8250 Жыл бұрын
When it comes enterprise we will have different ENV like SIT, UAT and PROD each with different urls, how can we dynamically load individual environment urls with one config setup? Can you please answer this question?
@artemu78
@artemu78 4 жыл бұрын
Awesome as usual. Thanks Jack.
@rjmunt
@rjmunt 4 жыл бұрын
New to the channel, thanks a lot your content is amazing! Is there any way to get code completion with TS when referencing the remote components ? Or must I have a type definition in the app that is doing the importing ?
@jherr
@jherr 4 жыл бұрын
I think you have to declare it in the app that's doing the importing. Module Federation is run-time and TS checking is compile time. What you could do is have a secondary NPM module with the type "contract" and then you depend on that contract in your consuming application. And you also import that into the module federation remote project to ensure that the federated module matches the contract as well.
@jasonthorpe3470
@jasonthorpe3470 2 жыл бұрын
Another option is to organize components into a monorepo (e.g. something that uses workspaces, and put shared typings that declare the contracts into a shared workspace that is imported into each of the federated components. To be perfectly honest, that's the dream, and the reality that I've experienced with npm workspaces and learna introduces more headaches, and in the past, I just end up using the npm's "file::" syntax to specify the location of the shared package that contains the contracts / typings for the exposed components.
@jasonthorpe3470
@jasonthorpe3470 2 жыл бұрын
PS, I'm in the process of learning Rushjs, which promises a better experience than npm workspaces or lerna, but it's to early the process for me to give it an informed thumbs up...
@pedroloureiro874
@pedroloureiro874 2 жыл бұрын
How to handle if a shell app imports two remotes and one of them crashes? In my situation i have one remote crashing that will cause the shell to stop working aswell.
@jherr
@jherr 2 жыл бұрын
Use react error boundaries.
@dominikabieder7477
@dominikabieder7477 2 жыл бұрын
can you use a deployed to prod repo link when running npm start with webpack development mode?
@vineetchaurasia7460
@vineetchaurasia7460 3 жыл бұрын
How we can deploy app on tomact?
@jherr
@jherr 3 жыл бұрын
All of this is just bundled JS files, so they should be deployed to an asset store (e.g. S3) and then referenced with script tags on the pages that you create from your Tomcat server. (Wow I haven't heard that name in a while.)
@ozzolim
@ozzolim 2 жыл бұрын
Is there any method to do that without hosting the provider app into a server. I mean build provider app and consumer app adds generated static files from the provider app. Like adding a page inside another page from a react build into another
@jherr
@jherr 2 жыл бұрын
If you are looking for generated stuff my advice is to go with build time stuff. It doesn't make much sense to generate off of a snapshot of a federated module. You just lose the dynamic loading behavior.
@ЕвгенийАл-л3е
@ЕвгенийАл-л3е 3 жыл бұрын
Thanks, just to understand the base idea
@noherczeg
@noherczeg 4 жыл бұрын
The fallback value in the ternary should be "/" so it'd work on any deployment target right (given module is mapped to root)?
@jherr
@jherr 4 жыл бұрын
Probably true.
@mikealejandro3938
@mikealejandro3938 3 жыл бұрын
You're a great human being
@jherr
@jherr 3 жыл бұрын
Thanks!
@zigmasslusnys3596
@zigmasslusnys3596 4 жыл бұрын
Your channel is underrated. I enjoy these videos even tho I found you just now through an article that I was searching for new features in webpack 5. A question popped while watching this video is how would we prevent other applications trying to get specific remoteEntry files to see what that code does? (Keep in mind I haven't played around with webpack5 yet). I suppose we could use minification? But that requires a sourcefile for it, would be have to store that also on a dedicated place for both apps to access? Thanks for the content!
@jherr
@jherr 4 жыл бұрын
Thanks! In production the remoteEntry.js would be minified and uglified, but that's just security through obscurity. Honestly, I don't think Module Federation is any more or less than any other code you to the client. From a security perspective I think of it as largely similar to code splitting. The only difference being that you are exposing named entry points. Which you could obscure, but I doubt that would add much security.
@mmmmmmm8706
@mmmmmmm8706 4 жыл бұрын
Really nice ....... thank you! Great tip in the development vs production modes
@herbertpimentel
@herbertpimentel 3 жыл бұрын
why "argv.mode" and not "arg.environment" is it something from webpack !?
@belaxion
@belaxion 4 жыл бұрын
Hi Jack, thanks for the concise explainer! In the remotes key, is the `header@some-url.com/remoteEntry.js` used by HtmlWebpackPlugin to insert the script tag into the HTML template?
@jherr
@jherr 4 жыл бұрын
I don't think so, I think it's JS injected by one of the plugins used by the ModuleFederationPlugin. The ModuleFederationPlugin is just syntactic sugar around three plugins and I'm doing this from memory, but I think one of those handles the remotes and that's probably the one that does it.
@jashoooo
@jashoooo 4 жыл бұрын
Is webpack5 fully ready for production apps ?
@noherczeg
@noherczeg 4 жыл бұрын
Still in beta if you check out the tags.
@zackjackson9674
@zackjackson9674 4 жыл бұрын
In beta but production stable. I’ve got it in production without issue
@junaid315
@junaid315 3 жыл бұрын
Is Module Federation production ready?
@jherr
@jherr 3 жыл бұрын
It is in production on commercial sites.
@rsrini7
@rsrini7 4 жыл бұрын
Excellent thanks
@erkanisuf3604
@erkanisuf3604 2 жыл бұрын
Amazing
Flexible Forms with React Hook Form
23:45
Jack Herrington
Рет қаралды 10 М.
Five Module Federation/Micro-Frontend Mistakes
28:09
Jack Herrington
Рет қаралды 49 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
State Management for Module Federation Four Ways
31:23
Jack Herrington
Рет қаралды 42 М.
Micro Frontends - Vite, RSBuild and Module Federation V2
17:02
Russell Canfield
Рет қаралды 989
Вадим Малютин - Как готовить production с Webpack 5 module federation
58:07
HolyJS — конференция для JavaScript‑разработчиков
Рет қаралды 11 М.
Typescript with Module Federation ||  TypeScript Tutorial
14:44
Jack Herrington
Рет қаралды 19 М.
Vite and Module Federation Makes Micro-Frontends EASY!
27:36
Jack Herrington
Рет қаралды 100 М.
Micro Frontend in Angular using Angular Elements | Micro Frontend
16:51
Fun Of Heuristic
Рет қаралды 38 М.
Introducing Module Federation in Webpack 5
10:39
Jack Herrington
Рет қаралды 89 М.
Mastering Micro-Frontends With RSpack and Module Federation
12:54
Jack Herrington
Рет қаралды 16 М.
Micro Frontends - Module Federation Dynamic Remotes with fallback (v2).
21:38
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН