es6-micro-loader
es6-micro-loader copied to clipboard
Top-level promise for System.import not resolved for dynamically loaded files
@caridy I can't send a proper patch atm (will do later today while back at home) but there is a bug in the System.import handling of promises for dynamically loaded files - please notice how resolve
is never called when a file is loaded.
I believe that the proper solution is to do:
import: function(name) {
var normalizedName = normalizeName(name, []);
var mod = get(normalizedName);
return mod ? Promise.resolve(mod) : load(name).then(function () {
return get(normalizedName);
});
},
Does it sound reasonable? If so I will try to submit a PR, including tests (I just need to get familiar with the tools / testing strategy this project is using).
@pkozlowski-opensource sure, feel free to send the PR.
note: this project is highly experimental, a prove of concept for some of the discussions in TC39 about loader, I will highly recommend to use SystemJS instead.
about the tests, sure, just use npm test
and it will run the tests.
@caridy sure, I kind of figured it is experimental, thnx for the warning! Still, I think that there is very much place for a minimal System.register
loader like this. I love SystemJS (and in fact was using it thus far) but it just tries to accommodate all the existing module formats (as far as I understand it). I believe in using ES2015 module syntax today and have a minimal, lightweight loader till browser support this. Just like this one :-)
Anyway, will submit a PR - even if experimental it doesn't have to be buggy :-) Thnx for getting back to me so quickly.
@caridy I ran into the same issue as well. It seems it's been mentioned, but a call to resolve
needs to be issued around the call to load
or inside of the callback here: https://github.com/caridy/es6-micro-loader/blob/33045ce0518d3f4ef6aafb140bbb9ad4cdc9a5cf/client.js#L107
@jameslk yeh, there is PR #5 fixing this, not merged yet, though...