Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ReferenceError: xxx is not defined #76802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Cygra opened this issue Mar 4, 2025 · 5 comments · May be fixed by #77964
Open

ReferenceError: xxx is not defined #76802

Cygra opened this issue Mar 4, 2025 · 5 comments · May be fixed by #77964
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.

Comments

@Cygra
Copy link

Cygra commented Mar 4, 2025

Link to the code that reproduces this issue

https://github.com/Cygra/reproduction-example-with-markdown-it

To Reproduce

  1. Start the application in development (next dev)

Current vs. Expected behavior

Current

 ⨯ ReferenceError: isSpace is not defined

Expected behavior

The application should start, since the method isSpace is defined and exported from the package "markdown-it".

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.18.1
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.15.0
Relevant Packages:
  next: 15.2.2-canary.0 // Latest available version is detected (15.2.2-canary.0).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label Mar 4, 2025
@Cygra
Copy link
Author

Cygra commented Mar 4, 2025

Related issue: markdown-it/markdown-it#1082

@Cygra
Copy link
Author

Cygra commented Mar 4, 2025

The error:

Image

@ifeora-emeka
Copy link

The error:

Image

Image

I was able to resolve the issue on my end by removing --turbo
I am using NextJs 15 with Turbo.

You may also want to downgrade markdown-it to [email protected]

@Cygra
Copy link
Author

Cygra commented Mar 9, 2025

The error:
Image

Image

I was able to resolve the issue on my end by removing --turbo I am using NextJs 15 with Turbo.

You may also want to downgrade markdown-it to [email protected]

Yes but, how can I use the latest markdown-it WITH turbo?

@timneutkens
Copy link
Member

Dug into this and found a minimal reproduction:

// app/assert.js
export function assert(a, b) {
  if (a !== b) {
    throw new Error(`Assertion failed: ${a} !== ${b}`);
  }
}
// app/page.js
import { assert } from "./assert";

const ch = 0x10;

function test() {
  for (;;) {
    // found valid marker
    if (ch === 0x29 /* ) */ || ch === 0x2e /* . */) {
      break;
    }

    return -1;
  }

  if (1 < 2) {
    if (!assert(1, 1)) {
      // " 1.test " - is not a list item
      return -1;
    }
  }
  return pos;
}

export default function Page() {
  return <h1>{test()}</h1>;
}

It's very similar to this issue: #77083

My current thinking is that the analysis seems to detect a case where return would be unconditional so the rest would be dead code, however it's not considering break that would break out of the loop or block, causing it to not replace the import for the helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear: turbopack Confirmed issue that is tracked by the Turbopack team. Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants