I'm working in Typescript (v2.4.2) using Webpack to compile. Everything compiles fine, but when I run my code in IE11, I get the following error: 'Promise' is undefined.
Here's my 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/**/*"
]
}
Here's my webpack config:
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
})
]
};
I understand that I need some sort of polyfill, but I'm not sure what or how to implement it. Everything I've seen so far suggests certain polyfills like Promise and Whatwg-Fetch, but whenever I add them I get compile errors.