这是indexloc提供的服务,不要输入任何密码
Skip to content

Turbopack doesn't support dynamic requests #56531

@Maclay74

Description

@Maclay74

Link to the code that reproduces this issue

https://github.com/Maclay74/nextjs-turbopack-dynamic-import-bug

To Reproduce

  1. Start application via npm run dev
  2. Check console output, it should provide correct values from modules
  3. Restart application via npm run dev-turbo
  4. Check console output, names are wrong

Current vs. Expected behavior

Turbopack should import modules without caching them.

Current :

{ name: 'First', fileName: 'first.tsx' }
{ name: 'First', fileName: 'second.tsx' }
{ name: 'First', fileName: 'third.tsx' }

Expected:

{ Name: 'First', fileName: 'first.tsx' }
{ Name: 'Second', fileName: 'second.tsx' }
{ Name: 'Third', fileName: 'third.tsx' }

Moreover, there is inconsistent behavior related to hot-reloading of the page.
Page has some dynamic imports and when content of any of these modules is changes, it should trigger page reloading, as it depends on it.

Turbopack indeed does that, while webpack doesn't trigger page, although it recomplies the changed module.
To reproduce that, change files/first.tsx and see that with --turbo the page is reloaded and it didn't without it.

Verify canary release

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

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
Binaries:
  Node: 19.8.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 13.5.5-canary.3
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

Turbopack (--turbo)

Additional context

No response

PACK-2246

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