cuthbertLab / music21j

Javascript port of music21 -- Toolkit for Computational Musicology
Other
144 stars 41 forks source link

Migrate to VexFlow 4 #144

Closed ronyeh closed 2 years ago

ronyeh commented 2 years ago

This patch works with VexFlow 4.0.0-alpha-6, currently available at:

npm install https://vexflow-demo.surge.sh/vexflow-4.0.0-alpha-6.tgz

ronyeh commented 2 years ago

Cool, if core-js works when you build, then it's probably fine. :-) I was just trying to get everything compiled with no errors and warnings. It was something about how some of the modern JS methods were unresolved (since VexFlow doesn't use core-js). If I can repro I'll send you an error log.

You don't need to treat this as an official PR. It's just a guide and you can apply the patch into a vex4 branch on your side.

I do agree you should use aliases for all imports of VexFlow classes. It's much clearer that way (VFOrnament vs Ornament).

ronyeh commented 2 years ago

If you plan to merge this into your master at some point (post VexFlow 4 release), let me know. I can update the PR with VFXXX prefixes for all the imports. That will clarify things and avoid name collisions.

ronyeh commented 2 years ago

I updated this PR with the most recent VexFlow 4 build. It only includes Gonville.

Give it a try and let me know if you run into any issues.

For me, the magic line seems to be this webpack resolve alias: https://github.com/ronyeh/music21j/blob/103789c10ecbda86bc1c2aa8af98d1aed193c3a0/Gruntfile.js#L78-L80

https://webpack.js.org/configuration/resolve/#resolvealias

There are multiple ways to accomplish the same thing, apparently.

In my example projects, we use tsconfig.json's paths.

In the future, neither of these should be necessary, after TypeScript 4.6 and WebPack loaders work together to parse VexFlow's package.json properly. :-)

mscuthbert commented 2 years ago

Thanks -- I'll definitely get on this as soon as Vex4 is released fully! :-) good luck and thanks!

mscuthbert commented 2 years ago

Wonderful -- I will try this out sometime this weekend

ronyeh commented 2 years ago

Moved to here: https://github.com/cuthbertLab/music21j/pull/172

This PR was getting a bit messy due to repeated merges. The above PR is a bit cleaner.