question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Babel 7 + babel-preset-react-app@next but with TypeScript

See original GitHub issue

Hello 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.
screen shot 2018-01-19 at 12 44 13 pm

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:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Jan 19, 2018

I doubt that 😃. But if you can reuse the preset I guess that’s nice?

0reactions
Timercommented, Oct 30, 2018

TypeScript is now officially supported as of Create React App 2.1. Read the release notes to get started!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found