madskristensen / BundlerMinifier

Visual Studio extension
Other
616 stars 172 forks source link

Using the JS nullish coalescing operator (??) generates an object reference not set to an instance of an object error. #554

Open AndradeAlbuquerque opened 3 years ago

AndradeAlbuquerque commented 3 years ago

Installed product versions

Description

It seems it is not possible to Bundle & Minify javascript files containing the nullish coalescing operator ('??') because it generates the error "(Bundler & Minifier) Object reference not set to an instance of an object."

Steps to recreate

  1. Create a js file
  2. Create some function with: let otherurl = null; let userOptions = { parameter1: 'this is my parameter 1' }; let options = { url: otherurl ?? '/myurl', parameter: userOptions?.parameter1 ?? '' };
  3. When Bundle & Minification the "(Bundler & Minifier) Object reference not set to an instance of an object." is shown in Error List and no minified file is generated.
msschl commented 3 years ago

The same happens when using the elvis operator i.e., optional chaining (?.)

bronthulke commented 3 years ago

I am having the same issue, and worked around it by using old-school null handling for now, but it would be great to know if this is something that might be resolved, as I'm in the process of moving all my bundling over to use this extension.

m1dst commented 2 years ago

Still doesn't work 1y later

Lucidize commented 11 months ago

I am also trying optional chaining operator ('?.') and arrow functions ('() => {}') but getting a syntax error on compile to a bundle. Still now fixed so will have to revert to old JavaScript syntax.