processing / processing/p5.js-web-editor
Import JS modules in web editor?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 1.7k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 8
Description
Nature of issue?
- Existing feature enhancement
NOTE: I am not sure if this is technically an enhancement request or not. If it is not possible to import other files into a sketch in the Web Editor, then this is an enhancement request. (Otherwise, I suppose it’s a…support request (?).)
Feature enhancement details:
I’m learning p5.js, and loving it so far. The web editor definitely makes it easier to jump in and play!
After modifying an existing example, the code got long enough for me to want to split it up into multiple files. However, I don’t want to pollute the global namespace (I actually started out by modifying the example to use P5 in instance mode), so I want to split the code up using JS modules.
But I keep getting the following error in the Web Editor:
Module name, './config.js' does not resolve to a valid URL.
But that file is in the same folder, so I don’t know why this is happening.
(I even tried renaming the file to use the .mjs extension, but no luck.)
So…
How can I import other files into a sketch on the Web Editor?
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 reproducing the Web Editor error with an import of the same-folder config.js file, then inspect the Web Editor's handling of sketch files and module URLs. Done means JavaScript modules can be imported from other files in a sketch without the invalid-URL error, including when the file uses a .mjs extension.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100