Select to view content in your preferred language

build @arcgis/core webpack component to npm

811
2
Jump to solution
05-01-2022 08:28 PM
naveenanne
Occasional Contributor

@ReneRubalcava 

I'm creating a map component (using @arcgis/core) with some default layers and features and publishing it to npm to be utilized within our applications. I'm successful with rollup bundling, however the size of the unpackaged bundle is above 50 MB. 

I've followed https://odoe.net/blog/arcgis-jsapi-build-tips to build my component using webpack. When using the built component used in any react application, I'm getting a series of errors unending errors. 

Is it possible you could provide me with an example of how to accomplish my task? 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

When you use your built component in your application (the npm package) are you also using the ArcGIS JSAPI in your app? If so, you can't mix JSAPI instances in your app with your component. You'll see errors regarding the Accessor. This is equivalent to trying to create a MapView using @arcgis/core and loading a Map created with the CDN. It won't work. You can publish your component without including the JSAPI in your build, and let the build tools handle it in your app. I do something similar with this published utility library (https://github.com/odoe/explode).

View solution in original post

2 Replies
ReneRubalcava
Honored Contributor

When you use your built component in your application (the npm package) are you also using the ArcGIS JSAPI in your app? If so, you can't mix JSAPI instances in your app with your component. You'll see errors regarding the Accessor. This is equivalent to trying to create a MapView using @arcgis/core and loading a Map created with the CDN. It won't work. You can publish your component without including the JSAPI in your build, and let the build tools handle it in your app. I do something similar with this published utility library (https://github.com/odoe/explode).

naveenanne
Occasional Contributor

The example helped and it worked like a charm, thanks a lot @ReneRubalcava.

0 Kudos