I am testing out the new ES Modules option in 4.19 by migrating one of my apps from ESRI Loader to ES Modules. The app uses React and was created using Create React App.
I am having issues importing the "projection" module. For example if I try to import it as below I get a compile time error:
import projection from "@arcgis/core/geometry/projection";
// Failed to compile.
// ./src/map/MainMap.tsx
// Attempted import error: '@arcgis/core/geometry/projection' does not contain a default export (imported as 'projection').
Additional version info:
How should I import this module?
Solved! Go to Solution.
The syntax would look like this.
import { load, project } from '@arcgis/core/geometry/projection';
You could import the entire module like this.
import * as projection from '@arcgis/core/geometry/projection';
However this will load all the methods of projection, even if you don't use them. It's a minimal impact on built javascript, but the first way allows build tools to only include code you use.
The syntax would look like this.
import { load, project } from '@arcgis/core/geometry/projection';
You could import the entire module like this.
import * as projection from '@arcgis/core/geometry/projection';
However this will load all the methods of projection, even if you don't use them. It's a minimal impact on built javascript, but the first way allows build tools to only include code you use.
Perfect, thanks Rene!