Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte got ERROR when @babel/preset-env target was 'ie >= 11' #4528

Closed
rhinonan opened this issue Mar 9, 2020 · 2 comments
Closed

Svelte got ERROR when @babel/preset-env target was 'ie >= 11' #4528

rhinonan opened this issue Mar 9, 2020 · 2 comments

Comments

@rhinonan
Copy link

rhinonan commented Mar 9, 2020

Describe the bug

Using webpack4 & babel7 to dev svelte application. Now it's just a 'hello world'. I need make it work on IE 11。

I use bable & babel-preset-env to translate js code. It's work fine when browsers was chrome,but when i change it to ie >= 11,it got an Error.

Logs

log.js:59 Uncaught TypeError: Class constructor SvelteComponent cannot be invoked without 'new'
    at new Componets (log.js:59)
    at Module../src/index.js (index.js:6)
    at __webpack_require__ (bootstrap:725)
    at fn (bootstrap:100)
    at Object.0 (app.js:15268)
    at __webpack_require__ (bootstrap:725)
    at bootstrap:792
    at bootstrap:792

To Reproduce

<!-- componet.svelte -->
<div class="svelte">
    <div>这是一个svelte组件(红框)</div>
</div>

here is my webpack.config.js

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');

module.exports = {
  entry: {
    app: "./src/index.js"
  },
  devtool: "inline-source-map",
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      title: "Output Management",
      template: "./index.html"
    }),
    new webpack.NamedModulesPlugin(),
    new webpack.HotModuleReplacementPlugin()
  ],
  module: {
    rules: [
      {
        test: /(\.m?js?$)|(\.svelte$)/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: "babel-loader",
          options: {
            presets: [
              [
                "@babel/preset-env",
                {
                  targets: {
                    browsers: ["ie >= 11"]
                  },
                  useBuiltIns: "usage",
                  corejs: 3
                }
              ]
            ]
          }
        }
      },
      {
        test: /\.(svelte)$/, // 不能使用html后缀
        exclude: /node_modules/,
        use: "svelte-loader"
      },
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      }
    ]
  },
  devServer: {
    contentBase: "./dist",
    hot: true,
    host: "0.0.0.0",
    open: false,
    overlay: true
  },
  output: {
    filename: "[name].js",
    path: path.resolve(__dirname, "dist")
  }
};

Who can help me?

@rhinonan
Copy link
Author

rhinonan commented Mar 9, 2020

I had tried the solution that was mentioned by this issue , but it does not work for me.

#2621

@Conduitry
Copy link
Member

GitHub issues aren't the right place for support questions like this. Please ask on StackOverflow or in our Discord chat room.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants