Skip to content

Vite dev server fails to serve source maps #26199

Closed
@yharaskrik

Description

@yharaskrik

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

17.0.0-rc.3

Description

When generating a fresh application with npm init @angular@next --ssr the application fails to load the sourcemaps when you open the dev tools.

Watch mode enabled. Watching for file changes...
  ➜  Local:   http://localhost:4200/
ERROR RuntimeError: NG04002: Cannot match any routes. URL Segment: '@vite/client.mjs.map'
    at Recognizer.noMatchError (/Users/jaybell/packages/router/src/recognize.ts:61:12)
    at <anonymous> (/Users/jaybell/packages/router/src/recognize.ts:101:20)
    at /Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:51
    at OperatorSubscriber._this._error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
    at Subscriber.error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at Subscriber.error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at Subscriber.error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30) {
  code: 4002
}
ERROR RuntimeError: NG04002: Cannot match any routes. URL Segment: 'styles.css.map'
    at Recognizer.noMatchError (/Users/jaybell/packages/router/src/recognize.ts:61:12)
    at <anonymous> (/Users/jaybell/packages/router/src/recognize.ts:101:20)
    at /Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:51
    at OperatorSubscriber._this._error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
    at Subscriber.error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at Subscriber.error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at Subscriber.error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/angular-17-ssr-application-builder/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30) {
  code: 4002
}

In our private monorepo when I port the configurations for the application builder I get a slightly different but same case, I run into the same sourcemap error but instead if just crashes the server

Cannot optimize dependency: path, present in 'optimizeDeps.include'
  ➜  Local:   http://localhost:60926/
file:///Users/jaybell/WebstormProjects/shinkansen/node_modules/@angular/router/fesm2022/router.mjs:3695
        return new ɵRuntimeError(4002 /* RuntimeErrorCode.NO_MATCH */, (typeof ngDevMode === 'undefined' || ngDevMode) &&
               ^

RuntimeError: NG04002: Cannot match any routes. URL Segment: '@vite/client.mjs.map'
    at Recognizer.noMatchError (file:///Users/jaybell/WebstormProjects/shinkansen/node_modules/@angular/router/fesm2022/router.mjs:3695:16)
    at file:///Users/jaybell/WebstormProjects/shinkansen/node_modules/@angular/router/fesm2022/router.mjs:3724:28
    at /Users/jaybell/WebstormProjects/shinkansen/node_modules/rxjs/dist/cjs/internal/operators/catchError.js:13:51
    at OperatorSubscriber._this._error (/Users/jaybell/WebstormProjects/shinkansen/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:43:21)
    at Subscriber.error (/Users/jaybell/WebstormProjects/shinkansen/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/shinkansen/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at Subscriber.error (/Users/jaybell/WebstormProjects/shinkansen/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/shinkansen/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30)
    at Subscriber.error (/Users/jaybell/WebstormProjects/shinkansen/node_modules/rxjs/dist/cjs/internal/Subscriber.js:60:18)
    at Subscriber._error (/Users/jaybell/WebstormProjects/shinkansen/node_modules/rxjs/dist/cjs/internal/Subscriber.js:84:30) {
  code: 4002
}

Node.js v18.18.2

Minimal Reproduction

npm init @angular@next --ssr
ng serve
Open the app
Open the devtools

Exception or Error

No response

Your Environment

Angular CLI: 17.0.0-rc.3
Node: 18.18.2
Package Manager: npm 9.8.1
OS: darwin arm64

Angular: 17.0.0-rc.1
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0-rc.3
@angular-devkit/build-angular   17.0.0-rc.3
@angular-devkit/core            17.0.0-rc.3
@angular-devkit/schematics      17.0.0-rc.3
@angular/cli                    17.0.0-rc.3
@angular/ssr                    17.0.0-rc.3
@schematics/angular             17.0.0-rc.3
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.1

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions