neutrinojs / neutrino

Create and build modern JavaScript projects with zero initial configuration.
https://neutrinojs.org
Mozilla Public License 2.0
3.95k stars 213 forks source link

Include @babel/plugin-proposal-optional-chaining #1501

Closed timkelty closed 4 years ago

timkelty commented 4 years ago

https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining just got bumped to Stage 4 and will be in ES2020: https://www.reddit.com/r/programming/comments/e6c3g0/ecmascript_optional_chaining_moved_to_stage_4_to/

Should we include it in our presets? Do we have a rule for when we include lang proposal plugins like this?

/cc @neutrinojs/core-contributors

helfi92 commented 4 years ago

woo, this is exciting!

Should we include it in our presets?

Makes sense to me.

edmorley commented 4 years ago

CRA uses the plugin: https://github.com/facebook/create-react-app/blob/b8ff97be72c02128c0917437d98e1b672a25ceb4/packages/babel-preset-react-app/create.js#L200

However it looks like it's soon going to be added to @babel/preset-env, so perhaps not worth us adding explicitly yet: https://github.com/babel/babel/issues/10809 https://github.com/babel/babel/pull/10811

Though it might be that we'll need to (and/or would want to anyway for other features in the future) enable the Babel shippedProposals option, to ensure the chaining support is picked up sooner (I'm not quite sure what cases the option applies to): https://babeljs.io/docs/en/babel-preset-env#shippedproposals https://github.com/babel/babel/blob/master/packages/babel-preset-env/data/shipped-proposals.js

edmorley commented 4 years ago

This plugin is now included in @babel/preset-env by default, so it should work out of the box in Neutrino 9.1.0+: https://github.com/babel/babel/releases/tag/v7.8.0