Dagre Angular2系统JS模块加载

Dagre Angular2系统JS模块加载,angular,systemjs,dagre,Angular,Systemjs,Dagre,使用Angular2.4.0、TSC2.3.1,我尝试使用Dagre和JointJS/graphlib,使用SystemJS作为加载程序,在Angular2中绘制图形 我不知道如何按照JointJS的要求在浏览器中获取“dagre”对象 var dagre=require('dagre') 我的Angular2组件包括 import*作为“dagre”中的dagre 我的SystemJS配置: (function () { System.config({ map: {

使用Angular2.4.0、TSC2.3.1,我尝试使用Dagre和JointJS/graphlib,使用SystemJS作为加载程序,在Angular2中绘制图形

我不知道如何按照JointJS的要求在浏览器中获取“dagre”对象
var dagre=require('dagre')

我的Angular2组件包括
import*作为“dagre”中的dagre

我的SystemJS配置:

(function () {
  System.config({
    map: {
        'dagre': '/static/libs/dagre/dagre.js'
    }
});
})();
无法加载dagre会导致JointJS在尝试调用dagre.layout时出现未定义的错误:
无法读取未定义的属性“布局”

// Executes the layout.
dagre.layout(glGraph, { debugTiming: !!opt.debugTiming });

这可能是库本身没有导出的问题,或者我必须在SystemJS配置中指定格式吗?

所以我不确定到底是什么解决了这个问题,但我做了三件事:

1)
npm安装-D@types/dagre

2)
import*作为dagre从dagre导入在my component.ts中

3) 在SystemJS配置中添加了格式:全局

(function () {
  System.config({
    map: {
        'lodash': '/static/libs/lodash/index.js',
        'dagre': '/static/libs/dagre/dagre.js',
        'graphlib': '/static/libs/graphlib/grpahlib.umd.js',
    },
    meta: {
      'dagre': {
         format: 'global',
         deps: ['lodash'],
      },
      'graphlib': {
         format: 'global',
         deps: ['lodash'],
      }
    }
});
})();