Skip to content

Commit

Permalink
Updates to use core components in microfrontends
Browse files Browse the repository at this point in the history
  • Loading branch information
gigincg committed Nov 26, 2024
1 parent 115e353 commit 5ed9fd5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 13 additions & 2 deletions src/components/CareLivekit.tsx
Original file line number Diff line number Diff line change
@@ -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 <div>CareLivekit</div>;
return (
<Suspense fallback={<div>Loading...</div>}>
<div>
{PageTitle ? (
<PageTitle title="CareLivekit" />
) : (
"PageTitle not available"
)}
</div>
</Suspense>
);
};

export default CareLivekit;
7 changes: 6 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <div>Hello from CareLivekit!</div>;
return (
<div>
<PageTitle title="CareLivekit" />
</div>
);
};

export default CareLivekit;
25 changes: 8 additions & 17 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}),
Expand All @@ -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",
},
},
});

0 comments on commit 5ed9fd5

Please sign in to comment.