Esri / esri-system-js

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

Convert to a systemjs plugin? #20

Closed green3g closed 7 years ago

green3g commented 8 years ago

Would it be possible to convert this to a SystemJS Plugin? That way you could do something like this in your code, and you wouldn't have to pre-register any modules.

import {Map} from 'esri/Map!esri';
tomwayson commented 8 years ago

I looked at that briefly back before creating this repo, and if I recall, asked @odoe if he had tried it yet, and I think he said he couldn't get it to work.

tomwayson commented 8 years ago

FYI - I talked to @odoe after you opened this issue a few weeks back, and there was a glimmer in his eye that indicated that there might be something else to try.

If we could get that to work, I'd say it's a better solution than what we're doing here.

green3g commented 8 years ago

That is excellent. I started looking into it, https://gist.github.com/roemhildtg/4dce79f9bffe74b99a6a6cea3f44604f but it gives an error about a plugin having system.register in it. I can't exactly recall the error message though.

odoe commented 8 years ago

I'll try to revisit this. I'll be spending the next couple of weeks working with Angular 2/SystemJS, so I'll try to work this in as well.

tomwayson commented 8 years ago

Cool. If that works, I assume that would be it's own repo, so I'm going to press ahead w/ a v1 for this lib as that is long overdue.

diegohb commented 7 years ago

Coming out the dev conference... any update/progress on this effort? I read someone summarize the problem on twitter as it being about not being able to supply defaultJsExtension prop ANd another property on the systemjs config..

tomwayson commented 7 years ago

I'm not using Angular these days, and even if I was, I'd be using webpack to bundle my modules. I know that even in webpack apps, SystemJS can be used to lazy load bundles at runtime, but for lazy loading the ArcGIS API and modules, I'd use esri-loader. So I'm not actively working on this these days.

What is your use case? Are you using JSPM?

green3g commented 7 years ago

@tomwayson I'm using npm and stealjs, which is based on SystemJS but lets you load from node_modules.

Steal also transpiles es6 modules on the fly, so ultimately I'd like to do something like this:

import Map from 'esri/map'; 

// or 
import Map from 'esri/map!esriPlugin';

where esriPlugin would be this repository as a system js plugin.

beginor commented 7 years ago

Finally, I have made a systemjs.loader.dojo.js plugin works with Angular v2.4.7 and ArcGIS API for Javascript v4.2, can load ArcGIS API on demand, do not need to load all required modules before the app boot, and there is a demo: ng2-esri-demo

tomwayson commented 7 years ago

Nice work @beginor!

I tried @beginor's demo app, and it seems to work other than this AoT build issue: https://github.com/beginor/ng2-esri-demo/issues/2

@diegohb and @roemhildtg I suggested you both give his gist (which I believe is based on @roemhildtg's gist above) a try in your own applications.

If the pattern works for you guys, then maybe you guys could work together to create a repository for and publish the plugin.

beginor commented 7 years ago

@tomwayson No, the demo can not build with aot (rollup).

It is just a SystemJS loader plugin, so the demo just works with SystemJS.

Anyone who knows how to build dojo with rollup?

tomwayson commented 7 years ago

I know how to not build dojo w/ rollup, which is probably the best strategy, and have an example repo. I don't think rollup is your problem (yet). See my comment: https://github.com/beginor/ng2-esri-demo/issues/2#issuecomment-280863333

Regardless of whether or not you choose to try and get the AoT build working, I think it's worthwhile to create a repo for the SystemJS plugin and publish it to make it easier for others to use.

beginor commented 7 years ago

npm package: https://www.npmjs.com/package/systemjs-plugin-dojo github repo: https://github.com/beginor/systemjs-plugin-dojo demo repo: https://github.com/beginor/ng2-esri-demo

tomwayson commented 7 years ago

Awesome work @beginor!

diegohb commented 7 years ago

@tomwayson thanks! I am trying to use JSPM and Aurelia for MVVM framework. Currently I'm trying to focus on just SystemJS config w/ Dojo.. I will try out the SystemJS loader plugin by @beginor and I'll share my results and publish a demo repo if I'm successful. thanks!