Skip to content

Are modules serializable? #46

Open
@sancarn

Description

@sancarn

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.G

import { run } from "@jxa/run";
let someVar = 1
export const currentUserName = () => {
    // This callback function is run as JXA
    return run(() => {
        return someVar;
    });
};
currentUserName() //returns undefined

At least with modules it will be very clear that this is a new and seperate scope.

export const currentUserName = new JXAFunction(
    module {
        const sys = Application("System Events");
        return sys.currentUser().name();
    }
)
currentUserName() //returns <current user name>

Features like this will only be doable if module are serializable, however.

Metadata

Metadata

Assignees

No one assigned

    Labels

    host environmentQuestions to be answered in each host environment

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions