LingDong- / q5xjs

A small and fast alternative (experimental) implementation of p5.js
https://q5xjs.netlify.app/
The Unlicense
544 stars 25 forks source link

Publish to npm? #3

Closed peilingjiang closed 3 years ago

peilingjiang commented 3 years ago

Hi, are you considering publishing the package to npm? It would be easier for people to integrate it into projects then. Thanks!

radames commented 3 years ago

That’s a great idea @peilingjiang , I’ve published others @LingDong- project to npm, I can help with a bundling setup if you need @LingDong- please let me know!

Ps Another awesome project! I published a simple example on Observable https://observablehq.com/@radames/hello-q5-js the modularity of your version makes it perfect for that environment

LingDong- commented 3 years ago

Hi @peilingjiang @radames,

Thanks for the suggestion! I decided to figure out publishing on npm, looks like I'm doing it right :) It's now at:

https://www.npmjs.com/package/q5xjs

@radames thanks for the nice demo on Observable!

radames commented 3 years ago

@LingDong- perfect! thanks for doing that, I've update the source on my test to npm and it works great!

ww-wolt commented 3 years ago

It would be great to include in the docs how to add the script by ecmasript import (not only script tag) I have trouble getting it working with react...

peilingjiang commented 3 years ago

It would be great to include in the docs how to add the script by ecmasript import (not only script tag) I have trouble getting it working with react...

@moonclimber1 It's because the function is not exported from the original file, simply change the first line

- function Q5(scope){
+ export default function Q5(scope){

and import it in your file like

import Q5 from 'path/to/q5.js'

Given the fact that you'll need to modify the file to get it to work, you'll not be able to use npm. Instead, you can fork the repo (if you want to then manage your own version of q5.js) or directly download the file.