Make jsPsych runnable in Node/modular
See original GitHub issueHi! I’m Ryan, a student at Northeastern University. I’m part of a student organization, called Sandbox, that builds open-source software for researchers. This year, I led a team that built a psychology application with jsPsych. We loved the library and it enabled us to replicate what had previously been done in PsychoPy in a web-deployable manner.
Recently, I refactored our experiment a bit to use modern JS features like modules to organize the repository better and add unit tests with Mocha. One thing I noticed is that jsPsych did not play very nice with Node, as it’s optimized for the browser so NodeJS support really means next to nothing for the library. However, I did a little tinkering in the repository and managed to come up with a band-aid solution to get the tests running.
I’m wondering if this is something you’ve thought about, or something that you’d like work done on. If so, I’d love to work with you to develop some acceptance criteria for something like this. Here’s a non-exhaustive list of things I’m thinking about:
const jsPsych = require('jspsych')
orimport jsPsych from 'jspsych'
– getting the jsPsych object from an import statement rather than relying onwindow
(which does not exist in Node)- plugins can also be imported, possibly configured in a
jsPsych.config.js
similar to Gatsby’s config file - possibly adding an NPM package for each plugin (think
@jspsych/html-keyboard-plugin
) instead of including them by default, mostly to decrease the bundle size and make configuration easier
Issue Analytics
- State:
- Created 4 years ago
- Comments:34 (18 by maintainers)
Is there any update on this?
The branch does not seem to be active
https://github.com/jspsych/jsPsych/tree/feature/modularization
Got it, that makes sense.
I do think that adopting ES6 modules as the default may solve all these problems. I don’t see ES6 modules as any more difficult to use than the current plugin system. There’s no need to install
npm
or run build scripts if you are using<script type="module">
. The only significant downside is officially dropping any hope of supporting IE. Current usage stats put adoption in the high 80% range, and that should only go up. There’s probably a way to polyfill that could be shipped by default, or pointed to as an option.