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

[turbopack] dynamic import with path alias not working #63372

@stefanprobst

Description

@stefanprobst

Link to the code that reproduces this issue

https://github.com/stefanprobst/issue-turbopack-imports

To Reproduce

  1. clone reproduction repo, install deps
  2. npm run dev
  3. open http://localhost:3000/ and see error message

Current vs. Expected behavior

i have the following dynamic imports, which work with webpack, but not with turbopack:

export async function i18n(locale: string) {
  /** This works with both turbopack and webpack. */
  // const messages = await import(`../messages/${locale}.json`)

  /** This works with webpack, but fails with turbopack. */
  const messages = await import(`@/messages/${locale}.json`)

  return messages
}

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #202401311935 SMP PREEMPT_DYNAMIC Thu Feb  1 00:46:47 UTC 2024
  Available memory (MB): 31403
  Available CPU cores: 16
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: 1.22.19
  pnpm: 8.15.4
Relevant Packages:
  next: 14.2.0-canary.26 // Latest available version is detected (14.2.0-canary.26).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.2
Next.js Config:
  output: N/A

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

Turbopack (--turbo)

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

next dev (local)

Additional context

reopening #61279 which was closed as a duplicate of #56531, which is marked as fixed - however the problem in this issue is not yet fixed.

PACK-2801

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