Customizing Babel Config returns Weird Error
Unanswered
Hexaa Scoooolzs posted this in #help-forum
Hello, so i'm using NextJS App Router and want to use a
But, when i remove the
Thanks.
twin.macro packages. but, when i do customizing a babel config, the nextjs will returns a weird error. like this:Syntax error: Unexpected token, expected ","
18 | import { useEffect, useState } from "react";
19 |
> 20 | export default function Home(request: {
| ^
21 | params: { locale: "id" | "en" };
22 | searchParams: {
23 | changeLang?: "true" | "false";
⨯ ReferenceError: React is not defined
at RootLayout (./src/app/[locale]/layout.tsx:15:5)
at stringify (<anonymous>)
16 | };
17 | }) {
> 18 | return (
| ^
19 | <Providers>
20 | <Navbar locale={params.locale} />
21 | <div>{children}</div>But, when i remove the
.babelrc or babel.config.js, the code runs perfectly. this is the babel config code:{
"presets": ["next/babel"],
"plugins": [
"macros",
"babel-plugin-styled-components",
"@babel/plugin-transform-react-jsx"
]
}Thanks.
9 Replies
no response?
never used it. does this example help you?
https://github.com/ben-rogerson/twin.examples/tree/master/next-styled-components
https://github.com/ben-rogerson/twin.examples/tree/master/next-styled-components
@Ray never used it. does this example help you?
https://github.com/ben-rogerson/twin.examples/tree/master/next-styled-components
nope, i'm install twin.macro guided by that example
@Hexaa Scoooolzs nope, i'm install twin.macro guided by that example
have you tried that example? it doesn't have
.babelrc or babel.config.js@Ray have you tried that example? it doesn't have `.babelrc` or `babel.config.js`
nope, but i have that
babel.config.js to fix some error like this:./node_modules/jiti/dist/jiti.js:1:72824
Module not found: Can't resolve 'perf_hooks'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/jiti/lib/index.js
./node_modules/tailwindcss/lib/lib/load-config.js
./node_modules/tailwindcss/lib/public/load-config.js
./node_modules/tailwindcss/loadConfig.js
./node_modules/twin.macro/macro.js
./src/app/[locale]/navbar.tsxbabel.config.js will not fix that (because i'm forgot what i'm doing)https://github.com/ben-rogerson/twin.macro/issues/836#issuecomment-1806926046 this.
i have seen this issue on others framework, same issue with
can't resolve 'perf_hooks' and can't resolve 'v8'up
up