Hey all,
I hoped I wouldn't have to post this - but my thinking is coming up with zero and Google only produces a single result (Github of "@esri/arcgis-html-sanitizer").
I'm trying to modernize my current AMD code to ES modules however I can't get past the initial import X from "X" stage.
It seems that certain imports cause the following error to occur: "Uncaught TypeError: Failed to resolve module specifier "@esri/arcgis-html-sanitizer"."
So far I've found the following imports: MapView and IdentityManager trigger the error so far.
The only result on Google points me to: https://github.com/Esri/arcgis-html-sanitizer
So I install "@esri/arcgis-html-sanitizer" and attempt to import the above, above my MapView/IdentityManager imports using the following:
import { Sanitizer } from "/node_modules/@esri/arcgis-html-sanitizer/dist/umd/arcgis-html-sanitizer.min.js";In my understanding it should be pointing to a .js file, like the other imports but there isn't one in the main directory and I've tried pointing it to every single version available in the dist subfolders.
Solved! Go to Solution.
Hi @LukeCalladine this sounds like a configuration issue with your module bundler. Do you have a github repo with a simple app that reproduces the issue? Or you can try to reproduce it with one of our sample apps: https://github.com/Esri/jsapi-resources/tree/master/esm-samples. Maybe comparing against our samples will provide some hints.
Turns out I may not need to learn too much about module bundlers!
I was able to get ViteJS to do it all for me first time, after watching @ReneRubalcava's video on ViteJS on Youtube: https://www.youtube.com/watch?v=sV1Tcie2SR8.
Hi @LukeCalladine this sounds like a configuration issue with your module bundler. Do you have a github repo with a simple app that reproduces the issue? Or you can try to reproduce it with one of our sample apps: https://github.com/Esri/jsapi-resources/tree/master/esm-samples. Maybe comparing against our samples will provide some hints.
Hey @AndyGup,
Many thanks for your reply - I can only imagine the fact I don't know what a module bundler is, is probably the root of my current problem and likely the majority of my future ones!
I've just cloned the jsapi-node ESM sample and was able to import MapView somewhat successfully - while I get a HTMLElement error which I have no idea to fix yet, it does seem to have gotten past the initial Import error I was getting in my initial post. I'll take a look through the files and see if I can get my head around what's happening.
And to think I thought I was getting the hang of this yesterday...
Turns out I may not need to learn too much about module bundlers!
I was able to get ViteJS to do it all for me first time, after watching @ReneRubalcava's video on ViteJS on Youtube: https://www.youtube.com/watch?v=sV1Tcie2SR8.