nextjs - ✅(Solved) Fix Turbopack: Dynamic imports with complex patterns fail when styled-jsx wildcard exports are configured [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#83785Fetched 2026-04-08 02:21:29
View on GitHub
Comments
2
Participants
3
Timeline
10
Reactions
0
Timeline (top)
labeled ×3commented ×2closed ×1cross-referenced ×1

Error Message

  1. The error will appear in the terminal and browser When using Turbopack with dynamic imports that have complex path patterns (double dynamic segments) and styled-jsx optimization configured, the following error occurs: Error while looking up import map: complex patterns into wildcard exports fields are not implemented yet: '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic> into 'styled-jsx/*' This is my best attempt at a reproduction. My subject repo where this is occurring is a highly complex multi-tenant app. The error in this reproduction goes away when optimizePackageImports: ['styled-jsx'] and transpilePackages: ['styled-jsx'] are removed. But, in my subject repo, I get the very same error even without these config params. Clearly maintainers are aware of this given the error message: complex patterns into wildcard exports fields are not implemented yet. I guess I'm wondering, is this avoidable? Will such a pattern be implemented any time soon?

Fix Action

Fixed

PR fix notes

PR #84178: Turbopack: support more dynamic request with import map

Description (problem / solution / changelog)

Add support to resolve arbitrarily dynamic requests into a '@/*": "./@" import mapping, such as

import(`@/styles/themes/theme-${themeName}/theme-${themeName}`)

Closes #83785 Closes PACK-5451

This was basically a regression from #82757

Changed files

  • turbopack/crates/turbopack-core/src/resolve/alias_map.rs (modified, +12/-1)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/resolving/tsconfig-paths-dynamic/input/index.js (modified, +4/-4)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/resolving/tsconfig-paths-dynamic/input/src/foo.ts (modified, +3/-4)

Code Example

Module not found: Can't resolve '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic>
  32 |   const themeName = site?.themeName ? toKebabCase(site?.themeName) : "one";
  33 |
> 34 |   const selectedTheme = await import(`@/styles/themes/theme-${themeName}/theme-${themeName}`);
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  35 |
  36 |   console.log(themeName);
  37 |   console.log(selectedTheme);

complex patterns into wildcard exports fields are not implemented yet: '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic> into 'styled-jsx/*'

Debug info:
- Execution of <ModuleAssetContext as AssetContext>::resolve_asset failed
- Execution of resolve failed
- Execution of resolve_internal failed
- complex patterns into wildcard exports fields are not implemented yet: '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic> into 'styled-jsx/*'
Error while looking up import map: complex patterns into wildcard exports fields are not implemented yet: '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic> into 'styled-jsx/*'

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.16.0
  npm: 11.4.2
  Yarn: 1.22.19
  pnpm: 10.16.0
Relevant Packages:
  next: 15.6.0-canary.6 // Latest available version is detected (15.6.0-canary.6).
  eslint-config-next: 15.5.3
  react: 19.1.1
  react-dom: 19.1.1
  typescript: 5.3.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/alexanderbnelson/dynamic-import-turbo

To Reproduce

  1. Clone the reproduction repository: git clone https://github.com/alexanderbnelson/dynamic-import-turbo
  2. Install dependencies: pnpm install
  3. Start the development server with Turbopack: pnpm run dev (runs next dev --turbo)
  4. Navigate to http://localhost:3000 in your browser
  5. The error will appear in the terminal and browser

Current vs. Expected behavior

Current behavior: When using Turbopack with dynamic imports that have complex path patterns (double dynamic segments) and styled-jsx optimization configured, the following error occurs:

Module not found: Can't resolve '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic>
  32 |   const themeName = site?.themeName ? toKebabCase(site?.themeName) : "one";
  33 |
> 34 |   const selectedTheme = await import(`@/styles/themes/theme-${themeName}/theme-${themeName}`);
     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  35 |
  36 |   console.log(themeName);
  37 |   console.log(selectedTheme);

complex patterns into wildcard exports fields are not implemented yet: '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic> into 'styled-jsx/*'

Debug info:
- Execution of <ModuleAssetContext as AssetContext>::resolve_asset failed
- Execution of resolve failed
- Execution of resolve_internal failed
- complex patterns into wildcard exports fields are not implemented yet: '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic> into 'styled-jsx/*'
Error while looking up import map: complex patterns into wildcard exports fields are not implemented yet: '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic> into 'styled-jsx/*'

https://nextjs.org/docs/messages/module-not-found`

Expected behavior: The dynamic import should resolve correctly and load the appropriate theme module, similar to how it works without Turbopack or without the styled-jsx configuration.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.16.0
  npm: 11.4.2
  Yarn: 1.22.19
  pnpm: 10.16.0
Relevant Packages:
  next: 15.6.0-canary.6 // Latest available version is detected (15.6.0-canary.6).
  eslint-config-next: 15.5.3
  react: 19.1.1
  react-dom: 19.1.1
  typescript: 5.3.3
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

Effects build also

This is my best attempt at a reproduction. My subject repo where this is occurring is a highly complex multi-tenant app. The error in this reproduction goes away when optimizePackageImports: ['styled-jsx'] and transpilePackages: ['styled-jsx'] are removed. But, in my subject repo, I get the very same error even without these config params.

complex patterns into wildcard exports fields are not implemented yet: '@/styles/themes/theme-' <dynamic> '/theme-' <dynamic> into 'styled-jsx/*'

My subject project is calling for styled-jsx to be used but I'm not entirely sure where. The only place I see it referenced is in my lock file as a peer dependancy for @babel/core

Clearly maintainers are aware of this given the error message: complex patterns into wildcard exports fields are not implemented yet. I guess I'm wondering, is this avoidable? Will such a pattern be implemented any time soon?

<sub>PACK-5451</sub>

extent analysis

TL;DR

The most likely fix or workaround is to remove or modify the optimizePackageImports and transpilePackages configurations related to styled-jsx in the Next.js configuration.

Guidance

  • Remove optimizePackageImports: ['styled-jsx'] and transpilePackages: ['styled-jsx'] from the Next.js configuration to see if the error resolves.
  • If the error persists, try to identify where styled-jsx is being used in the project and consider alternatives or modifications to avoid complex dynamic import patterns.
  • Keep an eye on the PACK-5451 issue for updates on the implementation of complex patterns into wildcard exports fields.

Notes

The error message indicates that the implementation of complex patterns into wildcard exports fields is not yet available, and the maintainers are aware of this issue.

Recommendation

Apply a workaround by removing or modifying the styled-jsx related configurations, as the implementation of complex patterns is not yet available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING