bjoluc / jspsych-builder

A CLI utility to easily develop and package jsPsych experiments
MIT License
46 stars 12 forks source link

jspsych-psychophysics plugin in the builder #40

Open franfrutos opened 1 year ago

franfrutos commented 1 year ago

I would be interested in using the jspsych-psychophysics plugin. Unfortunately it doesn't seem to be available for use via npm. Is there any way I can use the plugin code to make it accessible for use with jspsych builder?

Thanks in advance, and sorry if this is a trivial question.

bjoluc commented 1 year ago

Hi @franfrutos, this is everything but trivial :smile: The root problem is that jspsych-psychophysics is not available as an ES module. This is the same problem as https://github.com/jspsych/jspsych-contrib/issues/26#issuecomment-1099160930. The reason jspsych-builder doesn't support jspsych-psychophysics out of the box is that jspsych-builder's builtin compatibility hack only applies to @jspsych-contrib-scoped packages that don't export modules. You can manually work around it via

import jsPsychPsychophysics from "imports-loader?type=commonjs&imports=single|jspsych|jsPsychModule!exports-loader?type=commonjs&exports=single|jsPsychPsychophysics!./jspsych-psychophysics.js";

@tpronk @kurokida so you get a notification too