Skip to content

Bug: Not taking into account conversion between Number and BigInt for Math.pow usage #1050

Description

@badghee1937

Webpack Version:
"webpack": "^6.0.1",

Babel Core Version:
"@babel/preset-env": "^7.26.7",

Babel Loader Version:
9.1.3

I have this small code-snippet:

console.log(Number(2n**53n));

After bundling it with the following configuration:

const path = require('path');
module.exports = {
    entry: './try_math_pow.js',
    output: {
        path: path.resolve(__dirname, './'),
        filename: 'bundle.js',
      },
      module: {
        rules: [
          {
            test: /\.js$/,
            exclude: /node_modules/, 
            use: {
              loader: 'babel-loader',
              options: {
                presets: ['@babel/preset-env'], 
              },
            },
          },
        ],
      },
  };

The bundled file has:
console.log(Number(Math.pow(2n,53n)));

However Math.pow doesn't take BigInt parameters, hence the parameters should be fixed accordingly to the use of Math.pow or use simply exponent arithmetic operator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions