pradel / create-react-app-esbuild

Use esbuild in your create-react-app for faster compilation, development and tests
MIT License
562 stars 34 forks source link

[Question] how does one translate usage of `.babelrc` with esbuild? #27

Closed samtsai closed 3 years ago

samtsai commented 3 years ago

We use the below .babelrc. I'm having trouble understanding what gets replaced by switching to esbuild. Just following the basic craco replacements doesn't work for me. I immediately run into:

Expected "from" but found "{"

Which I suspect might be a different issue than babel, possibly cause we're using flow and we import types, e.g. import type { GlobalStore } from "app/redux".

{
  "presets": ["@babel/preset-flow", "@babel/preset-react", "@babel/preset-env"],
  "plugins": [
    "dynamic-import-node",
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-syntax-import-meta",
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-proposal-json-strings",
    [
      "@babel/plugin-proposal-decorators",
      {
        "legacy": true
      }
    ],
    "@babel/plugin-proposal-function-sent",
    "@babel/plugin-proposal-export-namespace-from",
    "@babel/plugin-proposal-numeric-separator",
    "@babel/plugin-proposal-throw-expressions",
    "@babel/plugin-proposal-nullish-coalescing-operator"
  ]
}

Any help to further understand this migration would be great!

pradel commented 3 years ago

This plugin is replacing babel with esbuild, meaning that your babel config will not be used at all. At the current moment, esbuild only supports typescript and it doesn't seem that they are planning to support it at some point https://github.com/evanw/esbuild/issues/79.

pradel commented 3 years ago

Closing the issue, feel free to reopen if you still have questions