How to rename modules/components/scripts?

Lets say I have a component sine_motion.SineMotion, I saved it as external script file because builtin script editor in Blender is fairly unusable for anything but minor edits. Now after some time I realized I need to rename it to motion_sine.MotionSine. But I already have gameobjects with this component on them. How to rename it without breaking the objects? I tried clicking “make internal”, then doing “save as” again but with a new name, and this didn’t work - gameobjects become broken.