question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If npm run start with swcMinify true, unreachable code will be called.

See original GitHub issue

What version of Next.js are you using?

12.0.7

What version of Node.js are you using?

16.13.0

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

AWS, Vercel

Describe the Bug

If you run npm run start with swcMinify set to true, unreachable code will be called. It is strange that unreachable code exists in the first place, so we should fix it, but I think there are times when such code is created unexpectedly in the world (like us😇). So, I would like to fix this bug. Please let me know if there’s anything I can do to help! Thanks! (Sorry if this is a bug in swc and I’m wrong to raise an issue here!)

Translated with www.DeepL.com/Translator (free version)

Expected Behavior

https://github.com/mayone-du/playground/tree/main/report/nextjs-swc

See the repository above. Or the code in ↓

import type { NextPage } from "next";
import { useEffect, useState } from "react";

type Status = "loading" | "error" | "success";

const IndexPage: NextPage = () => {
  const [value, setValue] = useState<Status>("loading");
  useEffect(() => {
    setTimeout(() => {
      setValue("success");
    }, 1000);
  }, []);

  if (value === "loading") {
    return <div>loading...</div>;
  } else if (value === "error") {
    return <div>error</div>;
  } else {
    return <div>success🥰 unreachable code is not called🙆‍♂️</div>;
  }

  return <div>unreachable code!!! this is a bug🐛</div>;
  // ↑Code that should not be called. swcMinify is called when it is set to true😕.
};

export default IndexPage;

To Reproduce

demo URLs.

in next.config.js ↓swcMinify: true (bug) https://report-nextjs-swc-npwjlueyx-mayone-du.vercel.app/

↓swcMinify: false (ok) https://report-nextjs-swc-bqbpg9h4z-mayone-du.vercel.app/

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
cuylcommented, Jan 13, 2022

Fixed in v12.0.8. But video.js bug still remain.

2reactions
cuylcommented, Jan 2, 2022

follow the issue swc-project/swc/issues/3173

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next failed to load SWC binary - Stack Overflow
When trying to run the command using nextjs npm ...
Read more >
Lots of error messages after npm install (Example) - Treehouse
Everything seems to be working and I got the server running, but there were also tonnes of error messages after running npm install....
Read more >
css-minimizer-webpack-plugin - npm package - Snyk
This will enable CSS optimization only in production mode. If you want to run it also in development set the optimization.minimize option to...
Read more >
How to Create an SSG (Static Site Generation) Application ...
Learn the advantages of each rendering method provided by Next.js. Then build an SSG (Static Site Generation) blog application using Strapi, Next.js, ...
Read more >
Next.js Tutorial for Beginners (Getting Started) | Stack Diary
You will write the core code of your application in this directory. ... If you run npm run dev , updating index.js will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found