Select to view content in your preferred language

Question about import syntax for Map web components

120
3
Monday
JonathanTiu
Occasional Contributor

Hi,

On the official documentation it says to import web components like this:

import '@arcgis/map-components/components/arcgis-scale-bar'

 

but in practice i have to import it with the dist folder or else it won't find it.

on disk, i do see the folder path under node_modules is arcgis/map-components/dist/components/arcgis-scale-bar but it feels like there is some missing mapping maybe.

import '@arcgis/map-components/dist/components/arcgis-scale-bar'.
 
i did an npm install and saved it to my package.json.  I'm not sure why i have to specify the dist folder
 
Jonathan
0 Kudos
3 Replies
Sage_Wall
Esri Regular Contributor

Hi @JonathanTiu ,

Are you using the latest version (4.34) of the SDK or an older version?  The import path above looks correct for the latest version, however in some previous versions the `dist` was needed in the imports.  We hope to address situations like this in the future by providing documentation for older versions of the SDK online.  Currently our documentation assumes you are using the latest version.

0 Kudos
JonathanTiu
Occasional Contributor

yes I am using 4.34 for both core and map-components?

JonathanTiu_0-1765501988965.png

 

0 Kudos
Sage_Wall
Esri Regular Contributor

Weird, The only thing I can think of is that your node_modules folder or some sort of cache is corrupt.  Have you tried deleting node_modules and then running `npm install`?  Are you using Vite by chance, it makes it's own cache.  You can force Vite to clear the cache with `npm run dev -- --force`

0 Kudos