-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are modules serializable? #46
Comments
Sorry, what do you mean by serializable exactly? Module blocks support |
I guess in an ideal world it'd be nice if you could just obtain the body of the code block. But even getting |
I guess the answer is yes, it may pass the structured clone algorithms but that algorithm is not defined in the JS. |
Just as a note, the code provided: export const currentUserName = new JXAFunction(
module {
const sys = Application("System Events");
return sys.currentUser().name();
}
)
currentUserName() //returns <current user name> Won't work because the code inside You can just export a function though, and import and call that function instead: module {
export default function() {
const sys = Application("System Events");
return sys.currentUser().name();
}
} |
I am very excited about this idea, as it finally gives us syntax sugar for a scopeless blocks! Are modules serializable?
Scenarios like node's @jxa library should be considered in this scenario. JXA has global
Application
and$
objects which already pose typescript issues ofc, but more to the point it's difficult to see from libraries such as@jxa
, that variables won't be in scope. E.GAt least with modules it will be very clear that this is a new and seperate scope.
Features like this will only be doable if module are serializable, however.
The text was updated successfully, but these errors were encountered: