tools: js minify breaks polymerfire

Description

building with "js": { "minify": true } breaks polymerfire. Cannot read the database anymore and get error messages like: FIREBASE INTERNAL ERROR: Server Error: ClientId[7309775]:ErrorId[966]: Error on incoming message .

Just replacing the files in build/min/bower_components/firebase/ by original files (firebase-app.js, firebase-database.js, firebas-auth.js … which are already minified) makes the app work again.

As an - unsuccessful - workaround, I tried to upgrade babel-preset-babili to the latest version (0.0.12), and unset all babel-preset-options ({boolean: false, buildIn, false, ...} as in https://github.com/Polymer/polymer-cli/pull/698).

Is there a way to prevent some files to be minified during the build process?

Versions & Environment

  • Polymer CLI: 0.18.1
  • node: 6.10.1
  • Operating System: Linux

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 29 (9 by maintainers)

Commits related to this issue

Most upvoted comments

There is now a PR for skipping minification of problematic js files: https://github.com/Polymer/polymer-cli/pull/878

I am getting exactly the same error as @homerjonathan when trying to log in with Google using polymerfire after building with es5-bundled presets

Uncaught TypeError: Cannot read property 'length' of undefined
    at Us.o.dispatchEvent (my-app.html:16)
    at Hs (my-app.html:16)
    at Us.Ke (my-app.html:16)
    at Us.send (my-app.html:16)
    at Yl.qg (my-app.html:16)
    at tu (my-app.html:16)
    at my-app.html:16
    at new Ir (my-app.html:16)
    at ru (my-app.html:16)
    at my-app.html:16

Even though this is a problem with the minifier, wouldn’t it be good to be able to not minify certain scripts, especially when you have 3rd party redistributable scripts with a version and a license like in the Firebase scripts?

I also found --js-minify breaks the polymerfire in the build process. Error reported when firebase-auth called: Uncaught TypeError: Cannot read property ‘signInWithEmailAndPassword’ of undefined at HTMLElement.signInWithEmailAndPassword (firebase-auth.html:1) at HTMLElement.signIn (my-app.html:1) at HTMLElement.S (polymer.html:1) at HTMLElement.fire (polymer.html:1) at HTMLElement.signIn (pd-login.html:1) at HTMLElement.S (polymer.html:1) at HTMLElement.fire (polymer.html:1) at Object.fire (polymer.html:1) at Object.forward (polymer.html:1) at Object.click (polymer.html:1) I copied in ./bower_components/polymer/polymer.html to ./build/default/bower_components/polymer and the app works OK. Something breaks in minimising polymer.html? polymer cli 0.18.1 polymer 1.9.1 polymerfire 0.10.4 (version required by polymer-cli)

This is my temporary fix… to [install_dir]/polymer-cli/lib/build/optimize-streams.js (e.g. /usr/local/lib/node_modules/polymer-cli/lib/build/optimize-streams.js)

--- optimize-streams.js.orig	2017-08-30 17:40:02.654992031 +0900
+++ optimize-streams.js	2017-08-30 17:43:42.132991921 +0900
@@ -50,6 +50,13 @@
             return;
         }
 
+        if(/firebase-auth\.js$/.test(file.path) &&
+           this.optimizerOptions.presets[0].minified == true){
+            logger.warn('skip minify `firebase-auth.js` ...');
+            callback(null, file);
+            return;
+        }
+        
         if (file.contents) {
             try {
                 let contents = file.contents.toString();

I am getting the same error using “google” as the provider of security.

Here is the authentication code I am using.

          this.$.auth.signInWithPopup()
              .then(function(response){
                console.log(response);
              })
              .catch(function(error) {
                console.log(error);
              });

I get the same error report with Uncaught TypeError: Cannot read property ‘length’ of undefined

Interestingly I get a blank sign-up box as well.

Also getting this error on v1.2.0 – just brought our production build to a halt.

firebase-auth.js:1 Uncaught TypeError: Cannot read property 'length' of undefined

@christophe-g’s fix doesn’t seem to work for us, nor does building with the following flags:

      "js": {"minify": false},
      "css": {"minify": false},
      "html": {"minify": false}

Which is odd, because I thought this problem was related to minification.

Same With v1.2.0, I get Cannot read property 'length' of undefined exceptions. Any clean solution other than @christophe-g solution ?!

Seeing this on v1.3.1 as well.

firebase-auth.js:1 Uncaught TypeError: Cannot read property ‘length’ of undefined

Hey @eob In my case it was the HTML minification. Maybe this is a mix of other problems.

I also see this problem with polymer cli v1.1.0 and after updating to polymerfire v2.1.0

firebase-auth.js:1 Uncaught TypeError: Cannot read property 'length' of undefined at Ss.o.dispatchEvent (firebase-auth.js:1) at _s (firebase-auth.js:1) at Ss.ne (firebase-auth.js:1) at Ss.send (firebase-auth.js:1) at _l.Mf (firebase-auth.js:1) at Wl (firebase-auth.js:1) at firebase-auth.js:1 at new ur (firebase-auth.js:1) at ql (firebase-auth.js:1) at firebase-auth.js:1