failwyn / BundlerMinifier

Visual Studio extension
Other
40 stars 10 forks source link

Minifying ExcelJS fails #11

Open Phoniexk opened 2 years ago

Phoniexk commented 2 years ago

Installed product versions

Description

Minifying of ExcelJs fails with error message:

Strict-mode does not allow assignment to undefined variables: regeneratorRuntime

Steps to recreate

  1. Add the lib from a cdn with libman.json:
{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "provider": "cdnjs",
      "library": "exceljs@4.3.0",
      "destination": "wwwroot/js/lib/exceljs/",
      "files": [
        "exceljs.min.js",
        "exceljs.js"
      ]
    }
  ]
}

Now create a bundle for the lib:

bundleconfig.json

[
  {
    "outputFileName": "wwwroot/js/vendor.js",
    "inputFiles": [
      "wwwroot/js/lib/exceljs/exceljs.js"
    ]
  }
]

The vendor.js file is created, but the Minification of vendor.js fails with the above exception.

The only solution is to add var regeneratorRuntime to the excel.js or replace the codeline:

regeneratorRuntime = runtime;

with

window.regeneratorRuntime = runtime;

but this isn't very suitable because every time anything changes in the libman.json, the file is replaced from cdnjs and you have do add the lines again.

One other "dirty solution" would to add an empty js-file which only contains the var regeneratorRuntime.

Edit: I have just added the single exceljs-lib to bundleconfig.js to keep it simply. Usually there a lot more libs.

failwyn commented 1 month ago

Can you provide the section of code that is causing the error?