Pre*_*ton 2 fetch promise typescript internet-explorer-11
我正在使用 Webpack 编译 Typescript (v2.4.2)。一切都编译正常,但是当我在 IE11 中运行我的代码时,我收到以下错误:'Promise' 未定义。
这是我的 tsconfig:
{
"compilerOptions": {
"outDir": "./wwwroot/js",
"sourceMap": true,
"allowJs": true,
"lib": [
"dom",
"es5",
"scripthost",
"es2015.iterable"
],
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"skipDefaultLibCheck": true,
"types": [ "es6-promise" ]
},
"include": [
"./Ts/**/*"
]
}
Run Code Online (Sandbox Code Playgroud)
这是我的 webpack 配置:
const path = require('path');
const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: {
main: "./Ts/main.ts"
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "wwwroot/js")
},
devtool: "source-map",
resolve: {
extensions: [".ts", ".js"]
},
module: {
rules: [
{ test: /\.ts?$/, loader: "awesome-typescript-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
})
]
};
Run Code Online (Sandbox Code Playgroud)
我知道我需要某种 polyfill,但我不确定是什么或如何实现它。到目前为止,我所看到的一切都暗示了某些 polyfill,例如 Promise 和 Whatwg-Fetch,但是每当我添加它们时,都会出现编译错误。
| 归档时间: |
|
| 查看次数: |
4607 次 |
| 最近记录: |