Skip to content

Import JS modules in web editor? #1933

Open
@Zearin

Description

@Zearin

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions