Vite ES15 Build

Hi,

I used advanced features like Nullish coalescing operator (??) in JavaScript I want to get production downgrade JS version for those using old WebView.

Do you have a resource on this?

Thanks.

undef and null are falsy
so you can simply replace โ€˜??โ€™ with โ€˜||โ€™
and you will get the same output.

on unix you can do:

cd /path/to/js
sed -i 's/??/||/g' *.js

note that you cant do it the other way around.
i mean you can, but the output will be different (on falsy value that is not null or undef)

Thanks, but I mean using something like babel.

1 Like

I personally just use @babel/preset-env ยท Babel

I can then just set which browsers/platforms I need to support and it does much of the heavy lifting for me.

Largely not an issue for android as the webview is updateable outside of OS updates, but to ensure iOS compatibility I just do:

// babel.config.js
module.exports = {
  presets: [
    ['@babel/preset-env',
      {
        "targets":
        {
          ios: "13.4"
        },
        "modules": false
      }
    ]
  ],
};
1 Like