Description
I'm using the ASP.NET Bundler system just to transpile ECMA2015+ code to something that works on IE 11, and trying to upgrade to v5.0.0 and Babel 7 was more difficult than I thought it would be. It may be nice to have a migration guide to help with the process.
- The default Babel version changed from 6 to 7. This would be fine in a latest release except that:
- The default Babel presets and plugins changed.
es2015-no-common-js
is no longer a default preset, so upgrading from v4 to v5 (thereby automatically switching from Babel 6 to Babel 7) causes code that used to transpile down to pre-ES2015 not do so anymore. - It also looks like
@babel/standalone
changed some of the ways that plugins applied. The main thing I ran into is that async/await is not transpiled unless you include thees2017
preset, which wasn't the case inbabel-standalone
(I'm pretty sure.) - Babel does a poor job documenting presets for
@babel/standalone
. All their v7 documentation says to use@babel/preset-env
or at least that presets should be prefixed with@babel/
however that's not the case with@babel/standalone
. It still uses presets and preset names that everywhere else in Babel say are deprecated. So it's confusing, when directed to go to https://babeljs.io/docs/en/plugins that you actually can't really use any of the presets that they list on the presets page. I had to dig into the@babel/standalone
source code to figure out the presets I could use. I know a lot of this point are issues with Babel documentation, but perhaps it would be nice to have an enum we could use to set the presets, so we're not stumbling around figuring out which ones we can use.
I could be wrong on some of these points. The actual interaction of presets between Babel 6 and Babel 7 combined with the different presets for @babel/cli
vs. @babel/standalone
makes it complicated to test these differences definitively. I just know that I was getting valid ES2017 code to transpile fine on v4 with no configuration, and on v5 I had to add this configuration in order to get the similar results
ReactSiteConfiguration.Configuration
.SetBabelVersion(BabelVersions.Babel7)
.SetBabelConfig(new BabelConfig {
Presets = new HashSet<string> { "react", "es2015-no-commonjs", "es2016", "es2017", "stage-3" },
Plugins = new HashSet<string> { "proposal-object-rest-spread" }
});
I realize that switching major versions causes breaking changes like this to happen, but some documentation describing the changes needed would be appreciated.