我使用 Vue.js + TypeScript + Parcel 进行了演示,并async/await
在index.ts中尝试。
索引.html
<html>
...
<body>
<script src="index.ts"></script>
</body>
</html>
索引.ts
console.log('Not see me')
(async () => {
console.log('Did not execute here too.')
})()
执行parcel index.html
并打开http://localhost:1234/。控制台报错:regeneratorRuntime is not defined
index.a4a28941.js:110 Uncaught ReferenceError: regeneratorRuntime is not defined
at index.a4a28941.js:110
at Object.parcelRequire.306 (index.ts:3)
at newRequire (index.a4a28941.js:48)
at parcelRequire.306 (index.a4a28941.js:80)
at index.a4a28941.js:106
似乎async
语法需要polyfill?
这是我的tsconfig.json:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "preserve",
"module": "esnext",
"moduleResolution": "node",
"noImplicitReturns": true,
"sourceMap": true,
"strict": true,
"target": "esnext",
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "esnext.array", "dom", "dom.iterable", "scripthost", "es2015.generator"]
},
"parcelTsPluginOptions": {
// If true type-checking is disabled
"transpileOnly": false
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
"exclude": ["node_modules"]
}