Repository: next.js
Issue: next dev with --turbo flag bug with "paths": {"*": ["types/*.d.ts"]} in tsconfig.json
Labels: bug,Turbopack

### Link to the code that reproduces this issue

https://github.com/Yohannfra/turbo-bug-reproduction-repo

### To Reproduce

1. Clone the linked repository
2. pnpm install && pnpm run dev
3. open localhost:3000


You will see this error message

```
 ✓ Ready in 679ms
 ⨯ src/i18n/routing.ts (8:24) @ [project]/src/i18n/routing.ts [middleware] (ecmascript)
 ⨯ Error: defineRouting is not defined
    at <unknown> ([project]/src/i18n/routing.ts [middleware] (ecmascript) (./src/i18n/routing.ts:8:24)
    at <unknown> (./[turbopack]/browser/runtime/base/dev-base.ts:205:21)
    at runModuleExecutionHooks (./[turbopack]/browser/runtime/base/dev-base.ts:264:5)
    at instantiateModule (./[turbopack]/browser/runtime/base/dev-base.ts:203:5)
    at getOrInstantiateModuleFromParent (./[turbopack]/browser/runtime/base/dev-base.ts:132:10)
    at esmImport (./[turbopack]/shared/runtime-utils.ts:214:18)
    at <unknown> ([project]/src/middleware.ts [middleware] (ecmascript) (./src/middleware.ts:3:1)
    at <unknown> (./[turbopack]/browser/runtime/base/dev-base.ts:205:21)
    at runModuleExecutionHooks (./[turbopack]/browser/runtime/base/dev-base.ts:264:5)
    at instantiateModule (./[turbopack]/browser/runtime/base/dev-base.ts:203:5) {
  digest: undefined
}
   6 | export const locales: LocaleType[] = ['fr', 'en', 'es', 'it', 'nl', 'de']
   7 |
>  8 | export const routing = defineRouting({
     |                        ^
   9 |   // A list of all locales that are supported
  10 |   locales: locales,
  11 |
 ✓ Compiled /_error in 401ms
 GET / 404 in 2ms
 ○ Compiling /_not-found/page ...
 ✓ Compiled /_not-found/page in 701ms
 ⨯ src/i18n/routing.ts (8:24) @ [project]/src/i18n/routing.ts [middleware] (ecmascript)
 ⨯ Error: defineRouting is not defined
    at <unknown> ([project]/src/i18n/routing.ts [middleware] (ecmascript) (./src/i18n/routing.ts:8:24)
    at <unknown> (./[turbopack]/browser/runtime/base/dev-base.ts:205:21)
    at runModuleExecutionHooks (./[turbopack]/browser/runtime/base/dev-base.ts:264:5)
    at instantiateModule (./[turbopack]/browser/runtime/base/dev-base.ts:203:5)
    at getOrInstantiateModuleFromParent (./[turbopack]/browser/runtime/base/dev-base.ts:132:10)
    at esmImport (./[turbopack]/shared/runtime-utils.ts:214:18)
    at <unknown> ([project]/src/middleware.ts [middleware] (ecmascript) (./src/middleware.ts:3:1)
    at <unknown> (./[turbopack]/browser/runtime/base/dev-base.ts:205:21)
    at runModuleExecutionHooks (./[turbopack]/browser/runtime/base/dev-base.ts:264:5)
    at instantiateModule (./[turbopack]/browser/runtime/base/dev-base.ts:203:5) {
  digest: undefined
}
   6 | export const locales: LocaleType[] = ['fr', 'en', 'es', 'it', 'nl', 'de']
   7 |
>  8 | export const routing = defineRouting({
     |                        ^
   9 |   // A list of all locales that are supported
  10 |   locales: locales,
  11 |
 GET /en 404 in 2ms
```

### Current vs. Expected behavior

This error doesn't exists without **--turbo** and the project run as expected.

Also after a *long* debugging session to find where this came from I found that this line in my tsconfig.json was causing it:

```json
    "paths": {"*": ["types/*.d.ts"]}
```

### Provide environment information

```bash
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:04 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 20.18.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.12.1
Relevant Packages:
  next: 15.0.2 // Latest available version is detected (15.0.2).
  eslint-config-next: N/A
  react: 19.0.0-rc.0
  react-dom: 19.0.0-rc.0
  typescript: 5.6.3
Next.js Config:
  output: N/A


-----

I also have the exact same bug on a my laptop running Ubuntu 22 and my intel Mac so I don't think the platform matters
```


### Which area(s) are affected? (Select all that apply)

Turbopack

### Which stage(s) are affected? (Select all that apply)

next dev (local)

### Additional context

_No response_