How to test a local WebMap Components package
Last updated
Last updated
Once you get a local copy of the WebMapComponents project at the git repository and want to test your latest changes in a migrated application then you need to follow this guide in order to create a local npm package and test it out in a migrated application.
Let's suppose that you want to add a new functionality to an existent control, change its appearance or add another component to the list of supported components.
In this example we are going to modify the label component to display an alert after the click event and then modify it's font color using a new method.
Note: It is important to know that the changes applied to this project and the components defined in it will modify every component of the same type in the migrated application. If you only want to modify a specific component of your application the you should perform the changes in the migrated application instead.
Since we want to modify the label component for this example then we need to edit the components files
First it is required to define the new functions that will handle our click event, so we add in our label.component.ts file the following code:
Then some modifications are required in the html file in order to add the corresponding bindings. In this example we include the ngStyle binding and the click event binding.
And those are the changes that we want to add in this example, so then we are going to build a local package.
Creating a new local npm package it's pretty simple using the standard npm commands.
First we need to define a version name for our package this is an optional step, because you could use the version already defined in the package.json file.
To create a new version you need to use the npm version
command, you simple need to enter:
After the version is generated the package.json file is modified and it will have the new version name in it.
Then, after compile your local project using the gulp
command, you should execute the npm pack
command, this command will generate a compressed file in (.tgz) format that contains your locally generated npm package
To install the generated local package in your migrated application, you only need to execute the following command in the migrated application's frontend project:
After the installation is finished, you should compile the migrated application's frontend code again using the ng build
command. If everything went successfully the application should compile and run with your changes included.