Popup template showing on localhost but not on remote server

561
5
09-20-2022 02:45 AM
bsides
by
New Contributor II

Hi all,

I'm using ArcGIS for JavaScript 4.23.7 and I'm stuck with this problem. When I'm developing locally, in localhost url, the popup template from a webmap is showing correctly, but when I publish the application, the popup throws errors like this in the console:

[esri.widgets.FeatureViewModel] error The popupTemplate could not be displayed for this feature.

Spoiler
"TypeError: t is not a function at ***HIDDEN_URL***/assets/index.720aedee.js:1449:61927 at String.replace (<anonymous>) at $g (***HIDDEN_URL***/assets/index.720aedee.js:1449:61865) at lNe (***HIDDEN_URL***/assets/index.720aedee.js:1518:57755) at ZT (***HIDDEN_URL***/assets/index.720aedee.js:1518:57594) at a._createTextVMParams (***HIDDEN_URL***/assets/index.720aedee.js:1521:59021) at a._compileText (***HIDDEN_URL***/assets/index.720aedee.js:1521:59232) at a._compileContentElement (***HIDDEN_URL***/assets/index.720aedee.js:1521:55520) at***HIDDEN_URL***/assets/index.720aedee.js:1521:55741 at Array.map (<anonymous>)"

Could anyone give me any directions on what may be causing this?

 

Thank you.

0 Kudos
5 Replies
bsides
by
New Contributor II

Could it be a CORS/proxy issue? The domain of the published application is authorized within arcgis.

0 Kudos
bsides
by
New Contributor II

I just did some further testing and it looks like the problem happens after bundling the application. The localhost is working fine but after building it with vite (esbuild), the popup template fails to work. It fails on a line that is trying to use .replace at something that probably isn't a string - and thus failing.

Although I could funnel down to where the error is happening, it's still something from arcgis npm package not being able to build and I really would like an answer.

I tried with versions 4.24.7 and NEXT (4.25.0-next) of the @arcgis/core package.

cc @AndyGup 

Thank you.

0 Kudos
bsides
by
New Contributor II

Since it's minified, it's hard to debug, so I'll just post here to see if that could help in any way. The highlighted part in the image, specifically the `e.replace` call, is the part that reads that "t is not a function" in the original post.

 

0 Kudos
AndyGup
Esri Regular Contributor

Hi @bsides can you provide a simple github repository that we can use to reproduce the issue? That's going to be the best way for us to help figure this out. The error message is just a generic message.

0 Kudos
Christer
New Contributor II

Hi, i know this is an old question. But heres my 2 cents on this, as we also had this annoying issue (altough with other modules of ArcGis).

Try to modify the optimizeDeps property in your Vite config. 

If its enabled, it should look like this after modifying it. 

optimizeDeps: {
  disabled: false,
  exclude: ['@arcgis/core'],
}

 

If we didnt exclude it, Vite tried to optimize ArcGis, which caused production-only bugs. Not sure as to why, because ArcGis kept giving us what seemed to be "valid" errors, in the sense that ArcGis atleast throws their own error messages leading us into dead-ends. 

We had similar issues with CIMSymbols and the GeometryEngine (so far). 

Hope this helps. 

0 Kudos