webextensions/copy-files-from-to

uglifyJs option is not working

raduchiriac opened this issue · 5 comments

I wrote a JSON file named copy-files-from-to.json at the root of my project, when I add "uglifyJs" in my options, the copied js file is not being processed/uglified.

Example:

{
  "copyFiles": [
    {
      "from": "node_modules/ie11-custom-properties/ie11CustomProperties.js",
      "to": "dist/js/ie11CustomProperties.js"
    }
  ],
  "copyFilesSettings": {
    "uglifyJs": true,
    "whenFileExists": "overwrite"
  }
}

I use npx copy-files-from-to --verbose and the output is:

copy-files-from-to version: 3.1.2
Node JS version: 12.16.0
Reading copy instructions from file copy-files-from-to.json

Starting copy operation in "default" mode: (overwrite option is on)
 ✓ Copied [ utf8 ] node_modules/ie11-custom-properties/ie11CustomProperties.js to dist/js/ie11CustomProperties.js

Fixed now in the latest version (v3.1.3) :-)

It's worse with 3.1.3, the copied file outputs undefined now.

@raduchiriac
That issue with "undefined" output has been fixed with v3.1.4 of copy-files-from-to.

In the given case, Uglify JS fails to work because it doesn't understand new JS syntax. Now, in the updated version, the original JS file would be returned in such a case.

Fixing the above mentioned scenario would require moving from "uglify-js" to "terser" library (https://www.npmjs.com/package/terser) which supports new JavaScript syntax.

It may take some time before that change is implemented.

Reopening.

OK, thanks for the explanation.
It's written on the homepage of uglify-js that it only supports ES5 so it makes sense. I'll keep an eye on the updates

The issue has been fixed with c53fec2 which is available with copy-files-from-to@3.6.0 onwards.