Bug: Not taking into account conversion between Number and BigInt for Math.pow usage
- Dominant language
- JavaScript
- Stars
- 4.8k
- Forks
- 456
- Avg merge
- 9h 19m
- Merged PRs (30d)
- 2
Description
**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.
Contributor guide
Research direction
Reproduce the output using try_math_pow.js, the shown webpack configuration, babel-loader, and @babel/preset-env, then inspect bundle.js. Verify how the BigInt expression is transformed and ensure the generated Math.pow call does not receive BigInt operands; rerun the bundle to confirm the resulting code is valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript, webpack
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100