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

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

@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: #202312131837 SMP PREEMPT_DYNAMIC Wed Dec 13 19:05:40 UTC 2023
Binaries:
  Node: 20.11.0
  npm: 10.2.4
  Yarn: 1.22.19
  pnpm: 8.14.1
Relevant Packages:
  next: 14.1.1-canary.17 // Latest available version is detected (14.1.1-canary.17).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.bugIssue was opened via the bug report template.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions