At the end of my last blog post I was looking at ways in which to write better components by abstracting as much non-browser specific code to utility modules. The idea of this was to improve testing so to minimize the amount of code that needed to be tested against multiple browsers. The side-effect of this approach means producing common capabilities that can be easily re-used against multiple web application frameworks such as Vue.js, React, Angular, etc.
As I developed my application I found myself pulling in more and more code and configuration that was already available in one of the many Vue.js CLI template projects. Most UI frameworks now come with a CLI that makes it easy to rapidly build out an application. I want to test out other frameworks so I thought it would make sense to abstract the core authentication and routing code into a separate project so that it could be imported into multiple different projects created using a CLI.
I followed some of the approach in this blog post and then mostly following these instructions on setting it up as an NPM package. Some useful information on testing the package prior to publication in described here. It was also necessary to follow this information in order to create a package with multiple exports.
The end result means that it is now possible to to install this new package with the following command:
npm install alfresco-auth-router --save-dev
Or if you prefer Yarn:
yarn add --dev alfresco-auth-router