【问题标题】:Angular 9: Error while "Generating ES5 bundles for differential loading...": Identifier directly after numberAngular 9:“为差异加载生成 ES5 包...”时出错:标识符直接在数字之后
【发布时间】:2020-10-23 01:23:11
【问题描述】:

我刚刚将我的 Angular 项目从版本 8 更新到了 9。由于我必须支持 IE 11 浏览器,因此目标是“es5”。

更新后,“为差异加载生成 ES5 包...”时出现以下错误

[1m[31m发生未处理的异常:C:\myproject\polyfills-es5.9b276c87455e9832d96d.js: Identifier directly after number (1:354893)[39m[22m [1m[31m[39m[22m

package.json

{
"name": "myproject",
"version": "0.0.0",
"private": true,
"dependencies": {
    "@angular/animations": "^9.1.11",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "^9.1.11",
    "@angular/compiler": "^9.1.11",
    "@angular/core": "^9.1.11",
    "@angular/forms": "^9.1.11",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "^9.1.11",
    "@angular/platform-browser-dynamic": "^9.1.11",
    "@angular/router": "^9.1.11",
    "@datorama/akita": "^5.1.1",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "angular-svg-round-progressbar": "^3.0.1",
    "cronstrue": "^1.94.0",
    "croppie": "^2.6.5",
    "css-element-queries": "^1.2.3",
    "highcharts": "^8.1.2",
    "highcharts-angular": "^2.4.0",
    "jquery": "^3.5.1",
    "jquery-ui-dist": "^1.12.1",
    "jquery-ui-touch-punch": "^0.2.3",
    "lodash": "^4.17.15",
    "ngx-infinite-scroll": "^9.0.0",
    "rxjs": "^6.6.0",
    "srcdoc-polyfill": "^1.0.0",
    "stacktrace-js": "^2.0.2",
    "tslib": "^2.0.0",
    "web-animations-js": "^2.3.2",
    "xlsx": "^0.16.3",
    "zone.js": "~0.10.3"
},
"devDependencies": {
    "@angular-builders/custom-webpack": "^9.2.0",
    "@angular-devkit/build-angular": "^0.901.10",
    "@angular/cli": "^9.1.10",
    "@angular/compiler-cli": "^9.1.11",
    "@angular/language-service": "^9.1.11",
    "@asciidoctor/core": "^2.2.0",
    "@asciidoctor/reveal.js": "^4.0.1",
    "@cartant/tslint-config-rxjs": "^2.0.6",
    "@datorama/akita-ngdevtools": "^5.0.3",
    "@types/browser-sync": "^2.26.1",
    "@types/ckeditor": "^0.0.46",
    "@types/jquery": "^3.5.0",
    "@types/jqueryui": "^1.12.13",
    "@types/license-checker": "^25.0.0",
    "@types/lodash": "^4.14.157",
    "@types/node": "^14.0.14",
    "@types/request": "^2.48.5",
    "ajv": "^6.12.2",
    "browser-sync": "^2.26.7",
    "codelyzer": "^5.1.2",
    "dependency-cruiser": "^9.8.0",
    "license-checker": "^25.0.1",
    "prettier": "^2.0.5",
    "rxjs-tslint-rules": "^4.33.3",
    "saml-idp": "^1.2.1",
    "stylelint": "^13.6.1",
    "stylelint-checkstyle-formatter": "^0.1.2",
    "stylelint-config-prettier": "^8.0.2",
    "stylelint-config-recommended": "^3.0.0",
    "stylelint-config-recommended-scss": "^4.2.0",
    "stylelint-config-standard": "^20.0.0",
    "stylelint-scss": "^3.18.0",
    "ts-node": "^8.10.2",
    "tsc-silent": "^1.2.1",
    "tslint": "^5.20.1",
    "tslint-microsoft-contrib": "^6.2.0",
    "tslint-sonarts": "^1.9.0",
    "typescript": "~3.8.3",
    "vega": "^5.13.0",
    "vega-embed": "^6.9.0",
    "vega-lite": "^4.13.1"
}

tsconfig.json

{
"compileOnSave": false,
"compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "alwaysStrict": true,
    "baseUrl": "src",
    "declaration": false,
    "downlevelIteration": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    "lib": [
        "dom",
        "es2020"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "strict": true,
    "strictFunctionTypes": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": true,
    "target": "es5",
    "typeRoots": [
        "node_modules/@types"
    ]
},
"angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
}

“npm outdated”给了

npm outdated gives

任何提示可能是什么解决方案?

【问题讨论】:

    标签: angular angular-cdk


    【解决方案1】:

    一些附加信息:

    polyfills-es5.<some hash value>.js 在末尾包含自己的文件名作为 JavaScript 表达式。这是文件的结尾(注意第 1 行的结尾,而不是第 2 行的注释)

    {preventExtensions:function(t){return c&&o(t)?c(i(t)):t}})}},[[4,0]]]),polyfills,es5.e52fb6e508fabacaf778.js;
    //# sourceMappingURL=polyfills-es5.e52fb6e508fabacaf778.js.map
    

    当且仅当哈希值以数字开头时才会发生编译错误。

    在 angular.json 中设置sourceMap: false 似乎可以防止错误,在这种情况下不会生成包含文件名的表达式。

    【讨论】:

      【解决方案2】:

      我的项目中存在同样的问题,我解决了将 outputHashing 设置为 none (angular.json) 的问题。 有人有关于这个错误的消息吗?我在 github angular 项目上找不到任何问题,也没有在网络上找到任何其他文章。

      【讨论】:

        猜你喜欢
        • 2020-06-21
        • 1970-01-01
        • 1970-01-01
        • 2017-01-07
        • 2018-05-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-20
        相关资源
        最近更新 更多