+
{pages}
diff --git a/src/Routers/routes/AssetRoutes.tsx b/src/Routers/routes/AssetRoutes.tsx
index d3bd96ca437..ee0537d6c58 100644
--- a/src/Routers/routes/AssetRoutes.tsx
+++ b/src/Routers/routes/AssetRoutes.tsx
@@ -2,20 +2,23 @@ import AssetConfigure from "../../Components/Assets/AssetConfigure";
import AssetManage from "../../Components/Assets/AssetManage";
import AssetsList from "../../Components/Assets/AssetsList";
import AssetCreate from "../../Components/Facility/AssetCreate";
+import { AppRoutes } from "../AppRouter";
-export default {
+const AssetRoutes: AppRoutes = {
"/assets": () =>
,
-
- "/facility/:facilityId/assets/new": (params: any) => (
-
- ),
- "/facility/:facilityId/assets/:assetId/update": (params: any) => (
-
+ "/facility/:facilityId/assets/new": ({ facilityId }) => (
+
),
- "/facility/:facilityId/assets/:assetId": (params: any) => (
-
+ "/facility/:facilityId/assets/:assetId/update": ({ facilityId, assetId }) => (
+
),
- "/facility/:facilityId/assets/:assetId/configure": (params: any) => (
-
+ "/facility/:facilityId/assets/:assetId": ({ facilityId, assetId }) => (
+
),
+ "/facility/:facilityId/assets/:assetId/configure": ({
+ facilityId,
+ assetId,
+ }) =>
,
};
+
+export default AssetRoutes;
diff --git a/src/Routers/routes/ConsultationRoutes.tsx b/src/Routers/routes/ConsultationRoutes.tsx
index 598fd06adc3..7f1a7fecfb8 100644
--- a/src/Routers/routes/ConsultationRoutes.tsx
+++ b/src/Routers/routes/ConsultationRoutes.tsx
@@ -5,30 +5,30 @@ import ManagePrescriptions from "../../Components/Medicine/ManagePrescriptions";
import { DailyRoundListDetails } from "../../Components/Patient/DailyRoundListDetails";
import { DailyRounds } from "../../Components/Patient/DailyRounds";
import { ConsultationDetails } from "../../Components/Facility/ConsultationDetails";
-import TreatmentSummary, {
- ITreatmentSummaryProps,
-} from "../../Components/Facility/TreatmentSummary";
+import TreatmentSummary from "../../Components/Facility/TreatmentSummary";
import ConsultationDoctorNotes from "../../Components/Facility/ConsultationDoctorNotes";
import PatientConsentRecords from "../../Components/Patient/PatientConsentRecords";
import CriticalCareEditor from "../../Components/LogUpdate/CriticalCareEditor";
import PrescriptionsPrintPreview from "../../Components/Medicine/PrintPreview";
import CriticalCarePreview from "../../Components/LogUpdate/CriticalCarePreview";
import FileUploadPage from "../../Components/Patient/FileUploadPage";
+import InvestigationPrintPreview from "../../Components/Facility/Investigations/InvestigationsPrintPreview";
+import { AppRoutes } from "../AppRouter";
-export default {
+const consultationRoutes: AppRoutes = {
"/facility/:facilityId/patient/:patientId/consultation": ({
facilityId,
patientId,
- }: any) =>
,
+ }) =>
,
"/facility/:facilityId/patient/:patientId/consultation/:id/update": ({
facilityId,
patientId,
id,
- }: any) => (
+ }) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:id/consent-records":
- ({ facilityId, patientId, id }: any) => (
+ ({ facilityId, patientId, id }) => (
(
+ }) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/prescriptions":
- (path: any) => ,
+ (path) => ,
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/prescriptions/print":
() => ,
"/facility/:facilityId/patient/:patientId/consultation/:id/investigation": ({
facilityId,
patientId,
id,
- }: any) => (
+ }) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:id/investigation/:sessionId":
- ({ facilityId, patientId, id, sessionId }: any) => (
+ ({ facilityId, patientId, id, sessionId }) => (
),
+ "/facility/:facilityId/patient/:patientId/consultation/:id/investigation/:sessionId/print":
+ ({ facilityId, patientId, id, sessionId }: any) => (
+
+ ),
"/facility/:facilityId/patient/:patientId/consultation/:id/daily-rounds": ({
facilityId,
patientId,
id,
- }: any) => (
+ }) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily-rounds/:id/update":
- ({ facilityId, patientId, consultationId, id }: any) => (
+ ({ facilityId, patientId, consultationId, id }) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily-rounds/:id":
- ({ facilityId, patientId, consultationId, id }: any) => (
+ ({ facilityId, patientId, consultationId, id }) => (
),
-
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily_rounds/:id":
- (params: {
- facilityId: string;
- patientId: string;
- consultationId: string;
- id: string;
- }) => ,
+ ({ facilityId, patientId, consultationId, id }) => (
+
+ ),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/daily_rounds/:id/update":
- (params: {
- facilityId: string;
- patientId: string;
- consultationId: string;
- id: string;
- }) => ,
+ ({ facilityId, patientId, consultationId, id }) => (
+
+ ),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId": ({
facilityId,
patientId,
consultationId,
- }: any) => (
+ }) => (
),
- "/consultation/:consultationId": ({ consultationId }: any) => (
+ "/consultation/:consultationId": ({ consultationId }) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/treatment-summary":
- ({ facilityId, patientId, consultationId }: ITreatmentSummaryProps) => (
+ ({ facilityId, patientId, consultationId }) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/notes":
- ({ facilityId, patientId, consultationId }: any) => (
+ ({ facilityId, patientId, consultationId }) => (
),
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/:tab":
- ({ facilityId, patientId, consultationId, tab }: any) => (
+ ({ facilityId, patientId, consultationId, tab }) => (
),
};
+
+export default consultationRoutes;
diff --git a/src/Routers/routes/FacilityInventoryRoutes.tsx b/src/Routers/routes/FacilityInventoryRoutes.tsx
index 17e93b2bc60..99123d8f737 100644
--- a/src/Routers/routes/FacilityInventoryRoutes.tsx
+++ b/src/Routers/routes/FacilityInventoryRoutes.tsx
@@ -3,22 +3,25 @@ import InventoryList from "../../Components/Facility/InventoryList";
import InventoryLog from "../../Components/Facility/InventoryLog";
import MinQuantityList from "../../Components/Facility/MinQuantityList";
import { SetInventoryForm } from "../../Components/Facility/SetInventoryForm";
+import { AppRoutes } from "../AppRouter";
-export default {
- "/facility/:facilityId/inventory": ({ facilityId }: any) => (
+const FacilityInventoryRoutes: AppRoutes = {
+ "/facility/:facilityId/inventory": ({ facilityId }) => (
),
- "/facility/:facilityId/inventory/min_quantity/set": ({ facilityId }: any) => (
+ "/facility/:facilityId/inventory/min_quantity/set": ({ facilityId }) => (
),
- "/facility/:facilityId/inventory/min_quantity/list": ({
- facilityId,
- }: any) => ,
- "/facility/:facilityId/inventory/min_quantity": ({ facilityId }: any) => (
+ "/facility/:facilityId/inventory/min_quantity/list": ({ facilityId }) => (
+
+ ),
+ "/facility/:facilityId/inventory/min_quantity": ({ facilityId }) => (
),
"/facility/:facilityId/inventory/:inventoryId": ({
facilityId,
inventoryId,
- }: any) => ,
+ }) => ,
};
+
+export default FacilityInventoryRoutes;
diff --git a/src/Routers/routes/FacilityLocationRoutes.tsx b/src/Routers/routes/FacilityLocationRoutes.tsx
index 5d547ebd466..c2e1add4b10 100644
--- a/src/Routers/routes/FacilityLocationRoutes.tsx
+++ b/src/Routers/routes/FacilityLocationRoutes.tsx
@@ -6,41 +6,42 @@ import LocationManagement from "../../Components/Facility/LocationManagement";
import CentralLiveMonitoring from "../../Components/CameraFeed/CentralLiveMonitoring";
import { AuthorizeUserRoute } from "../../Utils/AuthorizeFor";
import { CameraFeedPermittedUserTypes } from "../../Utils/permissions";
+import { AppRoutes } from "../AppRouter";
-export default {
- "/facility/:facilityId/location": ({ facilityId }: any) => (
+const FacilityLocationRoutes: AppRoutes = {
+ "/facility/:facilityId/location": ({ facilityId }) => (
),
"/facility/:facilityId/location/:locationId/beds": ({
facilityId,
locationId,
- }: any) => ,
- "/facility/:facilityId/inventory/add": ({ facilityId }: any) => (
+ }) => ,
+ "/facility/:facilityId/inventory/add": ({ facilityId }) => (
),
- "/facility/:facilityId/location/add": ({ facilityId }: any) => (
+ "/facility/:facilityId/location/add": ({ facilityId }) => (
),
"/facility/:facilityId/location/:locationId/update": ({
facilityId,
locationId,
- }: any) => (
-
- ),
+ }) => ,
"/facility/:facilityId/location/:locationId/beds/add": ({
facilityId,
locationId,
- }: any) => ,
+ }) => ,
"/facility/:facilityId/location/:locationId/beds/:bedId/update": ({
facilityId,
locationId,
bedId,
- }: any) => (
+ }) => (
),
- "/facility/:facilityId/live-monitoring": (props: any) => (
+ "/facility/:facilityId/live-monitoring": ({ facilityId }) => (
-
+
),
};
+
+export default FacilityLocationRoutes;
diff --git a/src/Routers/routes/FacilityRoutes.tsx b/src/Routers/routes/FacilityRoutes.tsx
index 2c711cf48cb..16b202ae0ce 100644
--- a/src/Routers/routes/FacilityRoutes.tsx
+++ b/src/Routers/routes/FacilityRoutes.tsx
@@ -2,48 +2,47 @@ import { FacilityConfigure } from "../../Components/Facility/FacilityConfigure";
import { FacilityCreate } from "../../Components/Facility/FacilityCreate";
import { FacilityHome } from "../../Components/Facility/FacilityHome";
import FacilityUsers from "../../Components/Facility/FacilityUsers";
-import { HospitalList } from "../../Components/Facility/HospitalList";
+import { FacilityList } from "../../Components/Facility/FacilityList";
import { TriageForm } from "../../Components/Facility/TriageForm";
import ResourceCreate from "../../Components/Resource/ResourceCreate";
import CentralNursingStation from "../../Components/Facility/CentralNursingStation";
import FacilityLocationRoutes from "./FacilityLocationRoutes";
import FacilityInventoryRoutes from "./FacilityInventoryRoutes";
import DischargedPatientsList from "../../Components/Facility/DischargedPatientsList";
+import { AppRoutes } from "../AppRouter";
-export default {
- "/facility": () => ,
+const FacilityRoutes: AppRoutes = {
+ "/facility": () => ,
"/facility/create": () => ,
- "/facility/:facilityId/update": ({ facilityId }: any) => (
+ "/facility/:facilityId/update": ({ facilityId }) => (
),
- "/facility/:facilityId/configure": ({ facilityId }: any) => (
+ "/facility/:facilityId/configure": ({ facilityId }) => (
),
- "/facility/:facilityId/cns": ({ facilityId }: any) => (
+ "/facility/:facilityId/cns": ({ facilityId }) => (
),
- "/facility/:facilityId": ({ facilityId }: any) => (
+ "/facility/:facilityId": ({ facilityId }) => (
),
- "/facility/:id/discharged-patients": ({ id }: any) => (
+ "/facility/:id/discharged-patients": ({ id }) => (
),
-
- "/facility/:facilityId/users": ({ facilityId }: any) => (
+ "/facility/:facilityId/users": ({ facilityId }) => (
),
- "/facility/:facilityId/resource/new": ({ facilityId }: any) => (
+ "/facility/:facilityId/resource/new": ({ facilityId }) => (
),
-
- // Triage related routes
- "/facility/:facilityId/triage": ({ facilityId }: any) => (
+ "/facility/:facilityId/triage": ({ facilityId }) => (
),
- "/facility/:facilityId/triage/:id": ({ facilityId, id }: any) => (
+ "/facility/:facilityId/triage/:id": ({ facilityId, id }) => (
),
-
...FacilityLocationRoutes,
...FacilityInventoryRoutes,
};
+
+export default FacilityRoutes;
diff --git a/src/Routers/routes/HCXRoutes.tsx b/src/Routers/routes/HCXRoutes.tsx
index 80378b24621..929cc3f12bb 100644
--- a/src/Routers/routes/HCXRoutes.tsx
+++ b/src/Routers/routes/HCXRoutes.tsx
@@ -1,10 +1,15 @@
-import ConsultationClaims, {
- IConsultationClaimsProps,
-} from "../../Components/Facility/ConsultationClaims";
+import ConsultationClaims from "../../Components/Facility/ConsultationClaims";
+import { AppRoutes } from "../AppRouter";
-export default {
+const HCXRoutes: AppRoutes = {
"/facility/:facilityId/patient/:patientId/consultation/:consultationId/claims":
- (pathParams: IConsultationClaimsProps) => (
-
+ ({ facilityId, patientId, consultationId }) => (
+
),
};
+
+export default HCXRoutes;
diff --git a/src/Routers/routes/PatientRoutes.tsx b/src/Routers/routes/PatientRoutes.tsx
index fcfc9b04e37..45ff044e4d2 100644
--- a/src/Routers/routes/PatientRoutes.tsx
+++ b/src/Routers/routes/PatientRoutes.tsx
@@ -3,44 +3,44 @@ import { PatientManager } from "../../Components/Patient/ManagePatients";
import { PatientHome } from "../../Components/Patient/PatientHome";
import PatientNotes from "../../Components/Patient/PatientNotes";
import { PatientRegister } from "../../Components/Patient/PatientRegister";
-import { DetailRoute } from "../types";
import DeathReport from "../../Components/DeathReport/DeathReport";
import { InsuranceDetails } from "../../Components/Patient/InsuranceDetails";
import FileUploadPage from "../../Components/Patient/FileUploadPage";
+import { AppRoutes } from "../AppRouter";
-export default {
+const PatientRoutes: AppRoutes = {
"/patients": () => ,
- "/patient/:id": ({ id }: DetailRoute) => ,
- "/patient/:id/investigation_reports": ({ id }: DetailRoute) => (
+ "/patient/:id": ({ id }) => ,
+ "/patient/:id/investigation_reports": ({ id }) => (
),
-
- // Facility Scoped Routes
- "/facility/:facilityId/patient": ({ facilityId }: any) => (
+ "/facility/:facilityId/patient": ({ facilityId }) => (
),
- "/facility/:facilityId/patient/:id": ({ facilityId, id }: any) => (
+ "/facility/:facilityId/patient/:id": ({ facilityId, id }) => (
),
- "/facility/:facilityId/patient/:id/insurance": ({ facilityId, id }: any) => (
+ "/facility/:facilityId/patient/:id/insurance": ({ facilityId, id }) => (
),
- "/facility/:facilityId/patient/:id/update": ({ facilityId, id }: any) => (
+ "/facility/:facilityId/patient/:id/update": ({ facilityId, id }) => (
),
"/facility/:facilityId/patient/:patientId/notes": ({
facilityId,
patientId,
- }: any) => ,
+ }) => ,
"/facility/:facilityId/patient/:patientId/files": ({
facilityId,
patientId,
- }: any) => (
+ }) => (
),
- "/death_report/:id": ({ id }: any) => ,
+ "/death_report/:id": ({ id }) => ,
};
+
+export default PatientRoutes;
diff --git a/src/Routers/routes/ResourceRoutes.tsx b/src/Routers/routes/ResourceRoutes.tsx
index 6636d0d83ea..d75c933f760 100644
--- a/src/Routers/routes/ResourceRoutes.tsx
+++ b/src/Routers/routes/ResourceRoutes.tsx
@@ -3,17 +3,17 @@ import { ResourceDetailsUpdate } from "../../Components/Resource/ResourceDetails
import ListView from "../../Components/Resource/ListView";
import BoardView from "../../Components/Resource/ResourceBoardView";
import { Redirect } from "raviger";
-import { DetailRoute } from "../types";
+import { AppRoutes } from "../AppRouter";
const getDefaultView = () =>
localStorage.getItem("defaultResourceView") === "list" ? "list" : "board";
-export default {
+const ResourceRoutes: AppRoutes = {
"/resource": () => ,
"/resource/board": () => ,
"/resource/list": () => ,
- "/resource/:id": ({ id }: DetailRoute) => ,
- "/resource/:id/update": ({ id }: DetailRoute) => (
-
- ),
+ "/resource/:id": ({ id }) => ,
+ "/resource/:id/update": ({ id }) => ,
};
+
+export default ResourceRoutes;
diff --git a/src/Routers/routes/SampleRoutes.tsx b/src/Routers/routes/SampleRoutes.tsx
index 290a34fd4eb..cf296790a81 100644
--- a/src/Routers/routes/SampleRoutes.tsx
+++ b/src/Routers/routes/SampleRoutes.tsx
@@ -2,24 +2,22 @@ import { SampleDetails } from "../../Components/Patient/SampleDetails";
import SampleReport from "../../Components/Patient/SamplePreview";
import { SampleTest } from "../../Components/Patient/SampleTest";
import SampleViewAdmin from "../../Components/Patient/SampleViewAdmin";
-import { DetailRoute, RouteParams } from "../types";
+import { AppRoutes } from "../AppRouter";
-export default {
+const SampleRoutes: AppRoutes = {
"/sample": () => ,
- "/sample/:id": ({ id }: DetailRoute) => ,
+ "/sample/:id": ({ id }) => ,
"/patient/:patientId/test_sample/:sampleId/icmr_sample": ({
patientId,
sampleId,
- }: RouteParams<"patientId" | "sampleId">) => (
-
- ),
+ }) => ,
"/facility/:facilityId/patient/:patientId/sample-test": ({
facilityId,
patientId,
- }: RouteParams<"facilityId" | "patientId">) => (
-
+ }) => ,
+ "/facility/:facilityId/patient/:patientId/sample/:id": ({ id }) => (
+
),
- "/facility/:facilityId/patient/:patientId/sample/:id": ({
- id,
- }: DetailRoute) => ,
};
+
+export default SampleRoutes;
diff --git a/src/Routers/routes/ShiftingRoutes.tsx b/src/Routers/routes/ShiftingRoutes.tsx
index f2e12de4f25..dc11ff2b8ee 100644
--- a/src/Routers/routes/ShiftingRoutes.tsx
+++ b/src/Routers/routes/ShiftingRoutes.tsx
@@ -4,18 +4,21 @@ import { ShiftDetailsUpdate } from "../../Components/Shifting/ShiftDetailsUpdate
import ListView from "../../Components/Shifting/ListView";
import BoardView from "../../Components/Shifting/BoardView";
import { Redirect } from "raviger";
+import { AppRoutes } from "../AppRouter";
const getDefaultView = () =>
localStorage.getItem("defaultShiftView") === "list" ? "list" : "board";
-export default {
+const ShiftingRoutes: AppRoutes = {
"/shifting": () => ,
"/shifting/board": () => ,
"/shifting/list": () => ,
- "/shifting/:id": ({ id }: any) => ,
- "/shifting/:id/update": ({ id }: any) => ,
+ "/shifting/:id": ({ id }) => ,
+ "/shifting/:id/update": ({ id }) => ,
"/facility/:facilityId/patient/:patientId/shift/new": ({
facilityId,
patientId,
- }: any) => ,
+ }) => ,
};
+
+export default ShiftingRoutes;
diff --git a/src/Routers/routes/UserRoutes.tsx b/src/Routers/routes/UserRoutes.tsx
index 56877ca4c78..24f355b201b 100644
--- a/src/Routers/routes/UserRoutes.tsx
+++ b/src/Routers/routes/UserRoutes.tsx
@@ -1,9 +1,12 @@
import ManageUsers from "../../Components/Users/ManageUsers";
import { UserAdd } from "../../Components/Users/UserAdd";
import UserProfile from "../../Components/Users/UserProfile";
+import { AppRoutes } from "../AppRouter";
-export default {
+const UserRoutes: AppRoutes = {
"/users": () => ,
"/users/add": () => ,
"/user/profile": () => ,
};
+
+export default UserRoutes;
diff --git a/src/Utils/useTimer.tsx b/src/Utils/useTimer.tsx
index 6a8d8320c5e..f7a03ffefa0 100644
--- a/src/Utils/useTimer.tsx
+++ b/src/Utils/useTimer.tsx
@@ -27,7 +27,7 @@ export const useTimer = (autoStart = false) => {
const [time, setTime] = useState(0);
useEffect(() => {
- let interval: number;
+ let interval: ReturnType;
if (running) {
interval = setInterval(() => {
setTime((prevTime) => prevTime + 1);
diff --git a/src/pluginTypes.ts b/src/pluginTypes.ts
new file mode 100644
index 00000000000..26a07e4f141
--- /dev/null
+++ b/src/pluginTypes.ts
@@ -0,0 +1,54 @@
+import { LazyExoticComponent } from "react";
+import { UserAssignedModel } from "./Components/Users/models";
+import { AppRoutes } from "./Routers/AppRouter";
+import { INavItem } from "./Components/Common/Sidebar/Sidebar";
+import { pluginMap } from "./pluginMap";
+
+// Define the available plugins
+export type AvailablePlugin = "@apps/care_livekit_fe";
+
+export type AvailablePluginManifest = "@app-manifest/care_livekit_fe";
+
+export type DoctorConnectButtonComponentType = React.FC<{
+ user: UserAssignedModel;
+}>;
+
+// Define supported plugin components
+export type SupportedPluginComponents = {
+ DoctorConnectButtons: DoctorConnectButtonComponentType;
+};
+
+// Create a type for lazy-loaded components
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+type LazyComponent> = LazyExoticComponent;
+
+// Define PluginComponentMap with lazy-loaded components
+export type PluginComponentMap = {
+ [K in keyof SupportedPluginComponents]?: LazyComponent<
+ SupportedPluginComponents[K]
+ >;
+};
+
+type SupportedPluginExtensions =
+ | "DoctorConnectButtons"
+ | "PatientExternalRegistration";
+
+export type PluginManifest = {
+ plugin: string;
+ routes: AppRoutes;
+ extends: SupportedPluginExtensions[];
+ components: PluginComponentMap;
+ navItems: INavItem[];
+};
+
+// Create a type that ensures only available plugins can be used
+export type EnabledPluginConfig = {
+ plugin: string;
+ manifestPath: AvailablePluginManifest;
+ path: AvailablePlugin;
+ manifest: Promise;
+ // Components are a dictionary, with the key being the component name, and the value being the component type
+ components: PluginComponentMap;
+};
+
+export { pluginMap };
diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts
index 7657f7da19e..f339922bfae 100644
--- a/src/vite-env.d.ts
+++ b/src/vite-env.d.ts
@@ -31,6 +31,7 @@ interface ImportMetaEnv {
readonly REACT_JWT_TOKEN_REFRESH_INTERVAL?: string;
readonly REACT_MIN_ENCOUNTER_DATE?: string;
readonly REACT_ALLOWED_LOCALES?: string;
+ readonly REACT_ENABLED_APPS?: string;
// Plugins related envs...
readonly REACT_PLAUSIBLE_SERVER_URL?: string;
diff --git a/tsconfig.json b/tsconfig.json
index 531d6f800e1..51ffeb4a0ae 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -19,9 +19,12 @@
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
+ "@core/*": ["src/*"],
+ "@apps/*": ["apps/*/src"],
+ "@app-manifest/*": ["apps/*/src/manifest.ts"],
"@careConfig": ["./care.config.ts"]
}
},
- "include": ["src", "care.config.ts"],
+ "include": ["src/**/*", "apps/**/*", "care.config.ts"],
"exclude": ["src/**/*.gen.tsx"]
}
diff --git a/vite.config.mts b/vite.config.mts
index acb0cdf727b..905374eb923 100644
--- a/vite.config.mts
+++ b/vite.config.mts
@@ -1,10 +1,12 @@
-import path from "node:path";
+import path from "path";
import { createRequire } from "node:module";
import { VitePWA } from "vite-plugin-pwa";
import react from "@vitejs/plugin-react-swc";
import checker from "vite-plugin-checker";
import { viteStaticCopy } from "vite-plugin-static-copy";
import { treeShakeCareIcons } from "./plugins/treeShakeCareIcons";
+import fs from "fs";
+import { defineConfig } from "vite";
const pdfWorkerPath = path.join(
path.dirname(
@@ -22,8 +24,56 @@ const cdnUrls =
"http://localhost:4566",
].join(" ");
+function getPluginAliases() {
+ const pluginsDir = path.resolve(__dirname, "apps");
+ // Make sure the `apps` folder exists
+ if (!fs.existsSync(pluginsDir)) {
+ return {};
+ }
+ const pluginFolders = fs.readdirSync(pluginsDir);
+
+ const aliases = {};
+
+ pluginFolders.forEach((pluginFolder) => {
+ const pluginSrcPath = path.join(pluginsDir, pluginFolder, "src");
+ if (fs.existsSync(pluginSrcPath)) {
+ aliases[`@apps/${pluginFolder}`] = pluginSrcPath;
+ aliases[`@app-manifest/${pluginFolder}`] = path.join(
+ pluginSrcPath,
+ "manifest.ts",
+ );
+ }
+ });
+
+ return aliases;
+}
+
+function getPluginDependencies() {
+ const pluginsDir = path.resolve(__dirname, "apps");
+ // Make sure the `apps` folder exists
+ if (!fs.existsSync(pluginsDir)) {
+ return [];
+ }
+ const pluginFolders = fs.readdirSync(pluginsDir);
+
+ const dependencies = new Set();
+
+ pluginFolders.forEach((pluginFolder) => {
+ const packageJsonPath = path.join(pluginsDir, pluginFolder, "package.json");
+ if (fs.existsSync(packageJsonPath)) {
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
+ const pluginDependencies = packageJson.dependencies
+ ? Object.keys(packageJson.dependencies)
+ : [];
+ pluginDependencies.forEach((dep) => dependencies.add(dep));
+ }
+ });
+
+ return Array.from(dependencies);
+}
+
/** @type {import('vite').UserConfig} */
-export default {
+export default defineConfig({
envPrefix: "REACT_",
plugins: [
viteStaticCopy({
@@ -86,10 +136,15 @@ export default {
],
resolve: {
alias: {
+ ...getPluginAliases(),
"@": path.resolve(__dirname, "./src"),
"@careConfig": path.resolve(__dirname, "./care.config.ts"),
+ "@core": path.resolve(__dirname, "src/"),
},
},
+ optimizeDeps: {
+ include: getPluginDependencies(),
+ },
build: {
outDir: "build",
assetsDir: "bundle",
@@ -118,4 +173,4 @@ export default {
},
port: 4000,
},
-};
+});