运行 Angular 11 IE11 应用

Run Angular 11 Application with IE11

我已经用 Angular 11 创建了一个网络应用程序。现在,客户将 运行 它与 IE11(用于在大电视屏幕上显示网页,该屏幕仍然存在并具有集成的 IE11 -浏览器)

为此,我已经设置了这一切

https://angular.io/guide/deployment#local-development-in-older-browsers

并取消注释 polyfills.ts 中的行(和 运行 npm 命令):

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js';  // Run `npm install --save classlist.js`.

/**
 * Web Animations `@angular/platform-browser/animations`
 * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
 * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
 */
import 'web-animations-js';  // Run `npm install --save web-animations-js`.

在 index.html 中添加了这个:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

当我 运行 现在我的应用程序重建后

ng serve --configuration es5

并在 IE11 中加载它,我得到以下错误:

SCRIPT1010: Expected identifier polyfills.js (143,43)

SCRIPT1020: Syntax error vendor.js (730,1)

SCRIPT1002: Syntax error main.js (13,1)

这是引用的行:

polyfills (143):
const $localize = function (messageParts, ...expressions) {

vendor.js (730):
class Portal {

main.js (13):
this.newValue = newValue.toString();

有谁知道我还能用 IE11 对 运行 应用程序做些什么?

更新:

这是我的 angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "webportal": {
      "i18n": {
        "sourceLocale": "ch-DE",
        "locales": {
          "en": "src/translations/webportal.en.xlf"
        }
      },
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/webportal",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets",
              {
                "glob": "**/*",
                "input": "node_modules/ngx-extended-pdf-viewer/assets/",
                "output": "/assets/"
              }
            ],
            "styles": [
              "node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/solid.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/regular.scss",
              "node_modules/@fortawesome/fontawesome-free/scss/brands.scss",
              "node_modules/ng-uikit-pro-standard/assets/scss/bootstrap/bootstrap.scss",
              "node_modules/ng-uikit-pro-standard/assets/scss/mdb.scss",
              "node_modules/animate.css/animate.css",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/chart.js/dist/Chart.js",
              "node_modules/screenfull/dist/screenfull.js",
              "node_modules/hammerjs/hammer.min.js"
            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb"
                }
              ]
            },
            "es5": {
              "tsConfig": "./tsconfig-es5.app.json"
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "webportal:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "webportal:build:production"
            },
            "es5": {
              "browserTarget": "webportal:build:es5"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "webportal:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "webportal:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "webportal:serve:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "webportal",
  "cli": {
    "analytics": false
  }
}

您必须更新 tsconfig.json 并将目标设置为 es5:

{
  "compilerOptions": {
    //...
    "target": "es5"
  }
}