playcanvas / playcanvas/engine

ESM Scripts break projects with Classic Scripts.

Open
#8,400 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

Various libraries for PlayCanvas often extended pc to add their classes.
For example:

pc.Angle = function(degrees = 0) {
    this.degrees = degrees;
};

pc.Angle.prototype.rotate = function(degrees) {
    this.degrees += degrees;
};

Adding a single ESM script to projects, will lead for all pc extensions to not work, and fail.

Image

This is very limiting the migration progress, and prevents many larger projects to ever migrating, as gradual migration is difficult to pull off due to this limitation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing a project that combines one ESM script with classic scripts and extends pc, using the example in the issue as the minimal case. Then trace how these two script types are loaded and how the shared pc object is exposed. Done means existing pc extensions continue to work during gradual ESM migration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.