question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in build-optimizer or uglify-es (AOT output bug)

See original GitHub issue

As per @trotyl on https://github.com/angular/angular/issues/25800 I post this here:

Bug Report or Feature Request (mark with an x)

- [ X] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

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

Versions

Angular CLI: 6.0.8 Node: 10.4.0 OS: darwin x64 Angular: 6.1.6

Repro steps

Current behavior

The following Typescript code:

let table1 = [null, "hello"];
let table2 = [null, "world"];

let i = -1;
for (const row of table1) {
  i++;
  if (!row) {
    continue;
  }
  console.log(row, table2[i])
}

when compiled with AOT in an Angular project (ng build --prod --build-optimizer --vendor-chunk=true --aot), produces the following “compiled” code:

for (var l = [null, "world"], n = -1, u = 0, a = [null, "hello"]; u < a.length; u++) {
   var o = a[u];
   o && console.log(o, l[++n])
}

The compiled code checks for null first before it increments i, the written Typescript codes increments i before the null check.

When run in a browser the AOT code prints hello null

Expected behavior

The AOT compiled code in a browser should print hello world

Minimal reproduction of the problem with instructions

Copy above Typescript snipped into a newly created Angular project and build it with AOT.

What is the motivation / use case for changing the behavior?

We expect AOT compiled code to do exactly what the code intends to do

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelbaurcommented, Sep 5, 2018

I guess this is the same problem with pure_getters: true that is already discussed in issue 11439

1reaction
fbernhardcommented, Sep 4, 2018

Thank you for re-opening the issue.

These type of changes are very dangerous for your users; We have more than 100k lines of code since Angular 2. We don’t see these type of issues in tests as the they only appear in the AOT compilation. We have to “read” the code to find out where else this problem might occur.

On Tue, Sep 4, 2018, 19:04 Alan Agius notifications@github.com wrote:

Reopened #12082 https://github.com/angular/angular-cli/issues/12082.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/12082#event-1825839882, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDatKGi2lbfVD7UDP4LKg3-251ET9dQks5uXrKUgaJpZM4WY4kV .

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular/angular-cli - Gitter
I think I found a bug in the NamedLazyChunksPlugin in Angular CLI ... production --aot=true --build-optimizer=true --output-hashing=none --named-chunks=true.
Read more >
"Unexpected token: punc ())" when building for production
Refactoring the .js file's code to ES5 fixed the problem. I used ng build --prod --aot to check if the error was gone....
Read more >
CHANGELOG.md
`uglifyjs` was replaced with the newer `uglifyes`, which supports ES2015. ### Bug Fixes * **aot:** normalize paths to fix path issues on windows ......
Read more >
node_modules/@ionic/app-scripts/CHANGELOG.md ... - GitLab
Bug Fixes. AoT: properly check for ngmodule declaration errors from the AoT build (a47f120); template: fix bug with using dollar sign within templates ......
Read more >
Angular CLI - Tutorial - Vskills
Install a previous version, maybe because of a bug in the latest version. For example to get 7.0.2: ... The syntax is: –aot;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found