developit / nextjs-preact-demo

Next.js 9.3 + Preact = 21kB
https://nextjs-preact.now.sh
384 stars 25 forks source link

Custom babelrc file causes errors #35

Closed andrewgadziksonos closed 3 years ago

andrewgadziksonos commented 3 years ago

Hello,

I'm seeing the following error when using a custom babel config,

error - ./pages/_app.tsx
SyntaxError: ./pages/_app.tsx: pragma and pragmaFrag cannot be set when runtime is automatic.
> 1 | import React from "react"
    | ^
  2 | import { NextPage } from "next"
  3 | import { theme, ThemeProvider, GlobalStyles, LazyProvider } from "@sonos-ui/core"
  4 | import dynamic from "next/dynamic"

And here's the custom babel config,

{
  "presets": [
    [
      "next/babel",
      {
        "preset-react": {
          "runtime": "automatic",
          "importSource": "@emotion/core"
        }
      }
    ]
  ],
  "plugins": [["babel-plugin-emotion", { "cssPropOptimization": true }]]
}

I was following along in the emotion instructions (v10) https://5faaafd0bd0f3f0008469537--emotion.netlify.app/docs/css-prop#babel-preset

andrewgadziksonos commented 3 years ago

Linking this incase anyone gets here https://github.com/system-ui/theme-ui/issues/1160

Changing runtime: classic solved this for me