Esri / esri-system-js

Load ArcGIS API for JavaScript modules using SystemJS
Apache License 2.0
23 stars 5 forks source link

TypeScript and Dojo #29

Closed payneBrandon closed 7 years ago

payneBrandon commented 7 years ago

I'm running into an issue with using dojo with the systemjs loader. For instance, I'd like to use dojo/dom or the require statement but when I try to add the following import statement, I get an error saying cannot find module 'dojo/dom'.
import dom from 'dojo/dom';

I've looked around a bit and can't find anywhere that is explicitly using the dojo tools with the esri-system-js loader. I'm sure that I've missed a step somewhere to include dojo, does anyone know how?

tomwayson commented 7 years ago

Can you please provide more of the code that you've already tried? Like the code from the quick start What does your call to esriSystem.register() look like?

payneBrandon commented 7 years ago

My register function is below. This was working previously on a website, but I've moved over to a web application and am running into the loading issues for dojo modules. As you can see, I am explicitly calling out the dojo modules in the register function such as the dojo/dom.

`esriSystem.register([
            "dojo/on",
            "dojo/dom",
            "dojo/ready",
            "dojo/dom-construct",
            "dojo/query",
            "dojox/gfx",
            "dojo/sniff",
            "esri/Color",
            "esri/geometry/Geometry",
            "esri/tasks/GeometryService",
            "esri/geometry/Extent",
            "esri/geometry/Point",
            "esri/geometry/Polygon",
            "esri/geometry/Polyline",
            "esri/SpatialReference",
            "esri/geometry/webMercatorUtils",
            "esri/geometry/ScreenPoint",
            "esri/graphic",
            "esri/layers/FeatureLayer",
            "esri/layers/GraphicsLayer",
            "esri/symbols/PictureMarkerSymbol",
            "esri/layers/MapImageLayer",
            "esri/layers/ArcGISTiledMapServiceLayer",
            "esri/layers/ArcGISDynamicMapServiceLayer",
            "esri/map",
            "esri/dijit/PopupTemplate",
            "esri/renderers/ClassBreaksRenderer",
            "esri/renderers/SimpleRenderer",
            "esri/renderers/Renderer",
            "esri/renderers/jsonUtils",
            "esri/symbols/SimpleFillSymbol",
            "esri/symbols/SimpleLineSymbol",
            "esri/symbols/SimpleMarkerSymbol",
            "esri/symbols/TextSymbol",
            "esri/tasks/IdentifyTask",
            "esri/tasks/IdentifyParameters",
            "esri/request",
            "esri/symbols/Symbol",
            "esri/tasks/query",
            "dojo/_base/array",
            "esri/dijit/Print",
            "esri/tasks/PrintTemplate",
            "esri/InfoTemplate",
            "esri/geometry/scaleUtils",
            "esri/dijit/OverviewMap",

            "dojo/_base/declare",
            "dojo/_base/connect",
            "dojo/_base/lang",
            "dojo/dom-class",
            "esri/dijit/Popup",

            "esri/layers/MapImage",
            "esri/layers/LayerInfo",
            "esri/dijit/Measurement",
            "esri/config"
], function () {
  // then bootstrap application
  System.import('app/main').then(function () {
    console.log('app/main imported');
  }, function (error) {
    console.log("Esri system error:", error);
  });
});`
jwasilgeo commented 7 years ago

@payneBrandon just to help us out some more with getting more info about this, can you try this approach and let us know if it does/n't work? https://github.com/Esri/esri-system-js#registering-as-a-single-module

payneBrandon commented 7 years ago

@jwasilgeo thanks for the help! I just tried using the single module, and when I do this, I get an error about 'cannot find module esri-mods'. I did a bit more digging as I had a feeling this error was only compile-time and was able to load the app when running in the browser. So that leaves me with some kind of issue in the IDE. Any ideas as to why I would run into issues at compile time but not runtime? Is there a step to make the compiler aware of the esri-system-js dojo modules that I'm misssing? I'm using VS2015 if that helps.

jwasilgeo commented 7 years ago

Oh, I'm not sure at all about VS, sorry. Have you tried with other IDEs, like VS Code? @tomwayson and I have seen other users experience funny business with VS.

tomwayson commented 7 years ago

Is the distinction between a "website" and a "web application" a VS thing? For all intents and purposes you should consider VS to be unsupported by this library. None of the maintainers have access to it. I recommend VS Code.

Have you tried system-js-plugin - that's a cleaner abstraction that may work better w/ VS.

On final thought. Are you using all those dojo and dojox modules in your own code? If not, you should not need to register them. If so, I'm curious as to why. Are you trying to integrate the ArcGIS API into an application built w/ another framework (Angular, etc)? If so strongly suggest using that framework to handle the low level things like dom manipulation. If not, why use System.js at all? Why not just build a Dojo app?

payneBrandon commented 7 years ago

The ArcGIS apps that I've been working on have been a part of larger applications which were originally built in VS and live in TFS (hence the continuation with VS, though I do like VS Code and will probably try that out for the GIS portion). The distinction between website and web app seems to mostly be a VS thing...the website requires you to push out all the c# files along with the .aspx files and isn't the most fun thing to work with.

I am working with Angular 2 to build this application, so I'll look into using that for the dom manipulations instead of dojo, great suggestion! Thanks for the help guys!

tomwayson commented 7 years ago

Closing due to inactivity. Re-open if needed.