These are chat archives for systemjs/systemjs

9th
Apr 2015
Will Prater
@wprater
Apr 09 2015 02:14
should I revert to 4.x?
Mike Haas
@mikehaas763
Apr 09 2015 14:57
Is the systemjs loader eventually supposed to be replaced by a native loader? What I mean is, what will eventually replace things like System.import() and System.config()?
Dave Ackerman
@dmackerman
Apr 09 2015 18:38
when I import a module, inside that module it has a var he = require(‘he’);
but, it seems that it’s looking for it not on the correct path
if (typeof he !== 'object' && typeof require === 'function') {
  var he = require('he');
}
Mike Haas
@mikehaas763
Apr 09 2015 18:39
@dmackerman do you need to shim it or set a basepath etc using System.config calls?
Dave Ackerman
@dmackerman
Apr 09 2015 18:47
that flew over my head
im not sure. I’m trying to use this library here https://github.com/domchristie/to-markdown
Mike Haas
@mikehaas763
Apr 09 2015 18:48
Are you bundling everything up into a single file including to-markdown?
Dave Ackerman
@dmackerman
Apr 09 2015 18:49
hmm, when I installed to-markdown from JSPM, it seems like the path it’s including isn’t the bundled file.
maybe I need to fork it and change the path
Guy Bedford
@guybedford
Apr 09 2015 20:00
@dmackerman you probably want to load that package from the jspm install npm:... if possible rather. Alternatively shim it as a global through Github install jspm install github:... -o "{format:'global'}"
Nelo Mitranim
@Mitranim
Apr 09 2015 20:09

Is it possible to defer exports in systemjs? The goal is:
1) module A wants to import module B
2) module B runs an arbitrary amount of asynchronous work to generate values to export
3) module B exports the generates values and tells to systemjs "I'm ready"
4) those values are imported into module A

Possible / not possible?

stagas
@stagas
Apr 09 2015 20:16
@Mitranim it's bad approach imho, you should be exporting a method from B that A would explicitly call to fetch those values
Nelo Mitranim
@Mitranim
Apr 09 2015 20:17
Well my use case doesn't allow that, I want to make a wrapper to retrieve angular1 services through its dependency injection and export them es6 way
stagas
@stagas
Apr 09 2015 20:18
@Mitranim one problem with that approach would be, what happens when modules other than A import B ?
Nelo Mitranim
@Mitranim
Apr 09 2015 20:18
Well all of them need to be deferred until it's done
stagas
@stagas
Apr 09 2015 20:21
I find it really hard to believe what you need can't happen using a method call and deferring yourself
I've never used angular though so I may be wrong
but I think imports/exports are static and sync
Nelo Mitranim
@Mitranim
Apr 09 2015 20:29

Compare. Current:

// Module 1
angular.module('my-module', [/* dependencies */])
.factory('myService', function(/* dependency list */) {
  /* export service value here */
}}
// Can only use myService in similarly declared angular1 modules
through dependency injection.

// Module 2
angular.module('my-module')
.factory('otherService', function(myService) {
  /* do stuff */
})

Ideally enabled by async systemjs wrapper:

// Module 1
angular.module('my-module', [/* dependencies */])
.run(function(/* dependency list */) {
  /* export myService asynchronously through systemjs */
}}

// Module 2
import {myService} from 'my-module-file'
/* do stuff */

Example with angular's inner service $q:

// Module 1
angular.module('my-module', [])
.run(function($q) {
  /* export $q asynchronously with systemjs */
})

// Module 2
import {$q} from 'my-module-file'
/* do stuff */
The problem is that .factory, .run etc are async
Anyway maybe some just knows the answer and will tell it's impossible
Anyone? :)
stagas
@stagas
Apr 09 2015 20:33
afaik imports/exports can't even be used in a conditional block, they need to be top level
maybe with System.register you could do it though
Nelo Mitranim
@Mitranim
Apr 09 2015 20:33
In ES6 modules, yes
Yeah I'm asking if maybe System enables this
stagas
@stagas
Apr 09 2015 20:37
my guess is yes, you can create your modules asynchronously, then finally boot with a System.import
not sure of the details on the how but I think it's possible :)
Nelo Mitranim
@Mitranim
Apr 09 2015 20:39
Huh nice should give this a try
stagas
@stagas
Apr 09 2015 20:42
I guess it's called a universal dynamic module loader for that reason haha