Babel-loader: Main IIFE is an arrow function

Created on 29 Nov 2020  路  5Comments  路  Source: babel/babel-loader

I'm submitting a bug report

Webpack Version:
5.8.0
Babel Core Version:
7.12.9
Babel Loader Version:
8.2.2
Please tell us about your environment:
Linux

Current behavior:
Basically all works good but the whole bundle is wrapped inside IIFE which is an arrow function, I think it shouldn't be like that since im using babel properly - with @babel/preset-env

Expected/desired behavior:
Wraps bundle in IIFE normal func

All 5 comments

Same for me .
```
"@babel/core": "^7.12.9",
"@babel/preset-env": "7.12.1",
"babel-loader": "8.2.2",
"webpack": "^4.44.2",
"webpack-cli": "^4.2.0",
````

Just one point - on webpack 4.44.2 it gives normal function

@nemmtor it's not loader issue, this function is provided by webpack itself

the link https://webpack.js.org/configuration/output/#outputenvironment was really helpful

  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'index_bundle.js',

    // next do the trick
    environment: {
      arrowFunction: false, // <-----
    }
  },

Yup, that's injected by webpack _after_ running Babel.

I'm keeping this open in case anyone wants to add a mention of this problem and how to solve it to the README.

I will make a PR today

Fixed in #886

Was this page helpful?
0 / 5 - 0 ratings