question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion - Module Loader for non-UMD style usage of ESRI classes & objects

See original GitHub issue

Built and use this in a production app on top of esri-loader to easily access parts of the API.

https://gist.github.com/davidpiesse/19060cf21f90f4a1460aa33954b4b957

Instead of always having to

esriLoader.loadModules(['esri/views/MapView', 'esri/WebMap'])
.then(([MapView, WebMap]) => {
  let web_map = new WebMap({ ... });
}
...

now you can

await esri.loadModules([
  'esri/Map', 
  'esri/views/MapView',
],true)

let map_view = new MapView({
  map: map,
  spatialReference: 102100
})

I use it a lot and usually wrap calls in promises etc. to know when a object is then ready.

It doesn’t re-download if something is already loaded in and auto assigns names to the classes (so esri/views/MapView is MapView) rather than the long winded UMD style method which means you need to keep them in order.

This is also makes it super easy to only request a module when you need it inline with your code

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
andygupcommented, Jul 17, 2018
0reactions
davidpiessecommented, Jul 17, 2018

Fair enough. I’ll close this then 😅 One of my main reasons for this method was I preferred opinionated code in this context and having to organise and remember the order of declarations was a pain.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build with ES modules | ArcGIS Maps SDK for JavaScript 4.25
ES modules are an official, standardized module system for working with modern JavaScript that has been adopted by all the major browsers. The...
Read more >
Esri/esri-loader: A tiny library to help load ArcGIS API ... - GitHub
A tiny library to help load ArcGIS API for JavaScript modules in non-Dojo applications - GitHub - Esri/esri-loader: A tiny library to help...
Read more >
Esri Training
Learn the latest GIS technology through free live training seminars, self-paced courses, or classes taught by Esri experts. Resources are available for ...
Read more >
Loader of the Things: One Library to Load Them All
If your ArcGIS web application uses any other module loader besides the Dojo loader (i.e. webpack, Rollup.js, etc.) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found