babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.39k stars 225 forks source link

IE Syntax error on minified code evaluation #928

Open babel-bot opened 6 years ago

babel-bot commented 6 years ago

Original issue submitted by @attatrol in https://github.com/babel/babel/issues/8980

Bug Report

Current Behavior IE 11.0.14393.0 returns error Syntax error in regular exception when i try to copy the minified code in its console.

Input Code REPL link

var regexpUnicodeSupport;
function test() { 
try { new RegExp("\uffff", "u"); regexpUnicodeSupport = true; }
  catch(e) {}
}

Expected behavior/code Successful evaluation.

Babel Configuration default minify preset used by REPL

Environment REPL

zloirock commented 5 years ago

It's also an issue for core-js: https://github.com/zloirock/core-js/issues/479 https://github.com/babel/babel/issues/9380

LucidityDesign commented 4 years ago

Any updates? I'm still having this problem with:

"@babel/polyfill": "^7.10.4",
"core-js": "^3.6.5",
"next": "^9.3.0",

and

"useBuiltIns": "usage",
LiquidMusic1 commented 4 years ago

I'm also still having this issue. It's happening in the package object-assign when i inspect the quarrelsome code in IE.... or at least that's the comment above the line to which the error is occurring. I have tried to put in es6-object-assign and use its automatic polyfill at the entry point of the application, but it still produces the same issue. I really need to get this fixed so that my app can move on in development.

I'm currently using (package.json):

   "@babel/plugin-proposal-class-properties": "^7.10.4",
    "@babel/plugin-proposal-object-rest-spread": "^7.11.0",
    "@babel/polyfill": "^7.2.5",
    "@types/react": "^16.4.18",
    "@types/react-dom": "^16.0.9",
    "axios": "^0.18.0",
    "babel-runtime": "^6.26.0",
    "clean-webpack-plugin": "^2.0.1",
    "core-js": "^2.5.7",
    "es6-object-assign": "^1.1.0",
    "handlebars": "^4.1.2",
    "handlebars-loader": "^1.7.1",
    "history": "^4.7.2",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.9.4",
    "npm": "^6.4.1",
    "raf": "^3.4.0",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-html-parser": "^2.0.2",
    "react-router-dom": "^4.3.1",
    "react-spinners": "^0.4.8",
    "rest": "^1.3.1",
    "styled-components": "^5.0.0",
    "util": "^0.12.1"

and in my webpack.config.js (just focusing on babel-loader):

             {
                    test: path.join(__dirname, '.'),
                    exclude: /(node_modules)/,
                    use: [{
                        loader: 'babel-loader?optional=runtime',
                        options: {
                            presets: [
                                [
                                    "@babel/preset-env",
                                    {
                                        useBuiltIns: 'entry',
                                        corejs: '2.5.7',
                                        targets: '> 0.25%, not dead'
                                    }
                                ],
                                "@babel/preset-react"
                            ],
                            plugins: [
                                '@babel/plugin-proposal-class-properties',
                                '@babel/plugin-proposal-object-rest-spread'
                            ]
                        }
                    }]
                }

I can provide as much detail as you need to help figure this out.

kieranbenton commented 1 year ago

Also having this issue with Vite - when configured using "@vitejs/plugin-legacy" as so:

    plugins: [
        ...
        legacy({
            targets: ["defaults, ie >= 11"], // include polyfills from core-js for this set of browsers
            additionalLegacyPolyfills: [
                "proxy-polyfill/proxy.min.js", // immer requires this
            ]
        })
    ],

IE11 will still not load a react based project, resulting in:

Unhandled promise rejection SyntaxError: Syntax error in regular expression

Not found a work around at the moment, and whilst I will probably just drop IE11 support I would prefer not to uncessarily.

jacob-baehr commented 1 year ago

@kieranbenton I am also having that same issue when using vite and with that plugin. @kieranbenton were you able to resolve this?

kieranbenton commented 1 year ago

Afraid not, but equally not tried it again