question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make jsPsych runnable in Node/modular

See original GitHub issue

Hi! 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') or import jsPsych from 'jspsych' – getting the jsPsych object from an import statement rather than relying on window (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:closed
  • Created 4 years ago
  • Comments:34 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
nx10commented, Sep 19, 2019

Is there any update on this?

The branch does not seem to be active

https://github.com/jspsych/jsPsych/tree/feature/modularization

2reactions
jodeleeuwcommented, Aug 29, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration - jsPsych
Then run npm install . This will create a node_modules directory and install all the dependencies into it that are required to build...
Read more >
The Basics: Hello World - jsPsych
This approach involves downloading a bundle of scripts that make up jsPsych. ... This requires using the jsPsych.run function and passing in a...
Read more >
initJsPsych
The settings object for initializing jsPsych. See table below. The settings object can contain several parameters. None of the parameters are required.
Read more >
Controlling Visual Appearance - jsPsych
This is a good option for when you want to make few and/or simple style changes to an HTML trial parameter. To change...
Read more >
Running Experiments - jsPsych
It's usually the fastest and easiest way to run through an experiment, ... computer and only makes the experiment files available from within...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found