Babel 7 + babel-preset-react-app@next but with TypeScript
See original GitHub issueHello there 👋 ,
I’m trying to unify my building, currently TypeScript & Babel, under Babel 7,
I’m using babel-preset-react-app@next
, to keep everything nice and updated, but, when I try to mix with @babel/preset-typescript
, I’ve the following error:
Module build failed: Error: Cannot combine flow and typescript plugins.
Seems it’s because we’ve the @babel/preset-flow
built in in babel-preset-react-app
,
My questions is:
- Could
babel-preset-react-app
make a opt-in/out for@babel/preset-flow
?
How to reproduce
Keep in mind, below, there’s no tsconfig.json
yet, because the project doesn’t even compile with both presets describe above
- package.json file:
"dependencies": {
"@babel/core": "^7.0.0-beta.38",
"@babel/preset-typescript": "^7.0.0-beta.38",
"babel-loader": "8.0.0-beta.0",
"babel-preset-react-app": "next",
"babel-runtime": "^6.23.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"webpack": "^3.10.0"
}
- .babelrc
{
"presets": ["react-app", "@babel/typescript"]
}
- webpack.config.js
const path = require("path");
module.exports = {
entry: "./main.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader"
}
}
]
}
};
- main.js
import React from "react";
import ReactDOMServer from "react-dom/server";
const App = () => <h1>Hello Wolrd!</h1>;
console.log(ReactDOMServer.renderToString(<App />));
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Setup a React App using Webpack, Babel and TypeScript
This article is part of a two part series on how to configure a React app from scratch with Webpack and Babel and...
Read more >Babel 7 + TypeScript - Artsy Engineering
TypeScript. We use it with React Native via Emission and on the web via Reaction. Until recently, however, projects that required the use...
Read more >Documentation - Using Babel with TypeScript
This technique is a hybrid approach, using Babel's preset-typescript to generate your JS files, and then using TypeScript to do type checking and...
Read more >Adding TypeScript Support to a Babel React App - Medium
Adding TypeScript Support to a Babel React App ; Install babel/babel-upgrade ; Use the babel upgrade tool in the project directory with npx...
Read more >Create React v18 TypeScript Project with webpack and Babel
The key module is @babel/preset-env and core-js . Because JavaScript evolution is so fast, hundreds of features must be transpiled and polyfilled. But...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I doubt that 😃. But if you can reuse the preset I guess that’s nice?
TypeScript is now officially supported as of Create React App 2.1. Read the release notes to get started!