Skip to content

upgrading to angular v13 causes webpack-dev-server to ignore translation string changes #22751

Closed as not planned
@nkrmavnar

Description

@nkrmavnar

🐞 Bug report

After upgrading to Angular v13, webpack-dev-server started ignoring translation string changes and therefore does not reload the page as it does when eg. a component template is changed. This feature worked in Angular v12.2.13.

Dependencies (package.json):

{
  "name": "frontend",
  "version": "0.0.0",
  "engines": {
    "node": ">=16.0.0",
    "npm": ">=7.0.0"
  },
  "scripts": {
    "start": "ng serve"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "13.2.3",
    "@angular/common": "13.2.3",
    "@angular/compiler": "13.2.3",
    "@angular/core": "13.2.3",
    "@angular/forms": "13.2.3",
    "@angular/platform-browser": "13.2.3",
    "@angular/platform-browser-dynamic": "13.2.3",
    "@angular/router": "13.2.3",
    ...
    "@ngx-translate/core": "14.0.0"
    ...
  },
  "devDependencies": {
    "@angular-builders/jest": "12.1.2",
    "@angular-devkit/build-angular": "13.2.4",
    "@angular-eslint/eslint-plugin": "12.6.1",
    "@angular/cli": "13.2.4",
    "@angular/compiler-cli": "13.2.3",
    "@angular/language-service": "13.2.3",
    ...
  }
}

angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "apps",
  "projects": {
    "admin": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "less"
        }
      },
      "root": "",
      "sourceRoot": "apps/admin",
      "prefix": "admin",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/admin",
            "index": "apps/admin/index.html",
            "main": "apps/admin/main.ts",
            "polyfills": "apps/admin/polyfills.ts",
            "tsConfig": "apps/admin/tsconfig.app.json",
            "assets": ["apps/admin/assets"],
            "styles": ["apps/admin/styles/styles.less"],
            "stylePreprocessorOptions": {
              "includePaths": ["apps", "node_modules"]
            },
            "scripts": [],
            "allowedCommonJsDependencies": [],
            "vendorChunk": true,
            "extractLicenses": false,
            "buildOptimizer": false,
            "sourceMap": true,
            "optimization": false,
            "namedChunks": true
          },
          "configurations": {
            "production": {
              "baseHref": "/admin/",
              "deployUrl": "/admin/",
              "optimization": {
                "scripts": true,
                "styles": {
                  "minify": true,
                  "inlineCritical": false
                },
                "fonts": true
              },
              "outputHashing": "all",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb"
                }
              ]
            },
            "development": {
              "baseHref": "/admin/",
              "deployUrl": "/admin/",
              "budgets": [
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "apps/admin/environments/environment.ts",
                  "with": "apps/admin/environments/environment.dev.ts"
                }
              ]
            }
          },
          "defaultConfiguration": ""
        },
       ...
      }
    }
  }
}

Sample translations file (en-US.json):
Before the change:

{
  "sideMenu": {
    "menuItem1": "Menu Item 1",
    "menuItem2": "Menu Item 2"
  }
}

After the change:

{
  "sideMenu": {
    "menuItem1": "Menu Item 1",
    "menuItem2": "Menu Item 2 - changed"
  }
}

Log after the change:

[webpack-dev-server] App updated. Recompiling...
index.js:551 [webpack-dev-server] Nothing changed.

Issue is similar to the one described here:
https://stackoverflow.com/questions/71143761/angular-13-webpack-dev-server-dont-reload-application-after-change-transloco-n

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions