Polymer / polymer

Our original Web Component library.
https://polymer-library.polymer-project.org/
BSD 3-Clause "New" or "Revised" License
22.03k stars 2.02k forks source link

Polymer 3.2.0 - Minifying es5 bundles causes the transpile to fail #5515

Closed svanherk closed 5 years ago

svanherk commented 5 years ago

Description

When using the following polymer.json settings, the es5 bundle fails to transpile and minify:

 "builds": [
    {
      "preset": "es5-bundled",
      "addServiceWorker": false,
      "bundle": true,
      "js": {
        "minify": true,
        "compile": "es5",
        "transformModulesToAmd": true
      },
      "css": {
        "minify": true
      },
      "html": {
        "minify": true
      }
    }
  ]

The following error is thrown:

{ err: 'Cannot read property \'isIfStatement\' of null' }

This seems to be a problem with babel-preset-minify that was fixed in 0.5.0: https://github.com/babel/minify/issues/850

We tracked the issue down to the polymer legacy adapter, and we think it was caused by a change in class.js (https://github.com/Polymer/polymer/blob/master/lib/legacy/class.js). Rather than find the line causing the error, I think this would be fixed by updating polymer build's version of babel-preset-minify: https://github.com/Polymer/tools/blob/master/packages/build/package.json#L68. (If I should open an issue there, please let me know!)

If we instead use "minify": false, the transpiling works as expected.

Versions

kevinpschaaf commented 5 years ago

Thanks for the report. cc: @usergenic re: polymer-bulild babel dependency.

usergenic commented 5 years ago

Looking into this now.

usergenic commented 5 years ago

FWIW, I updated babel-preset-minify to latest ^0.5.0 and there's a { err: 'Cannot read property \'isPure\' of null' } now. Still working on this issue. Related/duplicate issue: https://github.com/Polymer/tools/issues/717

Am considering replacing babel-preset-minify with uglify-es.

usergenic commented 5 years ago

Then I got { err: 'Couldn\'t find intersection' }...

Managed to get things passing again by disabling a couple of the babel-preset-minify plugins. Hopefully can get https://github.com/Polymer/tools/pull/3388 merged in and cut a polymer-build+CLI release very shortly.

usergenic commented 5 years ago

Published polymer-cli@1.9.8 and polymer-build@3.1.3 fixing this issue.

usergenic commented 5 years ago

Thanks for reporting this @svanherk

svanherk commented 5 years ago

Thanks for the quick response @usergenic, everything is looking good on our end with version 3.2.0 now

kobleistvan commented 4 years ago

This is still an issue on Polymer 3.3.1.

arthurevans commented 4 years ago

@kobleistvan what version of polymer-cli do you have installed?

kobleistvan commented 4 years ago

@arthurevans "polymer-cli": "1.9.7", (Because anything above it won't strip out comments :/ )

arthurevans commented 4 years ago

OK. This issue was fixed in 1.9.8, but I gather that version introduced the regression in comment handling.

Since there's no new work being done on the Polymer CLI, I'd recommend migrating to an alternate bundler. We've been recommending the open-wc Rollup configuration as a starting point, for example.

https://open-wc.org/building/

kobleistvan commented 4 years ago

We'll give that a try. Thanks, much appreciated!

On Wed, Apr 8, 2020, 21:06 Arthur Evans notifications@github.com wrote:

OK. This issue was fixed in 1.9.8, but I gather that version introduced the regression in comment handling.

Since there's no new work being done on the Polymer CLI, I'd recommend migrating to an alternate bundler. We've been recommending the open-wc Rollup configuration as a starting point, for example.

https://open-wc.org/building/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Polymer/polymer/issues/5515#issuecomment-611107673, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSU2RIIGCK7ZYAF5DMHARTRLS4I3ANCNFSM4HB3ERPQ .