AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Turbopack Import.Meta.Glob Fails To Resolve Parent-Relative Patterns In Server Modules

import.meta.glob with `../` patterns matches nothing in server components and app routes under Turbopack in Next.js 16.3 canary, while `./` patterns work. This breaks Vite-compatible path semantics for parent traversal.

highConfidence 75%Next.jsAffected V16.3.0-Canary.78

Origin Analysis

Turbopack's import.meta.glob resolver does not correctly normalize parent-relative patterns (`../`) when matching against the importer's directory. The glob resolution likely treats the pattern as relative to the project root instead of the importing file's directory, or fails to expand `..` segments, causing the pattern to match no files when traversing upward.
1. Create a Next.js 16.3 canary project with Turbopack. 2. In a server component or app route, use import.meta.glob with a pattern containing `../` (e.g., `import.meta.glob('../lib/modules/*.js')`). 3. Run `next dev` or `next build && next start`. 4. Observe that the glob returns an empty object/array, while `./` patterns work.

Fixing Code Block

Edge Case Audit

The workaround relies on import.meta.glob supporting root-relative paths; if not fully supported, it may fail or behave differently. Test thoroughly before deploying. The structure change may break if files are moved. For a permanent fix, track the Next.js issue and upgrade once resolved. To rollback, revert the pattern changes.

Ecosystem Topology