Link to the code that reproduces this issue
https://github.com/stefanprobst/issue-turbopack-subpath-imports
To Reproduce
- clone repo
- pnpm install
- pnpn build
Current vs. Expected behavior
turbopack fails to resolve subpath imports (starting with #/*, configured in package.json) in dynamic import() statements with a placeholder, e.g.:
await import(`#/messages/${locale}/index.json`);
Error:
Error: Module not found: Can't resolve ('#/messages/' <dynamic> '/index.json' | '#/messages/en/index.json')
PackageInternal requests can only be Constant strings
Note that the same works fine when using either relative paths, or typescript path aliases, e.g.:
await import(`../../messages/${locale}/index.json`);
await import(`@/messages/${locale}/index.json`);
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #28~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 15:50:57 UTC 2
Available memory (MB): 32035
Available CPU cores: 4
Binaries:
Node: 24.19.0
npm: N/A
Yarn: N/A
pnpm: 11.20.0
Relevant Packages:
next: 16.3.1-canary.21 // There is a newer canary version (16.3.1-canary.24) available, please upgrade!
eslint-config-next: N/A
react: 19.2.8
react-dom: 19.2.8
typescript: 7.0.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 build (local), next dev (local)
Additional context
No response
Reactions are currently unavailable
Link to the code that reproduces this issue
https://github.com/stefanprobst/issue-turbopack-subpath-imports
To Reproduce
Current vs. Expected behavior
turbopack fails to resolve subpath imports (starting with #/*, configured in package.json) in dynamic import() statements with a placeholder, e.g.:
Error:
Error: Module not found: Can't resolve ('#/messages/' <dynamic> '/index.json' | '#/messages/en/index.json') PackageInternal requests can only be Constant stringsNote that the same works fine when using either relative paths, or typescript path aliases, e.g.:
Provide environment information
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next build (local), next dev (local)
Additional context
No response