Defining NPM packages for widgets in WAB

10-05-2016 02:39 PM
New Contributor II

My organization is currently building a suite of widgets for Web App Builder, and I am interested in bringing in resources from NPM in my current widget for obvious reasons.

My first question

I did read:

Use other libraries—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers 

In this article, it seems that the only way to define these modules is based on the notion that everyone will be operating out of the same WebAppBuilder instance. In our shop this is not the case, each developer is running their own instance and we want NPM packages to somehow be concurrent across source control. Initially we were putting the entire WAB npm folder into source control and this caused some chaotic problems for several days, of which we never traced the origin of. Therefore, we decided to go with the approach of only retaining our widgets in source control. Is there a convention in terms of NPM package concurrency, interorganzation?

MY second question:

How do you actually use the NPM packages in your widget? I have tried two approaches:

  1. Use dojo/node: Use the dojo/node package to import the NPM package via AMD. Problem: Stack trace yields error: Cannot find the Node.js require
  2. CDNs I figured since most packages are on github, I could use RawGit functionality in to inject the dependency into the DojoConfig. Problem: Since WebAppBuilder doesn't allow me to define/edit my HTML entry point i.e. index.html where I would traditionally define CDN <scripts> / DojoConfig, where in the world should I put a CDN declaration under WAB?

Since NPM is so vital to nearly any JS project's success, it is crucial that we learn the typical NPM implementation strategy in WAB.  

Thank you for any assistance offered.

0 Replies