Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

(fix) Various fixes for compatibility of new versions #707

Merged
merged 3 commits into from
Jun 23, 2023

Conversation

ibacher
Copy link
Member

@ibacher ibacher commented Jun 23, 2023

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.

For changes to apps

If applicable

  • My work includes tests or is validated by existing tests.
  • I have updated the esm-framework mock to reflect any API changes I have made.

Summary

  • esm-framework itself should use System-style output
  • Properly handle multiple routes overriding each other
  • Properly handle ordering of pages across apps and app indices based on page order

Screenshots

Related Issue

Other

* esm-framework itself should use System-style output
* Properly handle multiple routes overriding each other
* Properly handle ordering of pages across apps and app indices based on page order
@github-actions
Copy link
Contributor

github-actions bot commented Jun 23, 2023

Size Change: -232 kB (-10%) 👏

Total Size: 2.11 MB

Filename Size Change
packages/shell/esm-app-shell/dist/openmrs.44d6abe7bc4fd6f0.js 0 B -200 kB (removed) 🏆
ℹ️ View Unchanged
Filename Size Change
packages/apps/esm-devtools-app/dist/25.js 275 B 0 B
packages/apps/esm-devtools-app/dist/312.js 4.19 kB 0 B
packages/apps/esm-devtools-app/dist/735.js 2.63 kB 0 B
packages/apps/esm-devtools-app/dist/768.js 115 kB -3.35 kB (-3%)
packages/apps/esm-devtools-app/dist/main.js 2.95 kB 0 B
packages/apps/esm-devtools-app/dist/openmrs-esm-devtools-app.js 3.03 kB 0 B
packages/apps/esm-implementer-tools-app/dist/102.js 2.76 kB 0 B
packages/apps/esm-implementer-tools-app/dist/139.js 11.7 kB 0 B
packages/apps/esm-implementer-tools-app/dist/242.js 6.71 kB 0 B
packages/apps/esm-implementer-tools-app/dist/319.js 458 B 0 B
packages/apps/esm-implementer-tools-app/dist/369.js 2.63 kB 0 B
packages/apps/esm-implementer-tools-app/dist/412.js 2.29 kB 0 B
packages/apps/esm-implementer-tools-app/dist/416.js 1.13 kB 0 B
packages/apps/esm-implementer-tools-app/dist/466.js 5.82 kB 0 B
packages/apps/esm-implementer-tools-app/dist/521.js 26.1 kB 0 B
packages/apps/esm-implementer-tools-app/dist/574.js 438 B 0 B
packages/apps/esm-implementer-tools-app/dist/600.js 62.2 kB 0 B
packages/apps/esm-implementer-tools-app/dist/620.js 126 kB 0 B
packages/apps/esm-implementer-tools-app/dist/697.js 1.41 kB 0 B
packages/apps/esm-implementer-tools-app/dist/735.js 2.63 kB 0 B
packages/apps/esm-implementer-tools-app/dist/758.js 4.02 kB 0 B
packages/apps/esm-implementer-tools-app/dist/768.js 115 kB -3.35 kB (-3%)
packages/apps/esm-implementer-tools-app/dist/782.js 4.28 kB 0 B
packages/apps/esm-implementer-tools-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-implementer-tools-app/dist/833.js 546 B 0 B
packages/apps/esm-implementer-tools-app/dist/981.js 448 B 0 B
packages/apps/esm-implementer-tools-app/dist/main.js 4.1 kB 0 B
packages/apps/esm-implementer-tools-app/dist/openmrs-esm-implementer-tools-app.js 3.25 kB 0 B
packages/apps/esm-login-app/dist/236.js 272 B 0 B
packages/apps/esm-login-app/dist/240.js 364 B 0 B
packages/apps/esm-login-app/dist/263.js 6.65 kB 0 B
packages/apps/esm-login-app/dist/272.js 264 B 0 B
packages/apps/esm-login-app/dist/273.js 1.28 kB 0 B
packages/apps/esm-login-app/dist/319.js 360 B 0 B
packages/apps/esm-login-app/dist/336.js 234 B 0 B
packages/apps/esm-login-app/dist/390.js 603 B 0 B
packages/apps/esm-login-app/dist/403.js 9.64 kB 0 B
packages/apps/esm-login-app/dist/438.js 6 kB 0 B
packages/apps/esm-login-app/dist/493.js 5.8 kB 0 B
packages/apps/esm-login-app/dist/539.js 298 B 0 B
packages/apps/esm-login-app/dist/574.js 428 B 0 B
packages/apps/esm-login-app/dist/611.js 726 B 0 B
packages/apps/esm-login-app/dist/63.js 16.5 kB 0 B
packages/apps/esm-login-app/dist/644.js 305 B 0 B
packages/apps/esm-login-app/dist/660.js 6.24 kB 0 B
packages/apps/esm-login-app/dist/668.js 9.07 kB 0 B
packages/apps/esm-login-app/dist/673.js 284 B 0 B
packages/apps/esm-login-app/dist/735.js 2.63 kB 0 B
packages/apps/esm-login-app/dist/737.js 24.9 kB 0 B
packages/apps/esm-login-app/dist/757.js 603 B 0 B
packages/apps/esm-login-app/dist/768.js 115 kB -3.35 kB (-3%)
packages/apps/esm-login-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-login-app/dist/833.js 606 B 0 B
packages/apps/esm-login-app/dist/main.js 3.46 kB 0 B
packages/apps/esm-login-app/dist/openmrs-esm-login-app.js 3.17 kB 0 B
packages/apps/esm-offline-tools-app/dist/107.js 7.35 kB 0 B
packages/apps/esm-offline-tools-app/dist/153.js 12.4 kB 0 B
packages/apps/esm-offline-tools-app/dist/228.js 303 B 0 B
packages/apps/esm-offline-tools-app/dist/263.js 6.66 kB 0 B
packages/apps/esm-offline-tools-app/dist/290.js 438 B 0 B
packages/apps/esm-offline-tools-app/dist/323.js 360 B 0 B
packages/apps/esm-offline-tools-app/dist/337.js 6.28 kB 0 B
packages/apps/esm-offline-tools-app/dist/364.js 8.24 kB 0 B
packages/apps/esm-offline-tools-app/dist/40.js 1.15 kB 0 B
packages/apps/esm-offline-tools-app/dist/574.js 1.04 kB 0 B
packages/apps/esm-offline-tools-app/dist/63.js 16.5 kB 0 B
packages/apps/esm-offline-tools-app/dist/679.js 6.57 kB 0 B
packages/apps/esm-offline-tools-app/dist/697.js 5.47 kB 0 B
packages/apps/esm-offline-tools-app/dist/720.js 6.23 kB 0 B
packages/apps/esm-offline-tools-app/dist/735.js 2.63 kB 0 B
packages/apps/esm-offline-tools-app/dist/752.js 2.83 kB 0 B
packages/apps/esm-offline-tools-app/dist/757.js 1.15 kB 0 B
packages/apps/esm-offline-tools-app/dist/768.js 115 kB -3.35 kB (-3%)
packages/apps/esm-offline-tools-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-offline-tools-app/dist/82.js 51.8 kB 0 B
packages/apps/esm-offline-tools-app/dist/833.js 1.16 kB 0 B
packages/apps/esm-offline-tools-app/dist/891.js 22.1 kB 0 B
packages/apps/esm-offline-tools-app/dist/904.js 294 B 0 B
packages/apps/esm-offline-tools-app/dist/922.js 14.6 kB 0 B
packages/apps/esm-offline-tools-app/dist/94.js 6.08 kB 0 B
packages/apps/esm-offline-tools-app/dist/940.js 11.2 kB 0 B
packages/apps/esm-offline-tools-app/dist/963.js 1.22 kB 0 B
packages/apps/esm-offline-tools-app/dist/967.js 492 B 0 B
packages/apps/esm-offline-tools-app/dist/main.js 58.6 kB 0 B
packages/apps/esm-offline-tools-app/dist/openmrs-esm-offline-tools-app.js 3.25 kB 0 B
packages/apps/esm-primary-navigation-app/dist/113.js 11.6 kB 0 B
packages/apps/esm-primary-navigation-app/dist/263.js 6.66 kB 0 B
packages/apps/esm-primary-navigation-app/dist/341.js 6.68 kB 0 B
packages/apps/esm-primary-navigation-app/dist/354.js 13.2 kB 0 B
packages/apps/esm-primary-navigation-app/dist/414.js 467 B 0 B
packages/apps/esm-primary-navigation-app/dist/545.js 6.08 kB 0 B
packages/apps/esm-primary-navigation-app/dist/574.js 183 B 0 B
packages/apps/esm-primary-navigation-app/dist/63.js 16.5 kB 0 B
packages/apps/esm-primary-navigation-app/dist/631.js 1.07 kB 0 B
packages/apps/esm-primary-navigation-app/dist/710.js 6.44 kB 0 B
packages/apps/esm-primary-navigation-app/dist/735.js 2.64 kB 0 B
packages/apps/esm-primary-navigation-app/dist/757.js 209 B 0 B
packages/apps/esm-primary-navigation-app/dist/768.js 115 kB -3.35 kB (-3%)
packages/apps/esm-primary-navigation-app/dist/788.js 42.9 kB 0 B
packages/apps/esm-primary-navigation-app/dist/833.js 210 B 0 B
packages/apps/esm-primary-navigation-app/dist/874.js 1.87 kB 0 B
packages/apps/esm-primary-navigation-app/dist/main.js 4.21 kB 0 B
packages/apps/esm-primary-navigation-app/dist/openmrs-esm-primary-navigation-app.js 3.29 kB 0 B
packages/framework/esm-api/dist/openmrs-esm-api.js 7.9 kB -623 B (-7%)
packages/framework/esm-breadcrumbs/dist/openmrs-esm-breadcrumbs.js 2.14 kB -596 B (-22%) 🎉
packages/framework/esm-config/dist/openmrs-esm-module-config.js 6.97 kB 0 B
packages/framework/esm-dynamic-loading/dist/openmrs-esm-dynamic-loading.js 1.4 kB 0 B
packages/framework/esm-error-handling/dist/openmrs-esm-error-handling.js 865 B -602 B (-41%) 🎉
packages/framework/esm-extensions/dist/openmrs-esm-extensions.js 6.6 kB -576 B (-8%)
packages/framework/esm-framework/dist/530.openmrs-esm-framework.js 2.92 kB 0 B
packages/framework/esm-framework/dist/585.openmrs-esm-framework.js 12.2 kB 0 B
packages/framework/esm-framework/dist/645.openmrs-esm-framework.js 9.31 kB 0 B
packages/framework/esm-framework/dist/71.openmrs-esm-framework.js 6.77 kB 0 B
packages/framework/esm-framework/dist/710.openmrs-esm-framework.js 6.48 kB 0 B
packages/framework/esm-framework/dist/735.openmrs-esm-framework.js 2.66 kB 0 B
packages/framework/esm-framework/dist/788.openmrs-esm-framework.js 42.9 kB 0 B
packages/framework/esm-framework/dist/openmrs-esm-framework.js 147 kB -4.16 kB (-3%)
packages/framework/esm-globals/dist/openmrs-esm-globals.js 679 B -710 B (-51%) 🏆
packages/framework/esm-offline/dist/openmrs-esm-offline.js 31.9 kB -572 B (-2%)
packages/framework/esm-react-utils/dist/openmrs-esm-react-utils.js 16.1 kB -593 B (-4%)
packages/framework/esm-state/dist/openmrs-esm-state.js 876 B -666 B (-43%) 🎉
packages/framework/esm-styleguide/dist/openmrs-esm-styleguide.js 36.6 kB -1.29 kB (-3%)
packages/framework/esm-utils/dist/openmrs-esm-utils.js 9.23 kB -637 B (-6%)
packages/shell/esm-app-shell/dist/01c48175a5cba05a.js 9.79 kB 0 B
packages/shell/esm-app-shell/dist/afaf751cd038cb13.js 1.02 kB 0 B
packages/shell/esm-app-shell/dist/b645d09ccf045ac1.js 4.44 kB 0 B
packages/shell/esm-app-shell/dist/d46bb6607e92a390.js 0 B -4.35 kB (removed) 🏆
packages/shell/esm-app-shell/dist/openmrs.4a391920555bb4ec.js 200 kB 0 B
packages/shell/esm-app-shell/dist/service-worker.js 51 kB +1 B (0%)
packages/tooling/openmrs/dist/cli.js 3.02 kB 0 B
packages/tooling/openmrs/dist/commands/assemble.js 2.71 kB 0 B
packages/tooling/openmrs/dist/commands/build.js 1.45 kB 0 B
packages/tooling/openmrs/dist/commands/debug.js 579 B 0 B
packages/tooling/openmrs/dist/commands/develop.js 1.75 kB 0 B
packages/tooling/openmrs/dist/commands/index.js 438 B 0 B
packages/tooling/openmrs/dist/commands/start.js 848 B 0 B
packages/tooling/openmrs/dist/index.js 517 B 0 B
packages/tooling/openmrs/dist/runner.js 870 B 0 B
packages/tooling/openmrs/dist/utils/config.js 689 B 0 B
packages/tooling/openmrs/dist/utils/debugger.js 529 B 0 B
packages/tooling/openmrs/dist/utils/dependencies.js 639 B 0 B
packages/tooling/openmrs/dist/utils/helpers.js 393 B 0 B
packages/tooling/openmrs/dist/utils/importmap.js 2.98 kB 0 B
packages/tooling/openmrs/dist/utils/index.js 444 B 0 B
packages/tooling/openmrs/dist/utils/logger.js 234 B 0 B
packages/tooling/openmrs/dist/utils/npmConfig.js 854 B 0 B
packages/tooling/openmrs/dist/utils/untar.js 721 B 0 B
packages/tooling/openmrs/dist/utils/variables.js 192 B 0 B
packages/tooling/openmrs/dist/utils/webpack.js 276 B 0 B
packages/tooling/webpack-config/dist/index.js 3.24 kB 0 B

