Problem Using FeatureLayer with ES6 Module

370
7
08-11-2021 12:39 PM
JoseCamacho
New Contributor II

Hi!

I am trying to use the ArcGIS Javascript Library with ES Modules and the app for some reason breaks when trying to add a FeatureLayer, this code is working fine using the CDN examples:

Here is a snippet of the code I'm testing:

JoseCamacho_0-1628710619497.png

if I remove the Feature Layer the map loads fine but once I add the FeatureLayer the application errors with the following:

JoseCamacho_1-1628710685265.png

any pointers or ideas of what could be causing this error would be really appreciated.

 

0 Kudos
7 Replies
ReneRubalcava
Frequent Contributor II

What does your build set up look like? We have a number of ESM samples here you can check against. https://github.com/Esri/jsapi-resources/tree/master/esm-samples

0 Kudos
JoseCamacho
New Contributor II

I'm using webpack. I just updated following the instructions in the link you shared and got the same error

0 Kudos
ReneRubalcava
Frequent Contributor II

Not sure. Does this happen in a particular browser/os combo? I put that snippet in a webpack build here and the build seems to be working ok.

https://github.com/odoe/jsapi-webpack-fl

Do you have a repro project we can test against?

0 Kudos
JoseCamacho
New Contributor II

I'm using it in a Ruby on Rails application using the webpacker gem I can provide an app that is presenting the error but I'm not 100% sure it would be very helpful because you will need a fully working rails dev env for it to work. I'm kind of a beginner in both webpack and the web packer gem but whatever I can do to help and figure out what's going on I'm happy to do.

0 Kudos
ReneRubalcava
Frequent Contributor II

Ha, it's been a minute since I used ruby/rails, but I'll see what I can do. If you have a project, that would help, but I can try and put one together.

0 Kudos
JoseCamacho
New Contributor II
Haha, no problem. I will provide a demo app for you to test in a little bit. Thanks!
0 Kudos
JoseCamacho
New Contributor II

So it turns out that, for some reason unknown to me, after upgrading the webpacker gem (rails wrapper for webpack) the FeatureLayers started working.

Thank you very much for your help @ReneRubalcava you pointed me into the direction for the solution, I appreciate it very much.