madskristensen / BundlerMinifier

Visual Studio extension
Other
611 stars 171 forks source link

Object reference not set to an instance of an object error when minifying d3.v7.min.js #594

Open plqplq opened 1 year ago

plqplq commented 1 year ago

Describe the bug When you try to re-minify the latest d3 v7 in already-minified state, a compilation error occurs with object variable not set.

To Reproduce In Visual Studio 2022, create a project that includes d3.v7.min.js copied locally as a javascript file, and try to re-minify it in bundleconfig:

  {
    "outputFileName": "js/a.js",
    "includeInProject": true,
    "inputFiles": [
      "js/jq3.min.js",
      **"js/d3.min.js",**
      "js/select2.full.min.js",
      "js/jcode.min.js",
      "js/atemp.min.js",
      "js/googlemaps.js"
    ],
    "minify": {
      "enabled": **true**,
      "renameLocals": false,
      "evalTreatment": "makeAllSafe"
    }

  },

The above code caused the error, and setting minify:enabled:false fixes it.

    "minify": {
      "enabled": **false**,

Although this is easy to workaround, it's an opportunity to improve the error message that is thrown and also an opportunity to fix the problem that some kind of es6 construct is throwing this message.

Expected behavior Compilation should succeed.

Screenshots

Build started...
------ Build started: Project: web7, Configuration: Debug Any CPU ------

  Bundler: Begin processing bundleconfig.json
C:\xam7\web7\js\a.js : Bundler & Minifier error 0: Object reference not set to an instance of an object.
  Bundler: Done processing bundleconfig.json
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
========== Elapsed 00:00.248 ==========
myesn commented 8 months ago

image

You should double-check the inputFile that reports the error, if there is a syntax error, the vs extension will throw an error Object reference not set to an instance of an object, the secret is to fix all the little green waves that appear.