facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.84k stars 26.88k forks source link

Switching to Babel 7 and change react-app preset while keeping all other settings #3933

Closed Baudin999 closed 6 years ago

Baudin999 commented 6 years ago

Is this a bug?

No, this is not a bug.

Question

I am trying to create an architecture which forces JavaScript into a more "functional" style and I'd really love to keep using create-react-app. What I'm trying to do is the following:

1) I'm trying to use babel 7 2) I want to use pipelines 3) I want to use do notation. 4) Simple async to generator 5) Pattern Matching plugins 6) etc etc

All of these things are needed to get a simple declarative style of programming:

const App 
    = props => <div>My component</div>
    |> connectMyComponent
    |> connectSubscriptions
    |> component => assure(p => p.users, component)

This is of course a very simple and not really well working example of the architecture.

I was wondering if there is an example of how to eject a project and the babel configurations because I can't find that in the documentation or find it when I eject the application. The only thing I can find is the react-app preset.

Apologies if these questions aren't appropriate or if this is not the place to ask this.

gaearon commented 6 years ago

You'd need to fork the preset and make your changes to it.

For Babel 7, you can check our next branch which already uses it. We already support async / await transform out of the box.

Other transforms you mentioned are not stable. You can use them of course, but I wouldn't call this "JavaScript"—in a few years they might not even exist, and the code you write against them will demand specific tooling (like old Babel versions) because newer versions of Babel might not support those proposals.

Proceed with caution!

Baudin999 commented 6 years ago

Thank you for the reply, I'll check out the next branch and I'll fork the presets.

And thank you for the warning! I know that those language things aren't JavaScript and most likely never will be in the spec and I understand that create-react-app can't put in stage-0 or stage-1 language features.

I'm just trying to gobble things together to get a more "Elmy" feel to my code. My architecture is basically an Elm architecture without type safety and these language features would make the code super-fly.