compressed-size-action

@@ -182,22 +182,26 @@ export function registerApp(appName: string, routes: OpenmrsAppRoutes) {
* Each page is rendered into a div with an appropriate name.
*/
export function finishRegisteringAllApps() {
pages.sort((a, b) => a.order - b.order);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I think we were implicitly relying on sorting pages by app and then by page order. Pages are now sorted purely by order (and then appName according to English rules) so we're not implicitly relying on anything.

This is also why the index-counting behaviour needed to be changed to track an index-per-app.

let index = 0;
let lastAppName: string | undefined = undefined;

let appIndices = new Map();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably have a lot of places where we're using Objects and it would make sense to use Maps. That said, the syntax for objects is much more comfortable, i.e., I don't think there's as ergonomic a version of {...base, ...overrides} for merging maps as for objects, though I suppose:

function mapMerge(base: Map, overrides: Map): Map

wouldn't be hard to write.

*/
async function setupApps() {
const scriptTags = document.querySelectorAll<HTMLScriptElement>(
"script[type='openmrs-routes']"
);

const promises: Array<Promise<typeof window.installedModules>> = [];
const promises: Array<Promise<OpenmrsRoutes>> = [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We process each script tag asynchronously, but we need to merge them into a single consistent view of routes before we do anything else. We were accidentally double-loading some routes in development, which was not great.

);

const modules: typeof window.installedModules = [];
Object.entries(routes).forEach(async ([module, routes]) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, this doesn't guarantee that all modules will be in installedModules, i.e., the array can continue to grow asynchronously. I don't know if it's worth implementing the kind of blocking that would be required to ensure that once it was set it's value was not changed.

Copy link
Member

@denniskigen denniskigen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@denniskigen denniskigen merged commit 69b7272 into main Jun 23, 2023
@denniskigen denniskigen deleted the fix/fix-5-0-0 branch June 23, 2023 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants