These are chat archives for systemjs/systemjs

27th
Nov 2015
Aliaksandr Astashenkau
@dfsq
Nov 27 2015 14:17

Hello guys, something I don't understand about imports.
Say I import two modules:

import moment from 'moment';
import Pickaday from 'pikaday';

and pikaday relies on window.moment. However, turns out that window.moment is undefined inside pikaday during loading. So how such situations needs to be handled? I even tried crazy

import moment from 'moment';
window.moment = moment;
import Pickaday from 'pikaday';

but this won't work of course.

Peter Müller
@Munter
Nov 27 2015 14:19
You need to annotate the moment dependency in pikaday and also configure that it needs window.moment
Aliaksandr Astashenkau
@dfsq
Nov 27 2015 14:20
how is it done? I mean pikaday is an external code I can't edit
Peter Müller
@Munter
Nov 27 2015 14:20
You need a jspm override in that case
Aliaksandr Astashenkau
@dfsq
Nov 27 2015 14:23
I see, something I will need to investigate, thanks!
Jeremy Attali
@jtheoof
Nov 27 2015 20:00
Guys, I have a question regarding a library i am building. It's basically and sdk, with spport for node and browser. I have two files http_backend.js and xhr_backend.js. Based on whether or not I have XMLHttpRequest I call the function from the right file.
Pretty much all goes well but when I try to load the lib from nodejs (bundled with systemjs/builder) I get:
[Error: ENOENT: no such file or directory, open '.../mnubo-js-sdk-test/http']
Jeremy Attali
@jtheoof
Nov 27 2015 20:06
And in the generated file the code is:
System.registerDynamic("mnubo/http/backends/node_backend.js", ["http", "https", "mnubo/http/request.js"], true, function($__require, exports, module) {
  ;
  var global = this,
      __define = global.define;
  global.define = undefined;
  var http = $__require('http');
  var https = $__require('https');
  var request_1 = $__require('mnubo/http/request.js');
  function nodeHttpRequest(request) {
    var data = request.payload();
    var options = {
      protocol: request.options.protocol + ':',
      hostname: request.options.hostname,
      port: request.options.port,
      method: request_1.RequestMethods[request.method],
      path: request.options.path,
      headers: {'Content-Length': Buffer.byteLength(data)}
    };
...
Bascially what I am trying to do is, when in a node environment, load http and https the way it's supposed to be loaded from node.
So my guess is that I am doing something wrong when bundling my app, but can't pinpoint what.
Jeremy Attali
@jtheoof
Nov 27 2015 20:55
My code resides here: https://github.com/jtheoof/mnubo-js-sdk/tree/systemjs if anyone of you can help me understand how to have a browser and node sdk bundled together I would be really happy :) See gulpfile.js for the actual bundling.