Skip to content

next-typesafe-url lib causes "ReferenceError: require is not defined" since canary v150 in dev mode with turbo #70186

@nctay

Description

@nctay

Link to the code that reproduces this issue

https://github.com/nctay/NextJS-canary-require-issue

To Reproduce

  1. Start dev with --turbo
  2. Get error ReferenceError: require is not defined

Current vs. Expected behavior

Current behavior:

Getting error ReferenceError: require is not defined

Expected behavior:

No errors

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.14.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 9.4.0
Relevant Packages:
  next: 15.0.0-canary.157 // Latest available version is detected (15.0.0-canary.157).
  eslint-config-next: 14.2.11
  react: 19.0.0-rc-206df66e-20240912
  react-dom: 19.0.0-rc-206df66e-20240912
  typescript: 5.6.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

i tested my reproduction against different canary releaases, the first one than introduced the bug was "15.0.0-canary.150", since reverting to "15.0.0-canary.149" works.
Last version of next-typesafe-url 4.1.0 published long ago. Seems like there is an issue with bundling server code to user since canary v150.
No errors using next dev without turbo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.bugIssue was opened via the bug report template.linear: turbopackConfirmed issue that is tracked by the Turbopack team.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions