Why did Webpack introduce eval mode to generate JavaScript code

recently looking at the JavaScript, generated by Webpack, there is a question that I don"t understand: why should Webpack provide the mode of eval , wrapping the generated code of the module with eval ?

the discussion here is not limited to devtool is eval , but also includes eval-source-map , cheap-eval-source-map and other derivative combinations that contain eval . If the advantage of eval is that build is fast, because it doesn"t generate source map, what about things like eval-source-map ?

so my question is not source map, but eval itself. If it is so criticized, why does Webpack still introduce such a code generation mechanism, and what are the benefits of it?


goto is also criticized, but you can still use goto in C/CPP.

what is really criticized is not eval, but the abuse of eval. If you confirm that the code you get is your own (or anything you trust), using eval is perfectly acceptable, and you can enjoy the benefits of speed.


agrees with the answer to Code Universe. Another deprecated keyword in js is with, but with, is available in template rendering in vue source code, which does make the code look simpler and clearer. The same goes for eval, which avoids abuse, but you can be sure that it will be more convenient to use it.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32508-2b657.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32508-2b657.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?