Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Install openmrs-module-spa on your OpenMRS server
  2. Create a directory, in which we will create a packmap package (see the following instructions). You'll probably want to make it a github repository, like this one.
  3. In this directory, create a package.json based on the packmap OpenMRS exampleCreate an override-import-map.json file (see the example) with the line
        "@openmrs/esm-root-config": "/openmrs/frontend/@openmrs/esm-root-config@1.1.1/dist/openmrs-esm-root-config.defaults.js"
    where 1.1.1 is the version of @openmrs/esm-root-config that you have in your package.json
  4. npm install
  5. npm run build
  6. Symlink* the resultant openmrs/frontend directory into your OpenMRS server's application data directory as "frontend". For my SDK server named "foo", on Linux, I do

      ln -s $(realpath openmrs/frontend) ~/openmrs/foo/frontend

  7. Start the OpenMRS server

  8. Navigate to localhost:8080/openmrs/spa/login (assuming your server is at localhost:8080)

  9. If the page comes up blank...
    1. Open the browser developer console (probably Ctrl+Shift+i)

    2. Work through the errors with the Troubleshooting Guide (forthcoming)

At this point, you should have microfrontends working entirely offline!

Adding configuration and assets without a custom root config

If you won't be creating a custom root config, you You can configure your application in the following manner

  1. Create a directory in your packmap package directory called "assets"
  2. Create a config.json file in that directory
  3. Add the command*
        ln -s $(realpath assets) openmrs/frontend/ 
    to the build script in package.json (separate it from previous commands with a &&)

  4. Add the following line to your override-import-map.json

        "config-file": "/openmrs/frontend/assets/config.json"

  5. That config file can refer to things you put in that assets directory, which will be served under  localhost:8080/openmrs/frontend/assets/

Developing on modules

TODO

Using a custom root config

Once your root config is published, you can add it to the packmap package like any other module. If the main line of your root config's package.json is set correctly, packmap should correctly add it to the import map.

openmrs-module-spa by default uses @openmrs/esm-root-config as the root config. Change it using the OpenMRS setting "spa.rootConfig" (pending PR)




*Sorry Windows users. Maybe one of you can fill in the equivalent thing to do here?