angular / angular-cli

CLI tool for Angular
https://cli.angular.dev
MIT License
26.78k stars 11.98k forks source link

Angular CLI 19.0.0-next.9 only works in SSR mode #28556

Closed e-oz closed 1 month ago

e-oz commented 1 month ago

Which @angular/* package(s) are the source of the bug?

compiler-cli

Is this a regression?

Yes

Description

I apologize for the bug report without a reproduction link. It is posted in the hope that you might get some clues about what could be wrong just by reading the error and config.

With this config:

"build": {
  "executor": "@angular-devkit/build-angular:application",
    "outputs": [
    "{options.outputPath}"
  ],
    "options": {
    "outputPath": "dist/apps/app-name",
      "index": "apps/app-name/src/index.html",
      "browser": "apps/app-name/src/main.ts",
      "polyfills": [
      "@angular/localize/init"
    ],
      "statsJson": true,
      "tsConfig": "apps/app-name/tsconfig.app.json",
      "inlineStyleLanguage": "scss",
      "localize": true,
      "assets": [
      {
        "glob": "**/*",
        "input": "apps/app-name/public"
      }
    ],
      "styles": [
      "apps/app-name/src/styles.scss"
    ],
      "scripts": [],
      "prerender": {
      "discoverRoutes": false,
        "routesFile": "apps/app-name/routes.txt"
    },
    "server": "apps/app-name/src/main.server.ts",
      "ssr": false
  },
  "configurations": {
    "production": {
      "budgets": [
        {
          "type": "initial",
          "maximumWarning": "500kb",
          "maximumError": "1mb"
        },
        {
          "type": "anyComponentStyle",
          "maximumWarning": "10kb",
          "maximumError": "20kb"
        }
      ],
        "outputHashing": "all",
        "fileReplacements": [
        {
          "replace": "apps/app-name/src/environments/environment.ts",
          "with": "apps/app-name/src/environments/environment.prod.ts"
        }
      ],
        "serviceWorker": "apps/app-name/ngsw-config.json"
    },
    "development": {
      "optimization": false,
        "extractLicenses": false,
        "sourceMap": true,
        "ssr": false,
        "prerender": false
    },
    "dev-ssr": {
      "optimization": false,
        "extractLicenses": false,
        "sourceMap": true
    }
  },
  "defaultConfiguration": "production"
},
"serve": {
  "executor": "@angular-devkit/build-angular:dev-server",
    "configurations": {
    "production": {
      "buildTarget": "app-name:build:production"
    },
    "development": {
      "buildTarget": "app-name:build:development"
    },
    "dev-ssr": {
      "buildTarget": "app-name:build:dev-ssr"
    }
  },
  "defaultConfiguration": "development"
},
"serve-ssr": {
  "executor": "@angular-devkit/build-angular:dev-server",
    "configurations": {
    "development": {
      "buildTarget": "app-name:build:dev-ssr"
    }
  },
  "defaultConfiguration": "development"
}

ng serve throws an error, and ng serve --configuration=dev-ssr works fine

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

NOTE: Raw file sizes do not reflect development server per-request transformations. ➜ Local: http://localhost:4200/ ➜ press h + enter to show help 5:48:55 PM [vite] Internal server error: Failed to load url /main.server.mjs (resolved id: /main.server.mjs). Does the file exist? at loadAndTransform (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51858:17) at async instantiateModule (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52817:44) 5:48:55 PM [vite] Internal server error: Failed to load url /main.server.mjs (resolved id: /main.server.mjs). Does the file exist? at loadAndTransform (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51858:17) at async instantiateModule (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52817:44) (x2) 5:49:00 PM [vite] Internal server error: Failed to load url /main.server.mjs (resolved id: /main.server.mjs). Does the file exist? at loadAndTransform (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51858:17) at async instantiateModule (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52817:44) (x3) 5:49:01 PM [vite] Internal server error: Failed to load url /main.server.mjs (resolved id: /main.server.mjs). Does the file exist? at loadAndTransform (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:51858:17) at async instantiateModule (file:///Users/oz/repos/project-name/repo-name/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js:52817:44) (x4)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.0.0-next.9 Node: 22.9.0 Package Manager: npm 10.8.3 OS: darwin arm64

Angular: 19.0.0-next.8 ... animations, common, compiler, compiler-cli, core, forms ... language-service, localize, platform-browser ... platform-browser-dynamic, platform-server, router ... service-worker

Package Version

@angular-devkit/architect 0.1900.0-next.9 @angular-devkit/build-angular 19.0.0-next.9 @angular-devkit/core 19.0.0-next.9 @angular-devkit/schematics 19.0.0-next.9 @angular/cdk 19.0.0-next.6 @angular/cli 19.0.0-next.9 @angular/material 19.0.0-next.6 @angular/pwa 19.0.0-next.9 @angular/ssr 19.0.0-next.9 @schematics/angular 19.0.0-next.9 rxjs 7.8.1 typescript 5.6.2 zone.js 0.15.0

Anything else?

No response

AndrewKushnir commented 1 month ago

Transferring this ticket to the CLI repo for further investigation, this might be related to some recent changes there. cc @alan-agius4

JeanMeche commented 1 month ago

This is an nx config but the relevant part is

  "server": "src/main.server.ts",
  "prerender": false,
  "ssr": false

This worked before but now it throws.

angular-automatic-lock-bot[bot] commented 1 week ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.