npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@digital-enabler/demf-kpim-editor-formula

v0.1.11

Published

![REPO-TYPE](https://img.shields.io/badge/repo--type-template-blue?style=for-the-badge&logo=github)

Downloads

100

Readme

VUE 3 Template Project with Vue/CLI v.5.0.8

REPO-TYPE

This template project is a start base that help you to create a Microfrontend project with the use of the Single-spa plug-in. Use this template and follow this guide.

Pre-requisites

Before you continue you need to

  • have NPM installed
  • have NodeJS installed (max version 16.20 for fully compatibility)
  • have Vue 3 and Vue-CLI installed
  • have a GitHub account
  • use VisualStudio Code or IntelliJ Idea as your development IDE

Creating an MF from VueJS template project

  1. Use the vuejs-microfrontend-template project by clicking on button Use this template from GitHub and in the next page write a project name with this pattern demf-[tool_name], write also a breaf description and select private type.

  2. Now the new project root-config is created on GitHub, clone it on your local environment and make a branch from main to start to work on it.

  3. In your local IDE, open the app/package.json file and rename the project using the pattern name @digital-enabler/demf-[tool_name]

  4. Open a Terminal window in the project folder and go inside the app folder, then launch the command: npm install

NOTE: When install finished, do not care about the warnings on the versions and vulnerability problems reported, and DO NOT launch the npm audit fix or npm audit fix –force commands

  1. At this point you can start customizing your project in VueJS, installing any additional libraries you need.

  2. Once you have completed and verified that all the desired libraries have been correctly configured, you can proceed with its transformation into Microfrontend through the use of the Single-spa plug-in.

vue add single-spa

The installation, in addition to installing the plugin, will involve modifying the package.json file and the main.js file to make them compliant with use within a microfrontend.

Alternatively to the command indicated you can use the VueUI browser interface to easily install the plugin: with the server turned off and the project not started, open the plugin section of the UI and look for the plugin vue-cli-plugin-single-spa, select it and proceed with the installation, following the instructions on the screen.

ATTENTION: it is possible that during the installation of the plugin through the VueUI not all the imports of your original main.js, in particular of the i18n plugin, are reported. If this happens, just re-enter the missing imports, for example: import i18n from "./i18n";
Then invoke it as for the other imports listed by copying the i18n key into the appOptions object.

  1. We can now verify the correct installation of the plugin by delivering the microfrontend through the command:
npm run serve

or by starting the Serve task from VueUI.

  1. When the server is started, your microfrontend will be available at the URL http://localhost:8080. The page shown will contain the title "Your Microfrontend is not here" along with some instructions.

Now your new Microfrontend is ready to be customized and mounted on a root-config project. See here for more information on how to mount your microfrontend on a root-config.

Using Props

You can use props shared by a root-config project, to be used within the MF in a variety of ways, such as additional external information, so that they are already present at the time the MF is mounted.

Props are data that can be used to initialize and configure the MF from its mount. Generally, props are provided by the root-config and then declared in the route tag that defines the layout and visibility of the MF within the application. See here for more information on how to mount your microfrontend on a root-config.

To use the props in the MF it is necessary to define them within the main.js file in the appropriate props section, as well as in the example:

    ...
    const vueLifecycles = singleSpaVue({
      createApp,
      appOptions: {
        render() {
          return h(App, {
            mashupsListConfig: this.mashupsListConfig,
            palette: this.palette,
            realm: this.realm,
          });
        },
      },
      ...
      },
    });
    ...

The code shows the declaration of the three props: mashupsListConfig, realm and palette. These three props must be forwarded in the MF code by adding the corresponding prop definitions within the App.vue file, as you usually declare a prop in a VueJS component.

Specifically mashupsListConfig is an example of a way you can take to get an external configuration json file for use within your application, generally this is called [realm]-[mf_name]-config.json and is located in a storage space separate. The root-config application is programmed to load several configuration files from a specific storage.

Configuring Vuetify Theme by Digital Enabler color palette

