Search code examples
babeljswebpacker

webpacker babel spam removal message not clear enough


Using webpacker with rails, the compilation process is spammed with a changed configuration issue form babel

While this solution of adding a resolutions block to the package.json file, + an update to most recent versions, got rid of a tom of these message, there is still a few

Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
["@babel/plugin-proposal-private-methods", { "loose": true }]
to the "plugins" section of your Babel config.

is not that helpful. A search for config reveals 76 items, of which 2 directories with that name and 4 .js fields that have that string in the name. In the babel subdirectory plugin-proposal-class-properties there is no config file and the suggested string is not of json format so that does not go in that su-directory's package.json file

So where exactly do we set this?


Solution

  • In babel.config.js, inside the plugins array, just add this as the last item:

    ['@babel/plugin-proposal-private-methods', { loose: true }]