'How to configure Babel to only output es2017/modern code?

I'm trying to configure web with optimize-plugin and babel to create module/nomodule bundles. In fact, I son't mind too much the nomodule thing, but I'd like to be sure to correctly configure babel to output es2017 code. In several tuts, for example this one, I've found a preset like 'es2017', but from babel docs it seems it's not supported anymore. Instead, I should use '@babel/preset-env' along with a browserlist config. It's not really clear to me how I should compose the browserlist. For now, I would say something like:

module.exports = { 
  presets : [ '@babel/preset-env' ],
  
  targets : {
    browsers: "last 2 versions, not dead, not IE 11",
    esmodules: true
  }
};

But not really sure.. Can someone tell me the perfect one? :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source