Only after its transformation into Microfrontend through the use of the Single-spa plug-in, it is possible to customize this MF application’s default text colors, surfaces, and more. Easily modify your Vuetify theme programmatically in real time by using the prop color palette coming from your root-config project, as explained in the previous paragraph. You need to use a similar piece of code as below:

  ...
  handleInstance(app, props) {
    app.use(router);
    app.use(i18n);

    //Vuetify theme color palette
    const palette = props.palette;
    vuetify.theme.computedThemes.value.deTheme.colors.primary = palette.primary;
    vuetify.theme.computedThemes.value.deTheme.colors.secondary = palette.secondary;
    vuetify.theme.computedThemes.value.deTheme.colors.accent = palette.accent;
    vuetify.theme.computedThemes.value.deTheme.colors.error = palette.error;
    vuetify.theme.computedThemes.value.deTheme.colors.info = palette.info;
    vuetify.theme.computedThemes.value.deTheme.colors.success = palette.success;
    vuetify.theme.computedThemes.value.deTheme.colors.warning = palette.warning;
    app.use(vuetify);
  },
  ...

At this point you also need to add your modified theme inside your vuetify.js file configuration, as described here. The top code show that the deTheme is modified at runtime so you need to add this theme as Application theme.

Creating the [realm]-[mf_name]-config.json

There is a way you can take to get an external configuration json file for use within your application and it is throgh the root-config application that is the main access point for every MF, see here for more information.

Generally this file is named [realm]-[mf_name]-config.json and is located in a specific storage space separate. The root-config application can be configured and is programmed to load several configuration files for every MF from the specific storage you set.

In this json file you can set all those static information necessary to your application working, an example could be:

{
   "mf": "Sidebar",
   "api": "//localhost:8083/api",
   "storageImgs": "https://storage.digital-enabler.eng.it/imgs",
   "links": [
      {
         "title": "labels.mashups",
         "icon": "mdi-file-tree",
         "link": "/"
      },
      ...

In this example you can see various information for your application

This is a required key to use this file.

  • "api" is the URL if your MF uses external API.
  • "storageImgs" is the URL of an external image memory where you can put all your images.
  • the "links" in this case are an array of objects describing different links to be used in the application

and so on...

Except the first "mf" key which is mandatory, other information you put in the json file should be all static info you to use inside your application.

When you have finished writing all the necessary information into this file, you need to publish it to a remote repository and register it following the instructions here, so that it can be used via the root-config application.

Building Policy and Methodology

In order to get a build of the microfrontend project as light as possible and with clean and customizable code, in an easy way, even without having to recompile the MF, you need:

  • remove any file that is not essential for building the project or that can, in any case, be regenerated during the build itself

  • use external storage (e.g. AWS S3, DE MinIO, Github, etc.) for all those static elements such as images and json files

Lints and fixes files

To find and fix problems in your JavaScript code you can use the Lint task inside the VueUI or the equal command line:

npm run lint

It is suggested to use this task just before every commit/push to git.

Build and Deployment

Once you pushed all your code and merged it with the main branch, the Pipeline system will deploy the new microfrontend on the NPM cloud under the Digital-Enabler organization. NPM will store your public compiled code and here you can controll all versions of your MF.

If you go to the free CDN JSDeliver and try to search @digital-enabler you will obtain the list of microfrontend for Digital Enabler with also the one you have deployed. Open the detail of one project, and you can see every files contained on it. Find the file named app.js and click the icon on the right side of the line. It will open a menu, select the Copy URL to copy the URL of this file to clipboard.

You will obtain a URL like this one:

https://cdn.jsdelivr.net/npm/@digital-enabler/[email protected]/app.js

It usually have the pattern:

https://cdn.jsdelivr.net/npm/@digital-enabler/[MF-project-name]@[MF-version]/app.js

This is the URL you have to use inside a root-config if you want to mount a MF from external source. You can notice the version, so if you want to use a different version you simply can change it.

Known Issues

For the following dependencies it is necessary to use the versions indicated that are currently the ONLY ones supported by the single-spa plugin used

| Plugin | Version | | ---------- | ------- | | Vue-router | ^4.0.3 |

This template includes listed dependecies:

"@mdi/font": "5.9.55",
"core-js": "^3.8.3",
"roboto-fontface": "*",
"vue": "^3.2.13",
"vue-i18n": "^9.1.0",
"vue-router": "^4.0.3",
"vuetify": "^3.0.0",