首页 > 解决方案 > 我怎样才能让 babel 做 ie 与 core-js 的兼容性

问题描述

我有这个 webpack 代码

...
rules: [
        {
            test: /(\.m?js?$)|(\.svelte$)/,
            exclude: /\bcore-js\b/,
            use: {
                loader: 'babel-loader',
                options: {
                    presets: [
                        ['@babel/preset-env', {
                            targets: {
                                'ie':'11'
                            },
                            useBuiltIns: "usage",
                            corejs: 3
                        }]
                    ],
                    plugins: [
                        // '@babel/plugin-proposal-class-properties',
                        // '@babel/plugin-transform-shorthand-properties'

                    ],
                    sourceType: 'unambiguous'
                }
            }
        },
        {
            test: /\.svelte$/,
            exclude: /node_modules/,
            use: {
                loader: 'svelte-loader',
                options: {
                    //emitCss: true,
                    hotReload: true
                }
            }
        },
...

它适用于 chrome 等,但在 IE 中我收到此错误SCRIPT5002: Function expected in es.symbol.js 在此处输入图像描述

我不太明白为什么会这样或如何解决它,我认为 core-js 会解决这个问题?

标签: webpackbabeljscore-js

解决方案


推荐阅读