IE11 bundle.js中的错误



我正在使用TypeScript与Awesome-typecript-Loader和WebPack进行编译。但是在IE11中,它行不通。我有这个错误。

script1014

bundle.js(58458,12(

,在这一行中,我有这个。我认为问题在于字符'

const v6 =`

这是我对tsconfig.json

的配置
{
  "compilerOptions": {
    "target": "es6",
    "module": "es6",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "declaration": false,
    "esModuleInterop": true,
    "noImplicitAny": false,
    "jsx": "react",
    "sourceMap": true,
    "noLib": false,
    "suppressImplicitAnyIndexErrors": true,
    "baseUrl": "./src/",
    "paths": {
      "@pages": ["./pages/*"],
      "@core": ["./core/*"],
      "@pods": ["./pods/*"],
      "@common": ["./common/*"],
      "@state": ["./state/*"]
    },
    "skipLibCheck": true
  },
  "compileOnSave": false,
  "exclude": ["node_modules"]
}

这是我的webpack.config.js

    var HtmlWebpackPlugin = require("html-webpack-plugin");
var MiniCssExtractPlugin = require("mini-css-extract-plugin");
var webpack = require("webpack");
var path = require("path");
var basePath = __dirname;
module.exports = {
  context: path.join(basePath, "src"),
  resolve: {
    extensions: [".js", ".ts", ".tsx"],
    alias: {
      // Later on we will add more aliases here
      pages: path.resolve(__dirname, "./src/pages/"),
      core: path.resolve(__dirname, "./src/core/"),
      pods: path.resolve(__dirname, "./src/pods/"),
      common: path.resolve(__dirname, "./src/common/"),
      state: path.resolve(__dirname, "./src/state/"),
    }
  },
  entry: ["@babel/polyfill", "./index.tsx"],
  output: {
    path: path.join(basePath, "dist"),
    filename: "bundle.js"
  },
  devtool: "source-map",
  devServer: {
    contentBase: "./dist", // Content base
    inline: true, // Enable watch and live reload
    host: "test",
    port: 8080,
    stats: "errors-only",
    disableHostCheck: true,
    historyApiFallback: true,
  },
  module: {
    rules: [
      {
        test: /.(ts|tsx)$/,
        exclude: /node_modules/,
        loader: "awesome-typescript-loader",
        options: {
          useBabel: true,
          babelCore: "@babel/core" // needed for Babel v7
        }
      },
      {
        test: /.css$/,
        use: [MiniCssExtractPlugin.loader, "css-loader"]
      },
      {
        test: /.(png|jpg|gif|svg)$/,
        loader: "file-loader",
        options: {
          name: "assets/img/[name].[ext]?[hash]"
        }
      }
    ]
  },
  plugins: [
    //Generate index.html in /dist => https://github.com/ampedandwired/html-webpack-plugin
    new HtmlWebpackPlugin({
      filename: "index.html", //Name of file in ./dist/
      template: "index.html", //Name of template in ./src
      hash: true
    }),
    new MiniCssExtractPlugin({
      filename: "[name].css",
      chunkFilename: "[id].css"
    })
  ]
};

和.babelrc文件

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "entry"
      }
    ]
  ]
}

我对这个问题没有更多的想法。

请检查字符,也许您正在使用中文符号字符'''。尝试将其更改为英语字符''。

ie 11不支持模板字面。模板文字是ES6语法,因此我建议您在tsconfig中使用es5 target

如果您不确定每个浏览器可以使用什么在此处检查

相关内容

  • 没有找到相关文章

最新更新