kurokida / jspsych-psychophysics

A jsPsych plugin for psychophysics
https://kurokida.github.io/jspsych-psychophysics/
MIT License
51 stars 13 forks source link

npm for the plugin? #38

Closed franfrutos closed 1 year ago

franfrutos commented 1 year ago

I am using jspsych-builder, which I think makes the process of programming experiments with jspsych much more flexible and simple, and I would like to use this plugin in integration with jspsych-builder. The fundamental problem is that, as far as I know, plugins have to be installed via npm. Have you thought about converting this package into a package so that it is possible to use it via npm?

kurokida commented 1 year ago

Thanks for this post!

Unfortunately, I'm not familliar with the npm at all. But my friend @tpronk might be able to help us. I hope you don't get your hopes up and wait too long.

tpronk commented 1 year ago

Hi @franfrutos and @kurokida!

I took a quick peek at jsPsych Builder. I see that besides NPM, it also supports "module-style imports of non-module plugins from @jspsych-contrib". However, the NPM and the contrib approach seem to require that the jspsych-psychophysics plugin is written in ES6, which it currently isn't. Converting the psychophysics plugin to ES6 could be quite project.

However, I'm not very sure of the above, since I'm not very experienced with jsPsych and only found out about that builder half an hour ago. Maybe reach out the builder devs to see what they think?

franfrutos commented 1 year ago

Thank you both!

I have opened an issue in the jspsych-builder repository (bjoluc/jspsych-builder#40). Let's see if the jspsych-builder developers have a simple solution.

tpronk commented 1 year ago

Bueno! I liked it in the hope that I then get notifications when we get any replies :)

bjoluc commented 1 year ago

Hi all,

I just skimmed over the code and found that it's quite easy to turn into an ES module and publish to NPM. It doesn't require modernizing any of the internals, just changing some top-level code. However, it would add an extra "transpile" step that automatically creates the conventional jspsych-psychophysics.js file from the ES version of it so you don't have to maintain both. @kurokida You might continue committing a generated jspsych-psychophysics.js to Git or just let people download the package from NPM / unpkg.com instead of GitHub. And you would need to update the package version and run npm publish for every new release. Happy to send a PR and explain the setup if you're interested. Cheers!

kurokida commented 1 year ago

@bjoluc Thank you for the careful explanation. Since I'm not familiar with the ES module and NPM, I can't fully imagine what would be happned if I accept your suggestions. I'm little concerned about changing how to download my plugin. Since my plugin includes the jsPsych itself, the users can run my sample programs just by downloading the plugin from GitHub repository. Introducing the NPM stile might be confuse my plugin users.

But on the other hand, I interested in making my plugin compatible with NPM. So, if you can please make the PR and let me confirm how use of my plugin would be changed.

Best, Daiichiro

kurokida commented 1 year ago

Thanks to @bjoluc , I can finally publish the psychophysics plugin on NPM. Sorry for the wait.

You can install it runningnpm install @kurokida/jspsych-psychophysics

You can also see the website: https://www.npmjs.com/package/@kurokida/jspsych-psychophysics

Best, Daiichiro