Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel-preset-react-app: Allow passing options #835

Closed
wants to merge 1 commit into from

Conversation

wmertens
Copy link

@wmertens wmertens commented Oct 3, 2016

Any options are passed to babel-preset-latest

Example use case: using native import support

"presets": [
  ["react-app", {"es2015": {"modules": false}}]
]

Any options are passed to babel-preset-latest

Example use case: using native import support
```
"presets": [
  ["react-app", {"es2015": {"modules": false}}]
]
```
@loganfsmyth
Copy link

FYI if you need to support Babel < 6.13, this will be a breaking change. If that is a concern, you can look at the approach we used for babel-preset-es2015.

@wmertens
Copy link
Author

wmertens commented Oct 3, 2016

Looks like react-app depends on babel-runtime 6.11. Were there any breaking
changes between 6.11 and 6.13?

On Mon, Oct 3, 2016 at 7:57 PM Logan Smyth [email protected] wrote:

FYI if you need to support Babel < 6.13, this will be a breaking change.
If that is a concern, you can look at the approach we used for
babel-preset-es2015.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#835 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADWlt6pGvjDAULBm-iHG1xVdxm0iShAks5qwUHtgaJpZM4KM0K-
.

@Jessidhia
Copy link

@wmertens There just hasn't been a babel-runtime release after v6.11.6.

Babel only releases packages that had changes on each release, but the versions are globally synchronized in the babel/babel repository.

@Jessidhia
Copy link

Jessidhia commented Oct 4, 2016

Maybe I'm just paranoid, and these count as either implementation details or bugs, but it could be good to explicitly depend on transform-es2015-classes, transform-es2015-destructuring and transform-es2015-parameters.

If you need to transform spread on function parameters (obj.func(...args) -> func.apply(obj, args)), transform-es2015-classes is needed for super(...args) to be transformed. transform-class-properties, if there is no previous constructor and there is an extends clause, generates a constructor with super(...args).

transform-object-rest-spread actually only implements spread; object rest is actually implemented by transform-es2015-destructuring, and you need transform-es2015-parameters to let transform-es2015-destructuring access destructuring in the parameter list.

@loganfsmyth
Copy link

@wmertens It wouldn't be the babel-runtime version in this case, it's the babel-core version that is loading the preset. We introduced function-based presets in 6.13 so if this is potentially used by users who have pinned their babel-core@<6.13 then this change would cause their builds to start throwing.

@gaearon
Copy link
Contributor

gaearon commented Oct 4, 2016

Thanks for the PR but I think we'll punt on having options for now.

We intentionally want to limit the number of permutations to limit the surface area for bugs and incompatibilities. This preset is not meant to be flexible.

We will eventually (probably after Webpack 2 is out of beta) remove CommonJS from it and bump the major.

@gaearon gaearon closed this Oct 4, 2016
@wmertens
Copy link
Author

wmertens commented Oct 4, 2016

I understand, I thought as much but could only try :)

On Tue, Oct 4, 2016 at 10:44 AM Dan Abramov [email protected]
wrote:

Closed #835
#835.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#835 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADWln3khruplaPNo3uKkXpmp-rOMjs5ks5qwhHdgaJpZM4KM0K-
.

@maiis
Copy link

maiis commented Oct 4, 2016

@wmertens for what it's worth, in the meantime I "hacked" it like that:

import babelLatest from 'babel-preset-latest';
import config from 'babel-preset-react-app';

config.presets[0] = [babelLatest, {
  es2015: {
    modules: false
  }
}];

export default config;

and passed this preset to my webpack config only for production ;)

@wmertens
Copy link
Author

wmertens commented Oct 4, 2016

@maiis ah yes of course, that's simple enough to maintain for now, thanks! I put it in my .babelrc as the path to a file containing

const config = require('babel-preset-react-app')

config.presets[0] = [config.presets[0], {es2015: {modules: false}}]

module.exports = config

@gaearon
Copy link
Contributor

gaearon commented Oct 4, 2016

Note for future readers: this is fragile and not officially supported, may break in any release.

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants