angular / angular/angular-cli

Error when evaluating SSR module ./server.mjs: Cannot split a chunk that has already been edited (0:76 – "import.meta")

Abierto
#31,978 5 comentarios 0 reacciones 0 asignados Ver en GitHub
angular/build:dev-server area: @angular/build needs: investigation
Lenguaje dominante
TypeScript
Estrellas
27k
Forks
11.8k
Merge medio
14 h 23 min
PR fusionados (30 d)
162

Descripción

### Command

serve

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

I just created an Angular application and

- Added Hono and configured it for SSR
- Added Drizzle ORM
- Added Better Auth

I configured every library following their documentation, but when I run `npx ng serve` I get this error :

```
6:31:46 PM [vite] (ssr) Error when evaluating SSR module ./server.mjs: Cannot split a chunk that has already been edited (0:76 – "import.meta")
at MagicString._splitChunk (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:3823:10)
at MagicString._split (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:3814:43)
at MagicString.update (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:3638:8)
at onIdentifier (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:16139:77)
at file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:16251:37
at Array.forEach ()
at walk$1 (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:16250:14)
at ssrTransformScript (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:16116:2)
at async loadAndTransform (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:23318:64)
at async fetchModule (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:34612:15)
```

Commenting line 20 of `src/server.ts`, then re-running the serve command makes it work.

### Minimal Reproduction

[testing-app.zip](https://github.com/user-attachments/files/23841005/testing-app.zip)

### Exception or Error

```text
6:31:46 PM [vite] (ssr) Error when evaluating SSR module ./server.mjs: Cannot split a chunk that has already been edited (0:76 – "import.meta")
at MagicString._splitChunk (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:3823:10)
at MagicString._split (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:3814:43)
at MagicString.update (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:3638:8)
at onIdentifier (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:16139:77)
at file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:16251:37
at Array.forEach ()
at walk$1 (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:16250:14)
at ssrTransformScript (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:16116:2)
at async loadAndTransform (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:23318:64)
at async fetchModule (file:///home/max/projects/migal/mi-points/node_modules/vite/dist/node/chunks/config.js:34612:15)
```

### Your Environment

```text
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/

Angular CLI : 21.0.1
Angular : 21.0.1
Node.js : 22.18.0
Package Manager : npm 11.6.1
Operating System : linux x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 21.0.1 │ ^21.0.1 │
│ @angular/cli │ 21.0.1 │ ^21.0.1 │
│ @angular/common │ 21.0.1 │ ^21.0.0 │
│ @angular/compiler │ 21.0.1 │ ^21.0.0 │
│ @angular/compiler-cli │ 21.0.1 │ ^21.0.0 │
│ @angular/core │ 21.0.1 │ ^21.0.0 │
│ @angular/forms │ 21.0.1 │ ^21.0.0 │
│ @angular/platform-browser │ 21.0.1 │ ^21.0.0 │
│ @angular/platform-server │ 21.0.1 │ ^21.0.0 │
│ @angular/router │ 21.0.1 │ ^21.0.0 │
│ @angular/ssr │ 21.0.1 │ ^21.0.1 │
│ rxjs │ 7.8.2 │ ~7.8.0 │
│ typescript │ 5.9.3 │ ~5.9.2 │
│ vitest │ 4.0.14 │ ^4.0.8 │
└───────────────────────────┴───────────────────┴───────────────────┘
```

### Anything else relevant?

_No response_

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Descomprime testing-app.zip e inspecciona src/server.ts, especialmente la línea 20; después reproduce el fallo con npx ng serve. Sigue la transformación SSR mostrada en el stack de Vite y compara el comportamiento con esa línea habilitada o comentada; se considera terminado cuando la reproducción mínima se sirve correctamente con el código del servidor previsto intacto.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript, vite
Área
build-system, devtools
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.