Turbopack: Fix next/font preloading for page.mdx (#88848)
## What?
This PR fixes font preloading for MDX pages in Turbopack and adds an e2e
test to verify the fix.
## Why?
When using `next/font` with MDX pages, font preloading was failing with
Turbopack because the LoaderTree was storing the **transformed module
path** instead of the **original source path**.
## The Bug
In Turbopack, MDX files are transformed by adding a `.tsx` extension:
- Source file: `app/page.mdx`
- After transform: `app/page.mdx.tsx`
The `create_module_tuple_code` function in `base_loader_tree.rs` was
using `module.ident().path()` (the transformed path) instead of the
original `path` parameter.
This caused a mismatch at runtime:
- Font manifest key: `[project]/app/page`
- LoaderTree stored: `[project]/app/page.mdx.tsx`
- After stripping `.tsx`: `[project]/app/page.mdx`
- **No match** → fonts not preloaded
## The Fix
Changed `crates/next-core/src/base_loader_tree.rs` to use the original
source path:
```rust
// Before
let module_path = module.ident().path().to_string().await?;
// After
let module_path = path.value_to_string().await?;
```
Now the LoaderTree stores `[project]/app/page.mdx`, which after
stripping `.mdx` at runtime becomes `[project]/app/page`, matching the
font manifest key.
## Test
Added `test/e2e/app-dir/mdx-font-preload/` which verifies:
1. MDX page renders correctly
2. Font class from layout is applied
3. Font is correctly preloaded
## How I tested these changes
```bash
pnpm test-start-turbo test/e2e/app-dir/mdx-font-preload/mdx-font-preload.test.ts
```
---------
Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>