Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(fix) Improve code splitting and dependencies #1468

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,10 @@
"test-e2e": "playwright test",
"postinstall": "husky install"
},
"dependencies": {
"@hookform/resolvers": "^3.3.1",
"@internationalized/date": "^3.5.4",
"classnames": "^2.3.2",
"react-hook-form": "^7.46.2",
"swr": "^2.0.1",
"xlsx": "^0.18.5",
"zod": "^3.22.2"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@carbon/react": "^1.71.0",
"@openmrs/esm-framework": "next",
"@openmrs/esm-patient-common-lib": "next",
"@playwright/test": "1.49.0",
"@swc/core": "^1.2.165",
"@swc/jest": "^0.2.29",
Expand Down Expand Up @@ -75,6 +65,7 @@
"sass": "^1.29.0",
"sass-loader": "^10.1.0",
"swc-loader": "^0.2.3",
"swr": "^2.0.1",
"turbo": "^2.2.3",
"typedoc": "^0.22.15",
"typescript": "^4.0.3",
Expand Down
1 change: 1 addition & 0 deletions packages/esm-active-visits-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"dependencies": {
"@carbon/react": "^1.71.0",
"classnames": "^2.3.2",
"lodash-es": "^4.17.15"
},
"peerDependencies": {
Expand Down
11 changes: 9 additions & 2 deletions packages/esm-appointments-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"serve": "webpack serve --mode=development",
"debug": "npm run serve",
"build": "webpack --mode production",
"analyze": "webpack --mode=production --env.analyze=true",
"analyze": "webpack --mode=production --env analyze=true",
"lint": "eslint src --ext tsx",
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color",
"test-watch": "cross-env TZ=UTC jest --watch --config jest.config.js",
Expand All @@ -38,19 +38,26 @@
},
"dependencies": {
"@carbon/react": "^1.71.0",
"@hookform/resolvers": "^3.9.1",
"classnames": "^2.3.2",
"formik": "^2.2.9",
"lodash-es": "^4.17.15",
"yup": "^0.32.11"
"react-hook-form": "^7.54.0",
"xlsx": "^0.18.5",
"yup": "^0.32.11",
"zod": "^3.24.1"
},
"peerDependencies": {
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "9.x",
"react": "18.x",
"react-dom": "18.x",
"react-i18next": "11.x",
"react-router-dom": "6.x",
"swr": "2.x"
},
"devDependencies": {
"@openmrs/esm-patient-common-lib": "next",
"webpack": "^5.74.0"
}
}
21 changes: 12 additions & 9 deletions packages/esm-appointments-app/src/helpers/excel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as XLSX from 'xlsx';
import { writeFile, utils, type WorkSheet } from 'xlsx';
import { fetchCurrentPatient, formatDate, getConfig } from '@openmrs/esm-framework';
import { type Appointment } from '../types';
import { type ConfigObject } from '../config-schema';
Expand All @@ -9,7 +9,10 @@ import { moduleName } from '../constants';
* @param {Array<Appointment>} appointments - The list of appointments to export.
* @param {string} [fileName] - The name of the downloaded file
*/
export async function exportAppointmentsToSpreadsheet(appointments: Array<Appointment>, fileName = 'Appointments') {
export async function exportAppointmentsToSpreadsheet(
appointments: Array<Appointment>,
fileName: string = 'Appointments',
) {
const config = await getConfig<ConfigObject>(moduleName);
const includePhoneNumbers = config.includePhoneNumberInExcelSpreadsheet ?? false;

Expand All @@ -35,7 +38,7 @@ export async function exportAppointmentsToSpreadsheet(appointments: Array<Appoin

const worksheet = createWorksheet(appointmentsJSON);
const workbook = createWorkbook(worksheet, 'Appointment list');
XLSX.writeFile(workbook, `${fileName}.xlsx`, { compression: true });
writeFile(workbook, `${fileName}.xlsx`, { compression: true });
}

/**
Expand All @@ -45,7 +48,7 @@ Exports unscheduled appointments as an Excel spreadsheet.
*/
export function exportUnscheduledAppointmentsToSpreadsheet(
unscheduledAppointments: Array<any>,
fileName = `Unscheduled appointments ${formatDate(new Date(), { year: true, time: true })}`,
fileName: string = `Unscheduled appointments ${formatDate(new Date(), { year: true, time: true })}`,
) {
const appointmentsJSON = unscheduledAppointments?.map((appointment) => ({
'Patient name': appointment.name,
Expand All @@ -58,20 +61,20 @@ export function exportUnscheduledAppointmentsToSpreadsheet(
const worksheet = createWorksheet(appointmentsJSON);
const workbook = createWorkbook(worksheet, 'Appointment list');

XLSX.writeFile(workbook, `${fileName}.xlsx`, {
writeFile(workbook, `${fileName}.xlsx`, {
compression: true,
});
}

function createWorksheet(data: any[]) {
const max_width = data.reduce((w, r) => Math.max(w, r['Patient name'].length), 30);
const worksheet = XLSX.utils.json_to_sheet(data);
const worksheet = utils.json_to_sheet(data);
worksheet['!cols'] = [{ wch: max_width }];
return worksheet;
}

function createWorkbook(worksheet: XLSX.WorkSheet, sheetName: string) {
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
function createWorkbook(worksheet: WorkSheet, sheetName: string) {
const workbook = utils.book_new();
utils.book_append_sheet(workbook, worksheet, sheetName);
return workbook;
}
30 changes: 15 additions & 15 deletions packages/esm-appointments-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ import {
expectedAppointmentsPanelConfigSchema,
missedAppointmentsPanelConfigSchema,
} from './scheduled-appointments-config-schema';
import rootComponent from './root.component';
import appointmentsDashboardComponent from './appointments.component';
import homeAppointmentsComponent from './home/home-appointments.component';
import appointmentsListComponent from './appointments/scheduled/appointments-list.component';
import earlyAppointmentsComponent from './appointments/scheduled/early-appointments.component';
import appointmentsFormComponent from './form/appointments-form.component';
import patientSearch from './patient-search/patient-search.component';
export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

const moduleName = '@openmrs/esm-appointments-app';

Expand All @@ -32,6 +24,8 @@ const options = {
moduleName,
};

export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

export function startupApp() {
const appointmentsBasePath = `${window.spaBase}/home/appointments`;

Expand All @@ -58,7 +52,7 @@ export function startupApp() {
]);
}

export const root = getSyncLifecycle(rootComponent, options);
export const root = getAsyncLifecycle(() => import('./root.component'), options);

export const appointmentsDashboardLink = getSyncLifecycle(createDashboardLink(dashboardMeta), options);

Expand All @@ -67,17 +61,23 @@ export const appointmentsCalendarDashboardLink = getSyncLifecycle(
options,
);

export const appointmentsDashboard = getSyncLifecycle(appointmentsDashboardComponent, options);
export const appointmentsDashboard = getAsyncLifecycle(() => import('./appointments.component'), options);

export const homeAppointments = getSyncLifecycle(homeAppointmentsComponent, options);
export const homeAppointments = getAsyncLifecycle(() => import('./home/home-appointments.component'), options);

export const appointmentsList = getSyncLifecycle(appointmentsListComponent, options);
export const appointmentsList = getAsyncLifecycle(
() => import('./appointments/scheduled/appointments-list.component'),
options,
);

export const earlyAppointments = getSyncLifecycle(earlyAppointmentsComponent, options);
export const earlyAppointments = getAsyncLifecycle(
() => import('./appointments/scheduled/early-appointments.component'),
options,
);

export const appointmentsForm = getSyncLifecycle(appointmentsFormComponent, options);
export const appointmentsForm = getAsyncLifecycle(() => import('./form/appointments-form.component'), options);

export const searchPatient = getSyncLifecycle(patientSearch, options);
export const searchPatient = getAsyncLifecycle(() => import('./patient-search/patient-search.component'), options);

// t('Appointments', 'Appointments')
export const patientAppointmentsSummaryDashboardLink = getAsyncLifecycle(async () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/esm-bed-management-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
},
"dependencies": {
"@carbon/react": "^1.71.0",
"lodash-es": "^4.17.15"
"@hookform/resolvers": "^3.9.1",
"classnames": "^2.3.2",
"lodash-es": "^4.17.15",
"react-hook-form": "^7.54.0",
"zod": "^3.24.1"
},
"peerDependencies": {
"@openmrs/esm-framework": "6.x",
Expand Down
1 change: 1 addition & 0 deletions packages/esm-patient-list-management-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"dependencies": {
"@carbon/react": "^1.71.0",
"classnames": "^2.3.2",
"dexie": "^3.0.3",
"fuzzy": "^0.1.3",
"lodash-es": "^4.17.15"
Expand Down
1 change: 1 addition & 0 deletions packages/esm-patient-registration-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"dependencies": {
"@carbon/react": "^1.71.0",
"classnames": "^2.3.2",
"formik": "^2.1.5",
"lodash-es": "^4.17.15",
"uuid": "^8.3.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/esm-patient-search-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
},
"dependencies": {
"@carbon/react": "^1.71.0",
"lodash-es": "^4.17.15"
"classnames": "^2.3.2",
"lodash-es": "^4.17.15",
"react-hook-form": "^7.54.0"
},
"peerDependencies": {
"@openmrs/esm-framework": "6.x",
Expand Down
1 change: 1 addition & 0 deletions packages/esm-service-queues-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"dependencies": {
"@carbon/react": "^1.71.0",
"@hookform/resolvers": "^3.9.1",
"classnames": "^2.3.2",
"lodash-es": "^4.17.15",
"react-hook-form": "^7.54.0",
"zod": "^3.24.1"
Expand Down
1 change: 0 additions & 1 deletion packages/esm-service-queues-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@
"updateEntry": "Update entry",
"updateRoom": "Update room",
"useTodaysDate": "Use today's date",
"visitQueueNumberAttributeUuid not configured": "visitQueueNumberAttributeUuid not configured",
"visitTabs": "Visit tabs",
"visitType": "Visit Type",
"vitals": "Vitals",
Expand Down
5 changes: 4 additions & 1 deletion packages/esm-ward-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
},
"dependencies": {
"@carbon/react": "^1.71.0",
"lodash-es": "^4.17.15"
"classnames": "^2.3.2",
"lodash-es": "^4.17.15",
"react-hook-form": "^7.54.0",
"zod": "^3.24.1"
},
"peerDependencies": {
"@openmrs/esm-framework": "6.x",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interface BedSelectorProps {
currentPatient: Patient;
selectedBedId: number;
error: FieldError;
onChange(bedId: number);
control: Control<{ bedId?: number }, any, { bedId?: number }>;
onChange(bedId: number): void;
control: Control<{ bedId?: number }>;
minBedCountToUseDropdown?: number;
}

Expand Down
Loading
Loading