-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Modify module exports mode to production in webpack.config.js #20431
Modify module exports mode to production in webpack.config.js #20431
Conversation
it's still using eval |
Can we switch |
a484e42
to
fd60812
Compare
Thanks for the review @wendigo,
I could not find eval() in the generated file. Could you point me to file?
After switching to production mode, I was getting below error. Same as mentioned here.
https://stackoverflow.com/questions/68626172/on-building-babel-loader-outputs-a-module-object-with-id-null-webpack-command suggests to use |
The generated webapp Javascript files has `eval()` function. Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you use `eval()`. Please see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval! With `mode: "development"` and no mention of `devtool` in webpack config, the `devtool` defaults to `eval` and generates the javascript files with `eval()` function. Modifying mode from `"development"` to `"production"` generates the JavaScript files without `eval()` function. This change requires to use `webpack-cli` instead `webpack-command`, as `webpack-command` is deprecated (https://github.com/webpack-contrib/webpack-command).
fd60812
to
064de86
Compare
LGTM. I've checked that PR locally. Seems to work |
Description
The generated webapp Javascript files has
eval()
function. Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you useeval()
.Please see: never_use_eval!
With
mode: "development"
and no mention ofdevtool
in webpack config, thedevtool
defaults toeval
and generates the javascript files witheval()
function.Modifying mode from
"development"
to"production"
generates the JavaScript files withouteval()
function.This change requires to use
webpack-cli
insteadwebpack-command
, aswebpack-command
is deprecated (https://github.com/webpack-contrib/webpack-command).Additional context and related issues
This example demonstrates various types of source-maps: https://github.com/webpack/webpack/tree/main/examples/source-map
Release notes
(x) This is not user-visible or is docs only, and no release notes are required.