Skip to content
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

Generate ESM boilerplate #67

Merged
merged 5 commits into from
Feb 14, 2024
Merged

Conversation

marklundin
Copy link
Member

@marklundin marklundin commented Feb 12, 2024

This PR adds the ability to conditionally generate ESM based class boilerplate when using createScript(). If the provided filename contains the .mjs suffix it will generate code based on the following boilerplate;

export class ClassName extends pc.ScriptType {

    static name = 'Script Name';

    initialize() {

    }

    update() {

    }

    // uncomment the swap method to enable hot-reloading for this script
    // update the method body to copy state from the old instance
    // swap(old) { };
}

// learn more about scripting here:
// https://developer.playcanvas.com/user-manual/scripting/

@marklundin marklundin self-assigned this Feb 12, 2024
@marklundin marklundin added the enhancement New feature or request label Feb 12, 2024
@marklundin marklundin merged commit c40325d into playcanvas:main Feb 14, 2024
2 checks passed
@marklundin marklundin deleted the esm-boilerplate branch February 14, 2024 08:32
@Maksims
Copy link
Collaborator

Maksims commented Feb 14, 2024

Please add dt into update method for the consistency with the old script template.

@marklundin
Copy link
Member Author

Ahh of course. good catch

marklundin added a commit that referenced this pull request Feb 22, 2024
Added 'dt' parameter to the udpate method as per #67 (comment)
@marklundin marklundin mentioned this pull request Feb 22, 2024
marklundin added a commit that referenced this pull request Feb 22, 2024
Added 'dt' parameter to the udpate method as per #67 (comment)
@marklundin
Copy link
Member Author

This has been added now in #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants