console-ninja icon indicating copy to clipboard operation
console-ninja copied to clipboard

Module parse failed: Identifier '_templateObject' has already been declared

Open Lee-Jason-Curley opened this issue 1 year ago • 5 comments

Issue description or question

I can't run Console Ninja without running into this issue outlined in Stackoverflow post: https://stackoverflow.com/questions/74834358/module-parse-failed-identifier-templateobject-has-already-been-declared

Please note that this has been viewed by 1000+ times. So, it seems to be a persistent issue. My app is using node 18.14.0.

Is there going to be fix anytime soon? As is, Console Ninja is unusable for me. I'm using v1.0.268.

Wallaby diagnostics report

Lee-Jason-Curley avatar Dec 20 '23 23:12 Lee-Jason-Curley

We have seen an issue like this before and it was related to Next.js SWC compilation: https://github.com/vercel/next.js/issues/44113. We have added a fix for it in Console Ninja when it was originally reported.

Something must have changed in Next.js since then, so the issue is back and new fix may be required.

Unfortunately, we can't reproduce the issue in a freshly generated npx create-next-app@latest Next.js app. It's possible that some specific next.js setting or dependency of your app is causing it.

Can you please create a sample repo demonstrating the issue, we are happy to take a look and investigate.

ArtemGovorov avatar Dec 20 '23 23:12 ArtemGovorov

See sample repo: https://github.com/xuxucode/console-ninja-issue-249/blob/master/app/page.tsx#L12-L14

The critical part is a class with private methods:

// A class with two private methods which have same names. The only difference
// is one of them begins with a underscore.
class Client {
  #privateMethod() { }

  #_privateMethod() { }
}

xuxucode avatar Jan 18 '24 13:01 xuxucode

@xuxucode - We can reproduce the same issue in your sample repo with Console Ninja paused, disabled, and when Console Ninja is not installed. The problem in your sample repo is not a problem with Console Ninja, it looks to be a problem with Next.js compilation.

smcenlly avatar Jan 18 '24 23:01 smcenlly

@smcenlly Yes, it is related to Next.js, has nothing to do with Console Ninja.

xuxucode avatar Jan 19 '24 00:01 xuxucode

I also post the comment at https://github.com/vercel/next.js/issues/44113#issuecomment-1898503310, maybe it should be fixed there.

xuxucode avatar Jan 19 '24 00:01 xuxucode