Skip to content

Parcel fails to run p5.js #10250

@RichardJECooke

Description

@RichardJECooke

🐛 bug report

Parcel doesn't run p5.js. But the exact same p5 code runs fine with Vite.js. As reported in the p5 project: processing/p5.js#8370 (comment)

🤔 Expected Behavior

p5 runs.

😯 Current Behavior

index2.ts:16 Uncaught TypeError: (0 , _p5Default.default) is not a constructor

💻 Code Sample

index.html

<!DOCTYPE html>
<html lang="">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<script src="./index.ts" type="module" ></script>
</head>
<body>
</body>
</html>

index.ts

import p5 from 'p5';
const sketch = (p: p5) => {
	p.setup = () => {p.createCanvas(800, 800);};
	p.draw  = () => {p.background(220);};
};
new p5(sketch);

Code to run:

docker run --init  -it --rm -v ".:/app" -w "/app" -p 3000:3000 node:24.12.0-slim sh -c  "npm install parcel; npm install p5; rm -rf dist; rm -rf .parcel-cache; npx parcel index.html --host 0.0.0.0 --port 3000";

Browse to http://localhost:3000.

If you instead run the code with vite it works fine, hence there must be a parcel bug:

docker run --init  -it --rm -v ".:/app" -w "/app" -p 3000:5173 node:24.12.0-slim sh -c  "npm install vite; npm install p5; npx vite dev --host 0.0.0.0";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions