blitz-js / babel-plugin-superjson-next

Automatically transform your Next.js Pages to use SuperJSON
MIT License
125 stars 15 forks source link

d(...) is not a function #29

Closed JuanM04 closed 3 years ago

JuanM04 commented 3 years ago

https://codesandbox.io/s/clever-oskar-ltpop?file=/pages/index.js

next: 10.0.5
react: 17.0.1
react-dom: 17.0.1
superjson: 1.4.1
babel-plugin-superjson-next: 0.1.9
Skn0tt commented 3 years ago

Thanks for reporting this issue. I've created two reproduction test cases in #30, but both pass locally. Do you also face these issue locally or is it just in the CodeSandbox? On which operating system are you?

JuanM04 commented 3 years ago

It happened in my PC after updating next and other dependencies. I'm using WSL (ubuntu), but it also failed when I deployed it to Vercel

JuanM04 commented 3 years ago

I downgraded to next v10.0.4 and it works. So, it has something to do with v10.0.5

Skn0tt commented 3 years ago

That's good to know! I'll look into the updates made in 10.0.5 then.

cheesequest commented 3 years ago

Getting the same issue, Tried downgrading to 10.0.4 but no luck. Still getting the same error.

./pages/[...username].tsx
TypeError: E:\libby\libby-web\pages\[...username].tsx: d(...) is not a function

Is there a fix coming out soon?

Here's my code snippet:

export async function getServerSideProps({ params }) {
  const users = await prisma.user.findMany({
    where: {
      name: params.toString()
    }
  })

  return {
    props: { users }
  }
}
Skn0tt commented 3 years ago

We haven't yet found the root cause. I've asked for input on the Next.js contributors Slack, but haven't received answers yet. I'm in contact with Prisma now, seems like they know more (https://github.com/vercel/next.js/issues/21043#issuecomment-759608184)

cheesequest commented 3 years ago

We haven't yet found the root cause. I've asked for input on the Next.js contributors Slack, but haven't received answers yet. I'm in contact with Prisma now, seems like they know more (vercel/next.js#21043 (comment))

Thanks for the update. I think I'll place the development of my webapp on hold for now until there's a conclusion/fix.

JuanM04 commented 3 years ago

Getting the same issue, Tried downgrading to 10.0.4 but no luck. Still getting the same error.

Maybe you downgraded wrong. I have to yarn remove next && yarn add next@10.0.4 (without the ^) to downgrade correctly. I downgraded wrong immeasurable times.

cheesequest commented 3 years ago

Getting the same issue, Tried downgrading to 10.0.4 but no luck. Still getting the same error.

Maybe you downgraded wrong. I have to yarn remove next && yarn add next@10.0.4 (without the ^) to downgrade correctly. I downgraded wrong immeasurable times.

Alright I rechecked the version and it was stuck on 10.0.5 but I removed then installed next@10.0.4 and it works again. Only issue now is that it isn't showing data on Prisma but that's a separate issue altogether.

Update: I fixed it by changing params.toString() to params.username.toString()

Skn0tt commented 3 years ago

This indeed is a regression in Next.js 10.0.5. Bisecting lead me to https://github.com/vercel/next.js/pull/20586. I'm now further investigating it.

Skn0tt commented 3 years ago

Further digging led me to @babel/plugin-transform-react-jsx, which is updated in the aforementioned PR.

Skn0tt commented 3 years ago

Alright, so as a workaround I was able to make it work like this:

- export default function MyPage() {
+ function MyPage() {
    ..
  }

+ export default MyPage

Can you confirm this?

In general, this error shows very weird behaviour. For example, it doesn't occur when JSX isn't used at all:

export default function AStringReturningComponent() {
  return "something something help me understand why this works"
}
JuanM04 commented 3 years ago

Can you confirm this?

Yes, it works. That's very odd

Skn0tt commented 3 years ago

This is probably the most intricate build chain issue I've ever worked on 😳 Let's hope that the Babel team has an idea ... https://github.com/babel/babel/issues/12631

Skn0tt commented 3 years ago

With the masterful help of @nicolo-ribaudo and @JLHwung, we were able to find a workaround.

@JuanM04 @ChGGse could you try out 0.1.9-fix-19-danger (npm install babel-plugin-superjson-next@danger)? If that works for you, I'll publish a patch update with that. It works locally for me, so I'm positive on this ^^

JuanM04 commented 3 years ago

Yes, it works!!!

Skn0tt commented 3 years ago

Amazing! :D

Skn0tt commented 3 years ago

Published as v0.1.10.

What a ride! I'm really glad we solved this 🥳

Skn0tt commented 3 years ago

@allcontributors add JuanM04 for bug

allcontributors[bot] commented 3 years ago

@Skn0tt

I've put up a pull request to add @JuanM04! :tada:

Skn0tt commented 3 years ago

@allcontributors add ChGGse for bug

allcontributors[bot] commented 3 years ago

@Skn0tt

I've put up a pull request to add @ChGGse! :tada:

cheesequest commented 3 years ago

With the masterful help of @nicolo-ribaudo and @JLHwung, we were able to find a workaround.

@JuanM04 @ChGGse could you try out 0.1.9-fix-19-danger (npm install babel-plugin-superjson-next@danger)? If that works for you, I'll publish a patch update with that. It works locally for me, so I'm positive on this ^^

I'll test it out in the morning when I wake up!