developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.03k stars 362 forks source link

BigInt exponentiation `2n ** 63n` transpiled to `Math.pow(2n, 63n)` in CommonJS output #953

Closed make-github-pseudonymous-again closed 2 years ago

make-github-pseudonymous-again commented 2 years ago

Expected? It is broken on Node v17.9.0.

rschristian commented 2 years ago

Yes, this is correct. Everything but the modern output is ES5 while the exponentiation operator is ES2016.

If you'd like to alter the targets you can do so using a "browserslist" entry in your package.json:

{
  "browserslist": [
    "node >= 7"
  ]
}

If you're only after Node compat (which I'm guessing since you've listed Node version), then this config will work. This operator has been supported since Node v7 (source).

Edit: Forgot, --target node will do this as well without need to alter the browserslist config.

make-github-pseudonymous-again commented 2 years ago

Thanks @rschristian. Is there a way to fix this with --taget web? I was only giving out node version because that's what I use to run microbundle.

rschristian commented 2 years ago

Yep, certainly can! Just edit the browserslist:

// package.json
{
  "browserslist": [
    "last 5 years"
  ]
}

Should do the trick.

rschristian commented 2 years ago

Closing this out as it's hopefully been answered. Let me know if you're still having issues and I can reopen.