This answer goes along with the other answers provided, but I wanted to add that there is a note in the @wordpress/scripts github repo that mentions this behavior as well. You need to downgrade versions to @wordpress/script@27
28.0.0 (2024-05-31) Breaking Changes
Note If you're using @wordpress/scripts for building JS scripts to target WordPress 6.5 or earlier, you should not upgrade to this version and continue using @wordpress/scripts@27.