简体   繁体   中英

Implement babel/typescript in a existing react project

i have some questions it is possible to implement babel in a existing react project or it's better to restart the project and add babel at the start to avoid any implement issues.

Is webpack is mandatory with babel for react project or you can implement babel without webpack.

Same question for typescript possible to implement it in a existing project or better to restart all?

and a last question if i have back in node and a front in react to i have to implement babel in the both?

Thank you for all your anwser.

I just started to work with React a little bit less than a month ago, so I had to do some research to answer your question. What I found that you don't have to restart your whole project, you can just install Babel and Typescript with npm. It is not necessary to use Webpack with Babel.

npm i @babel/core babel-loader @babel/preset-env @babel/preset-react --save-dev
npm install --save-dev typescript awesome-typescript-loader

About implementing TS I recommend reading this article.

If you created your application with create-react-app it already comes with Babel and Webpack and in that case you have to use the following command to implement Typescipt:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

I'm not really sure how to interpret your last question, so I'm going to leave that for more experienced fellows. I hope I could help you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM