You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to minify certain (not very well-formed) strings, swc.minifySync(...) panics and terminates the Node.js process.
Input code
importswcfrom'@swc/core'try{swc.minifySync('\u001a\u0000',{mangle: true,module: true})}finally{console.log('this should be printed no matter what, but is not')}
Config
{
"//": "I have none"
}
Playground link (or link to the minimal reproduction)
I'm trying to incorporate @swc/core into an internal tool. It's probable that at least a few users of the tool will inadvertently configure it to try to minify files which can't be minified, because they aren't JavaScript, or aren't even text. When this happens, the tool needs to be able to handle the error and continue onwards. In this case the file which broke was a PNG image file. The string '\u001a\u0000' is a minimal recreation of the break, from whittling the PNG data down.
Thank you for a great project!
The text was updated successfully, but these errors were encountered:
Describe the bug
When trying to minify certain (not very well-formed) strings,
swc.minifySync(...)
panics and terminates the Node.js process.Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.100&code=H4sIAAAAAAAAAzWMsQoCMRBE%2B0D%2BYbs94Thja2VvYXGtTYjJEUh2ZS9Bgty%2Fa%2FBshuHNY2J%2BshRYXw6CcAa8fOvRsXjUqkiDt1bQ5ylHiqHNjdyA92rMyfY0BsefA5AtLcmfoUj14474Uf%2Bok%2B2g1QYhkk1p%2F3ZMKyc%2FJV4GvF2xG1p9AAzNzlaYAAAA&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BAWdSIifrKJVBTl7iUE0maH3xsz8jooBbNoeKq1PMsQkYX4nEsi2Sf8lARIOxTNJia49XaWvRrRCtVoOxpIyBOluiX3hoMNQajjLXPGmzH%2FC3VwkUnkCu4o%2BsnSVTc0JbjwXmrZDkk50qF%2FwA%2FqsvNjMPLqm4kXGrYvhlQioBQBAAA%3D
SWC Info output
Expected behavior
In this case I believe the correct behaviour would be to throw an exception which can be caught, so that execution can continue.
Actual behavior
Version
1.4.14
Additional context
I'm trying to incorporate
@swc/core
into an internal tool. It's probable that at least a few users of the tool will inadvertently configure it to try to minify files which can't be minified, because they aren't JavaScript, or aren't even text. When this happens, the tool needs to be able to handle the error and continue onwards. In this case the file which broke was a PNG image file. The string'\u001a\u0000'
is a minimal recreation of the break, from whittling the PNG data down.Thank you for a great project!
The text was updated successfully, but these errors were encountered: