0

I'm able to build .ts files manually with tsc tool. And i see wrappers generated for async/await keywords.

But I have problem to setup transpile on the fly using systemjs.

index.htm:

<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typescript/1.7.5/typescript.min.js"></script>

<script>
  System.config({
    transpiler: 'typescript',
    typescriptOptions: {
      target: 'es6'
      },
    packages: {
      '': {
        defaultJSExtensions: 'ts'
      }
    }
  });

  System.import('app').catch(console.error.bind(console));
</script>

app.ts:

console.log('hello');

async function run() {
  console.log('world');
}

run();

Error in Developer Console:

SyntaxError: missing ; before statement

See plnkr

4

1 回答 1

0

问题在于指定格式“esm”。或者import.ts文件中添加一些关键字,以便 systemjs 可以选择正确的加载器。

System.config({
  transpiler: 'typescript',
  meta: {
    'app.ts': {
      format: 'esm'
    }
  }
});

System.import('app.ts').catch(console.error.bind(console));

更新了 plnkr

现在它就像一个魅力!

于 2016-01-14T06:45:45.793 回答