From 5ed9fd5345271a298a22aa684a009d40e31c2724 Mon Sep 17 00:00:00 2001 From: Gigin George Date: Tue, 26 Nov 2024 06:30:32 +0530 Subject: [PATCH] Updates to use core components in microfrontends --- package-lock.json | 4 ++-- package.json | 4 ++-- src/components/CareLivekit.tsx | 15 +++++++++++++-- src/index.tsx | 7 ++++++- vite.config.ts | 25 ++++++++----------------- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 148f2ad..d542744 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,8 @@ }, "devDependencies": { "@originjs/vite-plugin-federation": "^1.3.6", - "@types/react": "^18.0.28", - "@types/react-dom": "^18.0.11", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^3.1.0", "typescript": "^4.9.3", "vite": "^4.2.0" diff --git a/package.json b/package.json index 6eff500..406edc4 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ }, "devDependencies": { "@originjs/vite-plugin-federation": "^1.3.6", - "@types/react": "^18.0.28", - "@types/react-dom": "^18.0.11", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", "@vitejs/plugin-react": "^3.1.0", "typescript": "^4.9.3", "vite": "^4.2.0" diff --git a/src/components/CareLivekit.tsx b/src/components/CareLivekit.tsx index a8be91e..2a67e1b 100644 --- a/src/components/CareLivekit.tsx +++ b/src/components/CareLivekit.tsx @@ -1,7 +1,18 @@ -import React from "react"; +import React, { Suspense } from "react"; +const PageTitle = React.lazy(() => import("core/PageTitle")); const CareLivekit: React.FC = () => { - return
CareLivekit
; + return ( + Loading...}> +
+ {PageTitle ? ( + + ) : ( + "PageTitle not available" + )} +
+
+ ); }; export default CareLivekit; diff --git a/src/index.tsx b/src/index.tsx index 0862084..bbf5306 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,9 +3,14 @@ // export { default as manifest } from "./manifest"; // export { default as routes } from "./routes"; import React from "react"; +import { PageTitle } from "core"; const CareLivekit: React.FC = () => { - return
Hello from CareLivekit!
; + return ( +
+ +
+ ); }; export default CareLivekit; diff --git a/vite.config.ts b/vite.config.ts index 4befa36..9ee713e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,18 +9,14 @@ export default defineConfig({ name: "care_livekit", filename: "remoteEntry.js", exposes: { - // Expose the CareLivekit component - "./CareLivekit": { - import: "./src/components/CareLivekit.tsx", - name: "CareLivekit", - }, + "./CareLivekit": "./src/components/CareLivekit.tsx", }, - shared: { - react: { - requiredVersion: "^18.0.0", - }, - "react-dom": { - requiredVersion: "^18.0.0", + remotes: { + core: { + external: + 'Promise.resolve(window.location.origin + "/bundle/sharedCore.js")', + from: "vite", + externalType: "promise", }, }, }), @@ -33,16 +29,11 @@ export default defineConfig({ polyfill: false, }, rollupOptions: { + external: ["core/PageTitle"], output: { format: "esm", entryFileNames: "assets/[name].js", - minifyInternalExports: false, }, }, }, - resolve: { - alias: { - "@": "/src", - }, - }, });