SystemJs,Angular2导入文件

SystemJs,Angular2导入文件,angular,systemjs,Angular,Systemjs,这是我在index.html中的systemJs配置 <script> System.config({ packages: { app: { format: 'register', defaultExtension: 'js' } } }); System.import('./ts/app.js') .then(null, console.error.bind(con

这是我在index.html中的systemJs配置

<script>
  System.config({
    packages: {        
      app: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });

  System.import('./ts/app.js')
        .then(null, console.error.bind(console));
</script>
为什么我总是在导入(login directive.js)或系统js app.js中定义.js,而不只是在defaultExtension设置为“js”时定义login directive和app

tnx
miha

事实上,在SystemJS配置中,
格式='register'
默认扩展='js'
仅适用于以app/开头的模块

System.import('app/boot')
    .then(null, console.error.bind(console));
<> >或者如果<代码>组件,js<代码>位于“<代码> App文件夹”下(我认为导入是在一个模块内进行的,在代码> APP<代码>下,例如<代码> APP/BOOST 模块):

结构如下:

app/
  boot.js (compiled from boot.ts)
  component.js (compiled from component.ts)
否则,SystemJS将尝试直接使用其名称加载模块

System.import('ts/app.js')
    .then(null, console.error.bind(console));

事实上,在SystemJS配置中,
format='register'
defaultExtension='js'
仅适用于以app/开头的模块

System.import('app/boot')
    .then(null, console.error.bind(console));
<> >或者如果<代码>组件,js<代码>位于“<代码> App文件夹”下(我认为导入是在一个模块内进行的,在代码> APP<代码>下,例如<代码> APP/BOOST 模块):

结构如下:

app/
  boot.js (compiled from boot.ts)
  component.js (compiled from component.ts)
否则,SystemJS将尝试直接使用其名称加载模块

System.import('ts/app.js')
    .then(null, console.error.bind(console));

嗨,thierry,这是systemJS的默认行为?我应该如何更改我的配置以使其工作(ts/)?我会将
ts
放入你的SystemJS配置中,而不是
packages
块中的
app
,但要小心:如果你使用SystemJS:
System.config动态传输,app.js可能包含TypeScript文件({transpiler:'typescript',typescriptOptions:{emitdecormatata:true},
hi:)tnx对此…我非常感谢您的一点帮助。好的,我的SystemJs配置如下所示:System.config({app:{format:'register',defaultExtension:'js'});System.import('app/boot.js').then(null,console.error.bind(console));但在应用程序文件夹中,我仍然需要这样做导入:从“./app/components/app.gsHeader.js”导入{gsHeader};我可能做错了什么?现在我在应用程序文件夹中。tnxMihahi thierry,这是systemJS的默认行为?我应该如何更改配置以使其正常工作(ts/)?我会将
ts
放在你的SystemJS配置中,而不是
packages
块中的
app
,但要小心:如果你在运行中使用transpiling与SystemJS:
System.config({transpiler:'TypeScript',typescriptOptions:{emitdecormatatadata:true}一起使用,app.js可能包含TypeScript文件,…
hi:)tnx为此…我真的非常感谢关于这方面的一点小帮助。好的,我的SystemJs配置看起来像这样:System.config({app:{format:'register',defaultExtension:'js'}});System.import('app/boot.js')。然后(null,console.error.bind(console));但在应用程序文件夹中,我仍然要这样导入:从“./app/components/app.gsHeader.js”导入{gsHeader};我可能做错了什么?现在我在应用程序文件夹中。tnxMihaI认为defaultExtension已被弃用,但由于向后兼容而被保留。它与插件加载程序的工作方式发生冲突,并中断了从承载不带扩展的CDN加载内容。我相信defaultExtension已被弃用,但被保留用于向后兼容它与插件加载程序的工作方式相冲突,并打破了从承载不带扩展的CDN加载内容的做法。