next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Using triple && with swcMinify doesn't working

Open eashish93 opened this issue 3 years ago • 0 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 Binaries: Node: 16.15.0 npm: 8.5.5 Yarn: 3.2.0 pnpm: 7.8.0 Relevant packages: next: 12.2.5-canary.0 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome 103

How are you deploying your application? (if relevant)

No response

Describe the Bug

Consider this code:

const a = true;
const b = true;
const c = false;
if(a && b && c) {
  console.log('This shouldn\'t log');
}
if(c && b && a) {
  console.log('Reversed: This also shouldn\'t log');
}

When compiling with swcMinify, first one logged in browser which shouldn't happen, while second if working correctly. NOTE: It's working correctly in dev mode.

Expected Behavior

The above example shouldn't log.

Link to reproduction

https://codesandbox.io/s/sharp-lalande-bgfbvs

To Reproduce

  1. Check link for reproduction.
  2. Use swcMinify:true in next.config.js
  3. Build using next build
  4. Run with next start

eashish93 avatar Aug 09 '22 07:08 eashish93