angular / angular-cli

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

ng build --optimization=true not working #27094

Closed santoshmallah closed 7 months ago

santoshmallah commented 7 months ago

Command

build

Is this a regression?

The previous version in which this bug was not present was

No response

Description

Trying to build angular version with --optimization=true flag

Error:

Uncaught ReferenceError: Nu is not defined at 743 (compiler.mjs:8685:29) at r (bootstrap:19:1) at 7932 (main.js:1:143) at r (bootstrap:19:1) at .$:292:1 at r.O (chunk loaded:23:1) at .$:292:1 at n (jsonp chunk loading:71:1) at main.js:1:69

when making changes in this flag --optimization=false, it working fine , but the problem is that the main.js file bundle size is too high, and it requires time to load the screen.

Minimal Reproduction

ng build --configuration=dev --build-optimizer=true --optimization=true --source-map --named-chunks --verbose

Exception or Error

Uncaught ReferenceError: Nu is not defined
    at 743 (compiler.mjs:8685:29)
    at r (bootstrap:19:1)
    at 7932 (main.js:1:143)
    at r (bootstrap:19:1)
    at .*$:292:1
    at r.O (chunk loaded:23:1)
    at .*$:292:1
    at n (jsonp chunk loading:71:1)
    at main.js:1:69

After updating angular cli to 16.2.8
getting this error

compiler.mjs:8685 Uncaught ReferenceError: Ju is not defined
    at 743 (compiler.mjs:8685:29)
    at r (bootstrap:19:1)
    at 7932 (main.js:1:143)
    at r (bootstrap:19:1)
    at .*$:292:1
    at r.O (chunk loaded:23:1)
    at .*$:292:1
    at n (jsonp chunk loading:71:1)
    at main.js:1:69

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 16.0.3
Node: 16.20.2
Package Manager: npm 6.14.17
OS: linux x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1600.3 (cli-only)
@angular-devkit/core         16.0.3 (cli-only)
@angular-devkit/schematics   16.0.3 (cli-only)
@schematics/angular          16.0.3 (cli-only)

Anything else relevant?

Here is my angular.json file

{
  "name": "portfolio-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --ssl",
    "build": "ng build",
    "test": "ng test",
    "lint": "tsc --noEmit && eslint . --ext js,ts,json --quiet --fix",
    "e2e": "ng e2e",
    "ng serve": "ng serve --ssl",
    "sonar": "sonar-scanner"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "16.0.3",
    "@angular/cdk": "16.0.1",
    "@angular/common": "16.0.3",
    "@angular/compiler": "16.0.3",
    "@angular/core": "16.0.3",
    "@angular/forms": "16.0.3",
    "@angular/localize": "16.0.3",
    "@angular/platform-browser": "16.0.3",
    "@angular/platform-browser-dynamic": "16.0.3",
    "@angular/router": "16.0.3",
    "@auth0/angular-jwt": "5.0.2",
    "@fortawesome/angular-fontawesome": "0.13.0",
    "@fortawesome/fontawesome-free": "6.5.1",
    "@fortawesome/fontawesome-svg-core": "6.4.0",
    "@ng-idle/core": "11.1.0",
    "@ng-idle/keepalive": "11.0.3",
    "@ngx-translate/core": "15.0.0",
    "@ngx-translate/http-loader": "6.0.0",
    "angular2-moment": "1.9.0",
    "bignumber.js": "9.0.1",
    "bn-ng-idle": "1.0.1",
    "chart.js": "4.3.0",
    "echarts": "5.2.2",
    "echarts.js": "3.0.0-beta3",
    "file-saver": "2.0.5",
    "font-awesome": "4.7.0",
    "json-bigint": "1.0.0",
    "json-bignumber": "1.0.2",
    "jwt-check-expiration": "1.0.5",
    "keycloak-angular": "14.0.0",
    "keycloak-js": "21.1.1",
    "lodash": "4.17.21",
    "moment": "2.29.1",
    "ng-block-ui": "3.0.2",
    "ngx-echarts": "8.0.1",
    "primeflex": "2.0.0",
    "primeicons": "6.0.0",
    "primeng": "16.9.1",
    "rxjs": "7.8.1",
    "rxjs-compat": "6.6.7",
    "tslib": "2.0.0",
    "uuid": "3.4.0",
    "xlsx": "0.17.0",
    "zone.js": "0.13.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "16.0.2",
    "@angular/cli": "16.0.2",
    "@angular/compiler-cli": "16.0.3",
    "@angular/language-service": "16.0.3",
    "@types/jasmine": "3.5.0",
    "@types/jasminewd2": "2.0.3",
    "@types/lodash": "4.14.168",
    "@types/node": "12.20.11",
    "@typescript-eslint/eslint-plugin": "4.7.0",
    "codelyzer": "5.1.2",
    "eslint": "7.13.0",
    "eslint-config-prettier": "6.15.0",
    "eslint-plugin-prettier": "3.1.4",
    "jasmine-core": "3.5.0",
    "jasmine-spec-reporter": "5.0.0",
    "karma": "6.3.4",
    "karma-chrome-launcher": "3.1.0",
    "karma-coverage-istanbul-reporter": "3.0.2",
    "karma-jasmine": "4.0.0",
    "karma-jasmine-html-reporter": "1.5.0",
    "prettier": "2.1.2",
    "prettier-eslint": "11.0.0",
    "protractor": "7.0.0",
    "sonar-scanner": "3.1.0",
    "ts-node": "8.3.0",
    "tslint": "6.1.3",
    "typescript": "4.9.5"
  }
}

tcconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "ES2022",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2022",
      "dom"
    ],
    "useDefineForClassFields": false
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}
alan-agius4 commented 7 months ago

This looks like a duplicate of https://github.com/angular/angular-cli/issues/25543. If the problem persists please open a new issue with a minimal reproduction. A good way to make a minimal repro is to create a new app via ng new repro-app and add the minimum possible code to show the problem. Then you can push this repository to github and link it here.

angular-automatic-lock-bot[bot] commented 6 months 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.