Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if conditional statement being negated after bundling process #947

Open
coding-sldr123 opened this issue Jul 25, 2022 · 1 comment
Open

Comments

@coding-sldr123
Copy link

I'm submitting a bug report

Webpack Version:
5.70.0

Babel Core Version:
7.17.5

Babel Loader Version:
8.2.3

Please tell us about your environment:
AWS Amplify

I am running into a weird bug using webpack/babel. I am experiencing a difference between how my code looks in the GUI where I wrote it and in the browser. I have an if statement that starts off something like this:

if (condition1 || condition2 || condition3) return;

after webpack bundling it looks like this, via the browser debuggers (firefox and chrome):

if (!(condition1 || condition2 || condition3)) return;

It is completing negating the if statement.

excerpts from webpack file:

{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
plugins: [
[
"@babel/plugin-transform-runtime",
{
"corejs": 3,
"helpers": true,
"regenerator": true
}
]
],
presets: [
'@babel/preset-env',
'@babel/preset-react'
]
}
},
}

..

output: {
filename: 'bundle.js',
publicPath: '/'
},
devServer: {
historyApiFallback:true
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.htm'
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),

...

This is a bug being produced in a react project, in a component within a button click event.

@JLHwung
Copy link
Contributor

JLHwung commented Jul 25, 2022

Can you provide a minimal reproduction repo? Without such repo we can't investigate what is going wrong here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants