vercel / vercel/next.js

When using webpack hook in appDir mode, got ReferenceError: Cannot access 'watcher' before initialization error.

Open
#48,818 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
142k
Forks
32.5k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Verify canary release
  • I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.1.0: Sun Oct  9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 16.18.0
      npm: 8.19.2
      Yarn: 1.22.19
      pnpm: 8.2.0
    Relevant packages:
      next: 13.3.1
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), CLI (create-next-app)

Link to the code that reproduces this issue

https://github.com/Innei/next-watcher-reproduction

To Reproduce

Install dependencies and run next dev.

Describe the Bug

Start dev crash, got ReferenceError: Cannot access 'watcher' before initialization

image
Expected Behavior

No crash

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the linked next-watcher-reproduction repository; install dependencies and run next dev to confirm the crash with appDir mode and a webpack hook. Trace the appDir webpack-hook startup path from the reported ReferenceError, and consider the issue done when next dev starts without the watcher initialization crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, webpack
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.