-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup NPM package and use TypeScript #40
Conversation
Thank you very much! I have some questions. Sorry for bothering you, but I'm very new to npm, so I think my questions are elementary.
I hope I could talk with you in a face-to-face session someday, but I'm not good at English conversation. So communication using text is convenient for me at least now. Best, |
Sure thing!
My bad, sorry! I meant to write
I copied it from jspsych-contrib and modified it by hand. Alternatively
Works for me too, no probs! So just feel free to ask me anything :) |
Thanks to you, I am making some progress! In fact, I tried to convert my plugin file to TypeScript before, but I gave up. You seem to have succeeded in doing that. How did you make the src/index.ts file? I guess you have used some useful tools. When I add new features to my plugin or fix bugs, will I change the src/index.ts file? Actually, I tried to run my sample programs, but it failed. Best regards, |
I don't know if there are tools to do that; I just copied
You name it! In order to test the changes with the examples, you'll have to run
I couldn't find any attachments, but I tested all examples locally before creating the PR. Wild guess: Maybe you do not have d9bc08e locally? I had to make one patch change to |
Sorry I forgot to attach the file. Today I cloned your repo, so I think your final commit is included. I greatly appreciate making the src/index.ts file. In fact, I am unfamiliar with TypeScript. So I would like to learn how to convert the original JS file to a TS file. Let me try this before merging your PR. It might take a long time. |
I really appreciate that! Take your time. You may find the jspsych-contrib plugin template's EDIT: Turns out I was lying to you about not using any tools: I used Prettier for code formatting in |
I ran the demos in Firefox only. Running EDIT: After looking into this again, the best solution might be to get rid of math.js. It looks like https://github.com/mljs/matrix can be a slim and efficient replacement here which would vastly reduce the bundle size. It might be interesting to see if it can compete with EDIT 2: Couldn't help but try |
Thank you for your valuable comments and commits. |
Thank you very much for your cooperation! |
Hey @kurokida! Sorry if updating this raised the pressure on you; it wasn't intended to (I don't depend on this)! Just making sure the PR won't be outdated once you get to it 🙂 Take your time! |
Sorry for the late reply and congrats for transitioning! 🎉
Luckily, those are transitive dependencies of The next step for you would be to sign up at npmjs.com and run |
Following up on #38, this sets up an NPM package and – different than originally planned – also sets up TypeScript. I figured it would probably not be a good idea to set up a custom build chain in this repo that – however simple it may be – needs to be maintained, so I opted for the one used by the packages in jsPsych and jspsych-contrib repos, which is readily available via
@jspsych/config
.The source file is
src/index.ts
now, andjspsych-psychophysics.js
is generated by the build chain on runningnpm build
. It includesmathjs
andnumeric
for convenience, but not PixiJS (due to its heavy size). Hence, all demos continue working with the current file paths. There is a breaking change however that I couldn't avoid: When using PixiJS, the Pixi script needs to be included before the psychophysics plugin or it won't be available tojsPsychPsychophysics
.This PR adds a lot of development tooling under the hood and I'm happy to explain everything in detail, including some remaining choices – ideally in a face-to-face session. Just let me know if you're interested. Cheers!