Openmrs O3 custom module deploying failed

Hi all — I’m trying to deploy a simple ESM frontend module to OpenMRS O3 but it fails to load with a module-federation related error. Below are the steps I followed, the exact error, and what I’ve already checked.

Base: openmrs-distro-referenceapplication (cloned from the repo)

  • O3 frontend (running via Docker)

  • Created a sample ESM module using the esm template app (published to npm as @tjvosl/esm-hello-world-app)

  • I added the module to spa-assemble-config.json in the distro:

    "@tjvosl/esm-hello-world-app": "next"
    

(the same name as package.json in my module)

docker build frontend docker compose up

The module appears in the Implementer Tools → Frontend tab in O3, but when I open the module URL it fails to load.

Uncaught Error: application ‘@tjvosl/esm-hello-world-app-page-0’ died in status LOADING_SOURCE_CODE: The global variable _tjvosl_esm_hello_world_app does not refer to a federated module

Hay according to what I see,

The error says _tjvosl_esm_hello_world_app is missing. That global is derived from your appName. So what I could say about it is that make sure

1-Your package.json name is exactly @tjvosl/esm-hello-world-app

2 -your webpack.config.js uses the same appName

lastly I thinkyour build output should include a remoteEntry.js exposing the module.

try out that thank you.

1 Like

Please rebuild your code and publish it to NPM. In the version in dist (which is what is loaded at runtime) it’s using the name _tj_esm_hello_world_app which aligns with @tj/esm-hello-world-app rather than what you actually published.

could these accomplish what youve said?

npm run build npm publish

Except we use yarn not npm. So yarn build yarn npm publish or something like that…

I tried rebuild and publish to npm. but still error exists.

here is my package json

https://pastebin.com/Leq03yhp

i changed name to “@tjvosl/openmrs-esm-hello-world-app”, and added this name to spa-assemble-config. “@tjvosl/openmrs-esm-hello-world-app”: “latest”

what am i missing here?

@tjayasinghe after adding the module in the spa-assemble-config did you do a build for the reference app again. Also try pointing to the exact version of your microfrontend and see what happens.

1 Like

yes i build it again with docker build frontend and then docker compose up commands but page not viewing

I fixed it. command should be docker compose build not docker build frontend. after doing this module loading correctly. thanks everyone for the support.

3 Likes