[p5.js 2.0] ESM usage in global mode
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Increasing access
existing feature in v2
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
Feature enhancement details
In issue #7332 @limzykenneth wrote:
p5.js 2.0 will support ESM and due to the nature of ESM, sketches have to be written in instance mode. The way we are testing and iterating in 2.0 development is using an ESM sketch.
I understand that since functions declared in a module are not attached to the window, only the module's scope, users would have to define functions using the p5 v2 instance.
Yet, p5 v2 could otherwise start in global mode by attaching p5 instance functions and variables to window, which would make them top-level accessible in the module.
Ideally global mode would be the default when p5 v2 is used in an ESM module, or at least it should be an option, otherwise all p5 functions and vars would need to be instance prefixed.
I'm planning on making q5.js WebGPU top level global mode in an ESM the default way to use q5play (upcoming sequel to p5play), so it'd be great if p5 v2 supported this as well.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked discussion in issue #7332 and the described p5.js 2.0 ESM sketch usage. Clarify whether global mode should be the default or an opt-in option, then validate the chosen behavior with an ESM sketch; done means p5 functions and variables work as specified without unintended instance-mode requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100