Difference between @arcgis/core and arcgis-js-api

797
11
Jump to solution
04-08-2021 09:16 AM
avecchi
New Contributor II

Hello,

I'm currently using `@arcgis/core` for my React application but I'm running into long build times due to something with how webpack is code splitting the `@arcgis/core` code. I'm seeing now that there is another library called `arcgis-js-api` and I'm wondering what the difference between the two is since they both look like they're doing the same thing.

Thanks

0 Kudos
1 Solution

Accepted Solutions
AndyGup
Esri Regular Contributor

Same API just different modules: @arcgis/core uses ES modules and arcgis-js-api uses AMD modules. The underlying functionality is exactly the same. How is your webpack configured? cc @ReneRubalcava 

View solution in original post

0 Kudos
11 Replies
AndyGup
Esri Regular Contributor

Same API just different modules: @arcgis/core uses ES modules and arcgis-js-api uses AMD modules. The underlying functionality is exactly the same. How is your webpack configured? cc @ReneRubalcava 

0 Kudos
JamesBrett
New Contributor

@AndyGupSo as I understand it the @arcgis/core copies all assets at build? I used CRA to display a globe and my build is over 1GB.

Is this the correct functionality of @arcgis/core? Will esri-loader give me smaller builds?

0 Kudos
avecchi
New Contributor II

I haven't been able to get @arcgis/core to work given the large build size and build time. I've been stuck using esri-loader.

AndyGup
Esri Regular Contributor

@JamesBrett  Nope, that doesn't sound right. Can you provide a simple github repo that we can look at? Here are our sample app build sizes for comparison: https://github.com/Esri/jsapi-resources/blob/master/esm-samples/.metrics/4.23.0.csv

0 Kudos
JamesBrett
New Contributor

Sure give me a few mins. I should have clarified that is the entire build folder. Let me check the size of the main.js. I see that is what your benchmarks are looking at.

0 Kudos
AndyGup
Esri Regular Contributor

Correct, we measure a variety of stats including the size of the entire build folder for each of the samples. A 1GB folder could the the result of things like configuration issues, third party libraries, a very large and complex application, lots of image files, etc.

avecchi
New Contributor II

I'm just spun up a Create React Application

0 Kudos
AndyGup
Esri Regular Contributor

Maybe try updating via `npm i '@ArcGIS/core@next`. Starting at 4.19 (coming out later this month) there's no asset copying by default (unless you need the assets locally). Here's our working sample for 4.18: https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-create-react-app 

0 Kudos
avecchi
New Contributor II

I see. Not copying the assets on 4.19 is working but I'm still having my issue with my production build.

My main issue is that whenever I import a single module from @Anonymous User/core e.g:

import Graphic from '@arcgis/core/Graphic'

 My webpack production build process runs out of memory.

0 Kudos