Esri JS-API 4.13, Webpack, imported classes show up undefined

1715
2
Jump to solution
02-03-2020 09:12 AM
AndreasKunz
New Contributor II

We are using the ArcGIS JavaScript API 4.13 in an Angular 8 based project and are about to change from esri-loader to a Webpack approach. I followed the instructions on Angular | ArcGIS API for JavaScript 4.14 installing @arcgis/webpack-plugin 4.13.1. The example worked fine, but when i startet migrating the project, several imported classes show up "undefined". I went back to the simple example to reproduce the error, and it was the same.

We are using roughly 50 classes from different packages, but five classes show up undefined, these are the failing imports:

  • import watchUtils from 'arcgis-js-api/core/watchUtils';
  • import geometryEngine from 'arcgis-js-api/geometry/geometryEngine';
  • import webMercatorUtils from 'arcgis-js-api/geometry/support/webMercatorUtils';
  • import size from 'arcgis-js-api/renderers/smartMapping/creators/size';
  • import color from 'arcgis-js-api/renderers/smartMapping/creators/color';

I realize that each of the imported classes starts with a lower case letter, but the same goes for "import config from 'arcgis-js-api/config';", which is not failing.

What am i missing?
Cheers,

Schotty

1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

There are some modules in the API that do not have a default export. In this case you will need to import them with in one of two ways.

import * as watchUtils from 'arcgis-js-api/core/watchUtils';

// OR

import { whenTrue, whenFalse } from 'arcgis-js-api/core/watchUtils';

View solution in original post

2 Replies
ReneRubalcava
Frequent Contributor

There are some modules in the API that do not have a default export. In this case you will need to import them with in one of two ways.

import * as watchUtils from 'arcgis-js-api/core/watchUtils';

// OR

import { whenTrue, whenFalse } from 'arcgis-js-api/core/watchUtils';
AndreasKunz
New Contributor II

Hi Rene,

thanks, that solved the problem.

0 Kudos