Typescript running on IE 11 with webpack and ts-loader

965 views Asked by At

I have a small component that I have made to work with Typescript and Webpack, however, my target is ES5 to work with IE11. sadly does not matter what change I do, it won't compile for IE11, once I open in that browser it uses export default class but this is ES6. Giving me the error SCRIPT1002: Syntax error

Here are my Webpack and Tsconfig configuration. any idea what is wrong? I would like not to use any other polyfill as Babel or others.

Typescript

   {
      "compilerOptions": {
        "outDir": "./docs",
        "noImplicitAny": true,
        "module": "es6",
        "target": "es5",
        "allowJs": true,
        "sourceMap": true,
        "esModuleInterop": true, 
        "strict": true, 
        "lib": ["DOM", "ES6"]
      },
      "include": ["src"]
    }

Webpack:

const path = require('path');

module.exports = {
  entry: './src/index.ts',
  module: {
    rules: [
      {
        test: /\.ts$/,
        include: [path.resolve(__dirname, 'src')],
        use: 'ts-loader',
        exclude: /node_modules/,
      }
    ]
  },
  resolve: {
    extensions: ['.ts', '.js'],
  },
  devtool: 'inline-source-map',
  output: {
    publicPath: 'docs',
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'docs'),
  },
};
0

There are 0 answers