Repository: next.js
Issue: Parse error with pnpm package from private git repo in `next dev`
Labels: bug,Webpack

### Link to the code that reproduces this issue

- https://github.com/jinmayamashita/re-pk
- https://github.com/jinmayamashita/my-next-repro

### To Reproduce

1. Install dependencies using pnpm, including the package from [the private Git repository](https://pnpm.io/cli/add#install-from-git-repository). (A package to keep the username/repository and package name is total 60 characters or fewer)
1. Add package to [`transpilePackages`](https://nextjs.org/docs/app/api-reference/next-config-js/transpilePackages) in `next.config.js`
1. Start the application in development mode.
1. Navigate to the page where the imported package is used.
1. The error occurs.

### Current vs. Expected behavior

**Current Behavior**

When running `next dev` after installing dependencies from a private git repository using pnpm, the development server fails to start, and an error occurs. 

```sh
pnpm next dev
  ▲ Next.js 14.2.3
  - Local:        http://localhost:3000
  - Experiments (use with caution):
    · turbo

 ✓ Starting...
 ✓ Ready in 2.4s
 ○ Compiling / ...
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '/Users/username/my-next-repro/.next/server/vendor-chunks/@my-pkg+cxxxyyyyzzzzaaaabbbbccccddddeeex@git+https+++...
    at Object.stat (node:fs:1581:10)
    at Object.stat (/Users/username/my-next-repro/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/compiled/webpack/bundle5.js:1:278999)
    at writeOut (/Users/username/my-next-repro/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/compiled/webpack/bundle5.js:28:144696)
    at /Users/username/my-next-repro/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.9_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/next/dist/compiled/webpack/bundle5.js:28:1378675
    at FSReqCallback.oncomplete (node:fs:188:23) {
  code: 'ERR_INVALID_ARG_VALUE'
}
```

Interestingly, it seems that the failure depends on the length of the package name and the repository URL.

*Here are the character counts for cases with errors and those without. (`pnpm-lock.yaml` reference)*

```yaml
importers:

  .:
    dependencies:
      # No errors - It seems that there are no errors with the public repository.
      '@my/pkg-a':
        specifier: github:jinmayamashita/re-pkg#main
        version: https://codeload.github.com/jinmayamashita/re-pkg/tar.gz/79f988d6f2c6f5a59f80c5670bdeb7c79fbf4f54

      # Error occurs - Username, reponame, and package name total 60 characters or fewer.
      '@my/pkg-cxxxyyyyzzzzaaaabbbbccccddddeee':
        specifier: github:jinmayamashita/xr-pkg#main
        version: git+https://git@github.com:jinmayamashita/xr-pkg.git#2a4bbe0ffc3fdd66b2796f7486966e07afbdd4ab

      # No errors - Username, reponame, and package name total more than 60 characters.
      '@my/pkg-cxxxyyyyzzzzaaaabbbbccccddddeeee':
        specifier: github:jinmayamashita/gr-pkg#main
        version: git+https://git@github.com:jinmayamashita/gr-pkg.git#6e9161361838ccd697d8fc90dab2910701998a27

      # Error occurs - Username, reponame, and package name total 60 characters or fewer.
      '@my/pkg-cxxxyyyyzzzzaaaabbbbccccddddeeex':
        specifier: github:jinmayamashita/re-pk#main
        version: git+https://git@github.com:jinmayamashita/re-pk.git#a270742d3da44e0449d69a8c0fef98e121e273df
```

**Expected Behavior**

The development server should start successfully without any errors.

### Provide environment information

```bash
Node.js v20.15.1

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.15.1
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.6.0
Relevant Packages:
  next: 14.2.5 // Latest available version is detected (14.2.5).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Webpack

### Which stage(s) are affected? (Select all that apply)

next dev (local)

### Additional context

I've linked the code for the git private package I tested.
You can also change the git package repogitory to private and test it.