0

There have been a few questions like this in the past and the solutions given were to add a loader such as es2015. However I have tried adding es2015, 2016, 2017 (further ones and babel-preset-env gave other errors) and none of them could load this module. Other loaders in the webpack-config.js file are react and stage-0.

Module parse failed: Unexpected token
You may need an appropriate loader to handle this file type.
|  * @private
|  */
| Exporter.prototype.<function-name> = async function * <function-name>() {
|     yield '';
| };

Here's the rule for js files:

{
  test: /\.js$/,
  loader: 'babel-loader',
  exclude: [
    /node_modules/
  ],
  query: {
    cacheDirectory: true,
    presets: ['es2015', 'es2016', 'es2017', 'react', 'stage-0']
  }
}

and the .babelrc file:

{
  "presets": ["react", "es2015", "stage-0", "es2016", "es2017"]
}

Does anyone know what loader this needs? I am not very knowledgeable in babel, but it seems that this rule is excluding /node-modules/ and this error is coming from a module in the project. Might be relevant. Also relevant is that this same build is working on other computers where "es2015", "es2016", "es2017" have not been installed and were not added to presets in either of the files above. Thanks in advance.

  • Use https://babeljs.io/docs/en/babel-plugin-transform-runtime plugin – Dolly Feb 15 '21 at 16:41
  • Also, the order or presets should be```presets: [ 'es2015', 'react', 'stage-3', 'stage-0']``` – Dolly Feb 15 '21 at 16:52
  • @dolly how do I know what the correct order is? – אשל בר Feb 16 '21 at 08:28
  • Sorry for late response, Preset ordering is reversed (last to first). Read https://stackoverflow.com/questions/38620375/does-the-order-of-babel-6-presets-matter for your doubt. – Dolly Feb 24 '21 at 17:30

0 Answers0