angular / angular-cli

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

[Build Optimizer] Initial load fails with enabled --build-optimizer #13686

Closed riede closed 5 years ago

riede commented 5 years ago

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

No

Description

Building my SPA with ng build --prod works well. But when I want to load it initially, it crashed. Serving with --source-map delivers the following error: image

When I do not use the production flag everything works well. ng build --aot --optimization works, too - I can load the page and everything is ok. I think there might be a bug in the Build Optimizer.

πŸ”₯ Exception or Error


`TypeError: Cannot read property '__source' of undefined`

🌍 Your Environment


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 7.3.1
Node: 8.11.3
OS: darwin x64
Angular: 7.2.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.1
@angular-devkit/build-angular     0.13.1
@angular-devkit/build-optimizer   0.13.1
@angular-devkit/build-webpack     0.13.1
@angular-devkit/core              7.3.1
@angular-devkit/schematics        7.3.1
@angular/cli                      7.3.1
@ngtools/webpack                  7.3.1
@schematics/angular               7.3.1
@schematics/update                0.13.1
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.29.0

Anything else relevant? Here is my package.json:


 "dependencies": {
    "@angular/animations": "^7.2.4",
    "@angular/common": "^7.2.4",
    "@angular/compiler": "^7.2.4",
    "@angular/core": "^7.2.4",
    "@angular/forms": "^7.2.4",
    "@angular/http": "^7.2.4",
    "@angular/platform-browser": "^7.2.4",
    "@angular/platform-browser-dynamic": "^7.2.4",
    "@angular/router": "^7.2.4",
    "@ngx-loading-bar/core": "^4.1.1",
    "@ngx-loading-bar/http-client": "^4.1.1",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@swimlane/ngx-charts": "^10.0.0",
    "@types/d3": "^4.10.2",
    "@types/lodash": "^4.14.121",
    "@types/uuid": "^3.4.4",
    "angular-2-local-storage": "^3.0.0",
    "angular-gridster2": "^7.1.0",
    "angular2-ladda": "^2.0.0",
    "bootstrap": "^4.2.1",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.6.5",
    "d3": "^4.10.2",
    "font-awesome": "^4.7.0",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "ngx-bootstrap": "^3.2.0",
    "ngx-color-picker": "^7.3.1",
    "ngx-infinite-scroll": "^7.0.1",
    "ngx-slimscroll": "^7.1.0",
    "ngx-toastr": "^9.1.2",
    "pretty-checkbox": "^3.0.3",
    "rxjs": "^6.4.0",
    "spinkit": "^1.2.5",
    "tslib": "^1.9.3",
    "uuid": "^3.3.2",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.1",
    "@angular/cli": "~7.3.1",
    "@angular/compiler-cli": "^7.2.4",
    "@angular/language-service": "^7.2.4",
    "@compodoc/compodoc": "^1.1.8",
    "@types/jasmine": "~3.3.9",
    "@types/jasminewd2": "~2.0.6",
    "@types/node": "~8.9.5",
    "codelyzer": "~4.5.0",
    "husky": "^0.14.3",
    "jasmine-core": "~3.3.0",
    "jasmine-marbles": "^0.4.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.4",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "karma-parallel": "^0.3.1",
    "lint-staged": "^7.2.0",
    "prettier": "^1.16.4",
    "protractor": "~5.4.2",
    "ts-node": "~7.0.1",
    "tslint": "~5.12.1",
    "typescript": "3.2.4"
  }
mgechev commented 5 years ago

Would you provide a minimal repo where we can reproduce the problem?

riede commented 5 years ago

I will try to provide a minimal Repo. But I think it could take a cupple of days.

quangquy87 commented 5 years ago

Error in angular-2-local-storage, remove or use other library to fix problem

riede commented 5 years ago

@quangquy87 Are you sure? We already use angular-2-local-storage since Angular 5. Everything works fine with Angular 7.2.2. Updating to Angular 7.2.3 lets the application crash at runtime using --prod

quangquy87 commented 5 years ago

@quangquy87 Are you sure? We already use angular-2-local-storage since Angular 5. Everything works fine with Angular 7.2.2. Updating to Angular 7.2.3 lets the application crash at runtime using --prod

I am sure, I have encountered the same error and took several days to find the problem

riede commented 5 years ago

I am sure, I have encountered the same error and took several days to find the problem

Thanks. You're right, by using angular-2-local-storage in a minimal repro-app I could reproduce the error. Nevertheless the error has only existed since Angular 7.2.3

riede commented 5 years ago

Here is the minimal Repo that reproduces the error.

Issue #63 of the angular-2-local-storage project discusses the same error. I'm not sure if the error lays on the angular side or on the angular-2-local-storage side.

riede commented 5 years ago

@quangquy87 Iβ€˜ve created a Pull Request to fix the Problem. A new version is already available for angular-2-local-storage.

So, the Issue can be closed.

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