How should I import Paper.js in Svelte?

Viewed 534

I'm using the standard Svelte template with Rollup and have not been able to successfully import Paper.js.

I installed paper via:

npm install paper

and I get this output trying to do npm run dev after importing Paper:

(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
acorn (guessing 'acorn')

Acorn is a dependency of the paper-full.js disto, and I'm looking to map

import { paper } from "paper";

to paper-core.js (although it would be very cool to get PaperScript from the full distro working in Svelte, but that's likely a whole other can of worms).

I'm wondering what kind of Rollup config I would need to add to resolve this.

Here's the repo I'm working on if you'd like some more context or a quick way to jump to exactly where I'm at.

1 Answers

UPDATE: Got it working! I had forgotten to install acorn as a dependency. I also switched to installing them both as devDependencies since rollup bundles everything. -- solution credit to Antony in the Svelte Discord

Related