Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--prod does not work in Firefox ESR 45.9.0 #9340

Closed
jmajnek opened this issue Jan 23, 2018 · 53 comments · Fixed by #11996
Closed

--prod does not work in Firefox ESR 45.9.0 #9340

jmajnek opened this issue Jan 23, 2018 · 53 comments · Fixed by #11996

Comments

@jmajnek
Copy link

jmajnek commented Jan 23, 2018

Hi,

running ´ng serve --prod´ and opening the application in Firefox ESR 45.9.0 throws an exception.

TypeError: this is undefined

Versions

ng: 1.6.5
npm: 5.6.0
Node: 8.9.4

Repro steps

  • ng new foobar
  • cd foobar
  • ng serve --prod
  • Open in Firefox ESR 45.9.0

Observed behavior

Blank page, error in console

Desired behavior

Everything works as expected

BR
Jakob

@matthiaslischka
Copy link
Contributor

I can reproduce this with Firefox 45.9.0 ESR win 32. Get it here.
BR

@hansl
Copy link
Contributor

hansl commented Jan 23, 2018

error in console

Could you be more specific?

@hansl hansl added P5 The team acknowledges the request but does not plan to address it, it remains open for discussion needs: more info Reporter must clarify the issue freq1: low Only reported by a handful of users who observe it rarely severity3: broken labels Jan 23, 2018
@matthiaslischka
Copy link
Contributor

matthiaslischka commented Jan 23, 2018

There is not much more to it. One Warning and one error that this is undefinded

[Warning] mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create 
  main.0836c96b9484632bf48c.bundle.js:1:10588
[Error] TypeError: this is undefined   main.0836c96b9484632bf48c.bundle.js:1:87832

It works just fine with any other browser or when you do not add the --prod flag.

BR

@wunaidage
Copy link

wunaidage commented Jan 24, 2018

same here, exactly the same behavior and console output

@TheParad0X
Copy link

Same problem here with Firefox 50.1.0. See #9362
Current workaround: instead of using
ng build --prod
use
ng build --aot --environment=prod --output-hashing=all --sourcemaps=false --extract-css=true --named-chunks=false --build-optimizer=true

The culprit is --target=production

@nstod
Copy link

nstod commented Jan 30, 2018

We are seeing the same issue. The workaround submitted by @TheParad0X does indeed work, but it appears to bypass uglify, which we would greatly desire. I'm hoping to see this fixed as soon as possible.

@pfeigl
Copy link

pfeigl commented Jan 31, 2018

We are facing the same problem and leaving the production flag out is no real option, because the dist size is not an option than (because of the missing uglify process).

Also all code is effectively visible to everyone way to easily (which might be a problem to closed-source projects)

@nstod
Copy link

nstod commented Jan 31, 2018

We found a temporary workaround by reverting uglifyjs-webpack-plugin from version 1.1.8 to 1.1.5. Uglify is once again working on Firefox 45 for us.

@wunaidage
Copy link

#8997 see this issue, will reverting uglifyjs cause this issue again?

@nstod
Copy link

nstod commented Jan 31, 2018

No. uglifyjs-webpack-plugin@1.1.5 references uglify-es@3.2.2, which is where fix #8997 was implemented. uglify-webpack-plugin@1.1.6 updated to uglify-es@~3.3, which is where this error is occurring.

@filipesilva filipesilva added comp: cli/build and removed comp: cli/serve freq1: low Only reported by a handful of users who observe it rarely needs: more info Reporter must clarify the issue P5 The team acknowledges the request but does not plan to address it, it remains open for discussion severity3: broken labels Feb 1, 2018
@stas-kh
Copy link

stas-kh commented Feb 1, 2018

Oh, guys. I was looking exactly for this issue. Our users post bugs from Firefox 35.1 with the same issue in their dev console.

It would be really nice if you could fix the issue.

Thanks @nstod for the temporary workaround, the following helped me to figure out the problem:

npm i uglifyjs-webpack-plugin@1.1.5 --save-exact
rm -rf package-lock.json node_modules
npm install

@ericparton
Copy link

Could this issue have more than one cause? Pinning the webpack plugin version doesn't fix it for me.

@vdespa
Copy link

vdespa commented Feb 16, 2018

@ericparton Same here.

@stas-kh
Copy link

stas-kh commented Feb 16, 2018

@ericparton @vdespa Make sure that in package.lock you have exactly the same version as you pinned.

Our app is running on production without any issues after the fix.

@ericparton
Copy link

ericparton commented Feb 16, 2018

@stas-kh Yeah, I just double checked the package lock and even went as far as to make sure that the only version of the uglifyjs-webpack-plugin in node_modules was 1.1.5. Still no dice. And for what it's worth, I'm also seeing this issue on Firefox 46.

@amarnathm
Copy link

amarnathm commented Jun 19, 2018

Solution provided by TheParad0X was working for me until today. Today, with Firefox 50.0.1, it works for some cases, doesn't for others.

The error "TypeError: this is undefined" is generated inside a firebase/angular file. Not happening with Chrome. And in dev env, it works fine for Firefox as well.

EDIT: going to the top-level url first, and then navigating to the various urls work. But going directly to a path url is failing. Does this work for you all?

@raphaelcps
Copy link

raphaelcps commented Jun 22, 2018

I could make it work for me after using @spanja 's solution and adding two new directories to the postinstall step:

"dependencies": { ..., "rimraf": "2.6.2", "uglify-es": "3.2.2", "uglifyjs-webpack-plugin": "1.1.5" }

"postinstall": "rimraf node_modules/@angular-devkit/build-angular/node_modules/uglify-es && rimraf node_modules/@angular/cli/node_modules/uglify-es && rimraf node_modules/@angular-devkit/build-angular/node_modules/uglifyjs-webpack-plugin && rimraf node_modules/@angular/cli/node_modules/uglifyjs-webpack-plugin"

@LiamDotPro
Copy link

This is still not working, this needs more priority.

@josephliccini
Copy link

If it's an Uglify-ES bug, I think we just need to get a minimum code sample that reproduces the issue and file a bug in their repo.

I think the this is in PlatformRef according to this comment: #8326 (comment)

@josephliccini
Copy link

Might be related:
http://statichtml.com/2011/spidermonkey-function-hoisting.html

I confirmed in my testing that it is indeed PlatformRef (you can tell because this minified function has prototype property bootstrapModuleFactory

Here's the constructor that succeeds:
image

Here's the constructor that fails:
image

I'll continue investigating what is causing this, but my guess is function hoisting issues in old versions of FF that UglifyES did not account for.

@suau
Copy link

suau commented Jul 14, 2018

This isn't working for @angular/cli@6.1.0-rc.2 either, here's a workaround:
install dev-dependencies:

npm i -D --save-exact uglify-es@3.2.2 uglifyjs-webpack-plugin@1.1.5

Now open package-lock.json

    • search for uglify-es until you found the entry with "version": "3.2.2"
    • copy the content like this:
           "version": "3.2.2",
           "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.2.2.tgz",
           "integrity": "sha512-l+s5VLzFwGJfS+fbqaGf/Dfwo1MF13jLOF2ekL0PytzqEqQ6cVppvHf4jquqFok+35USMpKjqkYxy6pQyUcuug==",
           "dev": true,
           "requires": {
             "commander": "~2.12.1",
             "source-map": "~0.6.1"
           }
    
    • now search for @angular-devkit/build-angular and scroll down to the dependencies and replace the content for uglify-es with your clipboard.
    • search for uglifyjs-webpack-plugin until you found the entry with "version": "1.1.5"
    • copy the content like this:
           "version": "1.1.5",
           "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.5.tgz",
           "integrity": "sha512-YBGc9G7dv12Vjx8vUQs54DZgAXVf04LlG6dNNiEbTZjL3PbUqiY4uPB9Kv+fUJaqRskEGva/lS7sh08yJr7jnA==",
           "dev": true,
           "requires": {
             "cacache": "^10.0.0",
             "find-cache-dir": "^1.0.0",
             "schema-utils": "^0.3.0",
             "serialize-javascript": "^1.4.0",
             "source-map": "^0.6.1",
             "uglify-es": "3.2.2",
             "webpack-sources": "^1.0.1",
             "worker-farm": "^1.4.1"
           }
    
    • now search for @angular-devkit/build-angular and scroll down to the dependencies and replace the content for uglifyjs-webpack-plugin with your clipboard.
  1. Open your node_modules folder and find and delete the folder @angular-devkit/build-angular
  2. Run npm install
  3. Open your node_modules/@angular-devkit/build-angular/node_modules/uglify-es check the package.json file and confirm it's version uglify-es@3.2.2
  4. Open your node_modules/@angular-devkit/build-angular/node_modules/uglifyjs-webpack-plugin check the package.json file and confirm it's version uglifyjs-webpack-plugin@1.1.5

It would be great if someone working on @angular-devkit/build-angular could just pin the uglifyjs-webpack-plugin version number to 1.1.5

@WizardPC
Copy link

A definitive solution has been identified ? We are planning to migrate from Angular 4 to Angular 6 and it's not possible for our client to lost one of the main browser...

@LiamDotPro
Copy link

@WizardPC This problem is present in more than just 6, there's a couple of versions in 5 and 4 that I tried moving too which also experience the same issue.

@filipesilva
Copy link
Contributor

Hi all,

@suau has provided a good summary of this issue in #11552, but unfortunately we cannot follow through it with. Reverting to an older version of uglify-es might address this problem, but will cause other bugs that have meanwhile been fixed in uglify-es to manifest themselves again.

Updating to a newer version of uglify-es is also not an option, because it is not being maintained anymore.

The affected versions of Firefox ESR seem to be <50, but according to https://www.mozilla.org/en-US/firefox/organizations/ the current ESR is 52, which is not affected according to #9340 (comment).

Given that the latest Firefox ESR should work, together with the stated Angular browser support for Firefox listing latest only, and not having a good way to address the problem on uglify-es itself, we have decided to not take action on this issue.

I'm sorry that there isn't anything we can do right now to address the problem you all are experiencing, but in the future we will be looking at alternatives to uglify-es to prevent situations like this. Meanwhile, I suggest updating to the latest Firefox ESR.

filipesilva added a commit to filipesilva/angular-cli that referenced this issue Aug 24, 2018
Should help bring down prod build times, @SanderElias reported a ~60% reduction on his project.

Should fix angular#9340.
vikerman pushed a commit that referenced this issue Aug 27, 2018
…11996)

Should help bring down prod build times, @SanderElias reported a ~60% reduction on his project.

Should fix #9340.
@kubbafox
Copy link

Hi @filipesilva, we just updated CLI to a new release but we are still having this issues with FF < 51

Error - TypeError - This is undefined.

"devDependencies": {
"@angular-devkit/build-angular": "^0.8.1",
"@angular/cli": "~6.2.1",
"@angular/compiler-cli": "^6.1.7",
"@angular/language-service": "^6.1.7",
.....
}

@filipesilva
Copy link
Contributor

For Angular CLI 7 we are replacing uglify-es with terser: #11996.

It should help address this issue.

@WizardPC
Copy link

A definitive solution has been identified ? We are planning to migrate from Angular 4 to Angular 6 and it's not possible for our client to lost one of the main browser...

Update :

Angular CLI: 6.2.3
Node: 8.10.0
OS: win32 x64
Angular: 6.1.8

Working again on Firefox 45.2.0 🍰

@raDiesle
Copy link

Are you sure? How it can be fixed in 6.2.3, which should be 7.0.0

@WizardPC
Copy link

WizardPC commented Oct 21, 2018

Hem... Sorry for false hope ! The teams who build the app (with Jenkins) failed and forgot to use the flag "prod" so the code wasn't minified and working on Firefox... "It's not a bug it's a feature" kind of 👍

@josephliccini
Copy link

Hi all,

I have upgraded to use the latest build of Terser and Terser Webpack Plugin in Angular 7, and I am still seeing this reproduce in FireFox <50.

Has anyone upgraded and has confirmed the issue is fixed in 7.x?

@DavidBowdoin
Copy link

It has been working for us for quite a while. We are currently running 7.2.1 along with Angular 7.2.0. I would suggest creating a new/blank CLI project and then compare package.json and angular.json

@GreedyA1
Copy link

have the same issue. Transfered my project from angular 6 to 7. Still getting the same problem.

@DavidBowdoin
Copy link

@GreedyA1 Make sure you have upgraded the AngularCLI as it is the key (rather than Angular) Make sure you have the current CLI version installed globally, then create a new blank CLI project and use a tool like WinMerge to verify that your package.json and other files are up to speed.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.