Open JeanMeche opened 6 months ago
This is because esbuild considers throwing an exception to be a side effect, and new RegExp
can potentially throw an exception (such as new RegExp('[')
). The string literal is not checked for whether it's a valid regular expression or not.
While inspecting my bundle output I just saw that an unreferenced regex wasn't removed by DCE. It looks like it only affects regex created by
new RegExp(...)
.Is there a reason for that ?
Demo