If I export AppleScript written in JavaScript as run only, I can open back in Script Editor. It also shows all the source code. However, if I export regular AppleScript as run only, I can't open it nor look at the source code using other text editor. Is there any solution for this? Thanks!
Both OSA languages are working as designed. The 'run only' option tells an OSA language to save a script as "non-decompilable" bytecode that can't [easily] be converted back to source code format. This provides a measure of protection against others snooping or modifying that script when it's distributed, though you do need to take care to keep a separate editable copy yourself should you need to make future changes to it.
AppleScript was designed to support OSA (and vice versa) so supports this and every other OSA feature just fine. OTOH, JXA is a half-baked mess and doesn't support a lot of OSA features correctly/at all. Though in this case there's probably not much JXA can do as the JavaScript interpreter doesn't support storing and loading scripts in bytecode format, and there's no way for an OSA language to tell Script Editor to disable the 'run only' checkbox if it doesn't support it, so a JXA .scpt
file will always contain the original, editable JS source code even when you think it doesn't.
(That the 'run only' option doesn't work for JXA scripts should be documented, of course, but JXA's documentation is worse than its implementation is, so no surprise there.)