These are chat archives for systemjs/systemjs

23rd
Aug 2016
Artemy Tregubenko
@arty-name
Aug 23 2016 13:37
Hello. I would like to programmatically create a Module which exports a function as default value. Effectively module.exports = function(){}. When I write System.newModule(function(){})I get exception that it needs an object. When I follow online recommendations and write System.newModule({ default: function(){} }), the default export is an object with default property. What am I doing wrong?
var System = require('systemjs');
System.set(System.normalizeSync('x'), System.newModule({ 
    default: function(){ return 234 }
}));
System.import('x').then(function(x){ 
    console.log(x)
    x(); 
}).catch(console.error);
Module { default: [Getter/Setter] }
TypeError: x is not a function
    at /home/arty/Entwicklung/sys/test.js:7:5
    at process._tickCallback (internal/process/next_tick.js:103:7)
    at Module.runMain (module.js:577:11)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
    at bootstrap_node.js:467:3