1

I want to configure the babel options in my Ember app to either ignore the data-stubs folder, or set compact to false so I can silence the following error during builds:

[Babel: my-app > applyPatches][BABEL] 
 Note: The code generator has deoptimised the styling of dev/my-app/tests/data-stubs/foo.js
 as it exceeds the max of 500KB.

Accepted answers on StackOverflow say to configure the .babelrc file with {"compact": false}, but that isn't working with ember-cli builds. Reference Answer: BABEL Note: The code generator has deoptimised the styling of "app.js" as it exceeds the max of "100KB in Meteor

I made a .babelrc file in the root folder of my ember app and have tried many different configurations:

{
  "ignore": ["**/data-stubs/*.js", "tests/data-stubs/*", "*tests/data-stubs/*"], //do not translate our stub files
  "compact": false,
  "env": {
    "development": {
      "compact": false
    }
  }
}

None has any effect and always results in the The code generator has deoptimised the styling error message. I also put a .babelrc file into the data-stubs folder with the same settings as above, and that isn't working either.

dandan
  • 1,016
  • 8
  • 16

2 Answers2

0

This is expected. Ember uses ember-cli-babel which states in documentation:

If you need to customize the way that babel-preset-env configures the plugins that transform your code, you can do it by passing in any of the babel/babel-preset-env options. Note: .babelrc files are ignored by default.

While you can configure babel and ember-cli-babel in your ember-cli-build.js, I think compact will not work because of this open issue.

However you can specify exclude.

Lux
  • 17,835
  • 5
  • 43
  • 73
  • Actually I tried that exclude and it seems to be for types of javascript/functions and not for specific files. eg. ```// don't transpile generator functions exclude: [ 'transform-regenerator', ],``` but cudos to pointing out the `Note: .babelrc files are ignored by default.` that definetly helps. – dandan Nov 29 '19 at 04:43
  • yeah, the situation is actually even more complex, because every addon can bring another version of babel that should be used for the addon. – Lux Nov 29 '19 at 16:02
0

As of now, only the top level options destined for @babel/preset-env will work with ember-cli-babel . Unfortunately compact is not one of those.

Aswath
  • 96
  • 4