2017-05-12 33 views

回答

3

這是SystemJS模塊格式自動檢測的問題。

它具有這樣的正則表達式來檢查,如果來源是ES6,需要transpiled:

// good enough ES6 module detection regex - format detections not designed to be accurate, but to handle the 99% use case 
    var esmRegEx = /(^\s*|[}\);\n]\s*)(import\s*(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s*from\s*['"]|\{)|export\s+\*\s+from\s+["']|export\s*(\{|default|function|class|var|const|let|async\s+function))/; 

果然,打字稿2.3.1和2.3.2有哪些匹配的正則表達式的源代碼此評論:

// For an export of a module, we may be in a declaration file, and it may be accessed elsewhere. E.g.: 
    //  declare module "a" { export type T = number; } 
    //  declare module "b" { import { T } from "a"; export const x: T; } 

所以,調試這時候,你可以看到,SystemJS加載transpiler(打字稿),決定了它是ES6,需要transpiled,加載transpiler,...,並沒有出現,transpiling您代碼(main.ts

爲打字稿正確格式爲「全球性」,在頂層所以加入這SystemJS配置應該修復它:

meta: {typescript: {format: 'global'}} 
+0

這是一個很好的,謝謝。 – estus