Skip to content
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

Error: Dot.buildAndAttach is not a function #1630

Closed
the-drunk-coder opened this issue Aug 13, 2024 · 6 comments
Closed

Error: Dot.buildAndAttach is not a function #1630

the-drunk-coder opened this issue Aug 13, 2024 · 6 comments

Comments

@the-drunk-coder
Copy link

Hi,

I'm trying to draw dotted notes, but somehow I'm getting an error that

Uncaught TypeError: Dot.buildAndAttach is not a function

Not sure how to fix this ... I'm on latest Vexflow 4, using the vexfow4 package from npm ...

@AaronDavidNewman
Copy link
Collaborator

You really need to share some code with us on a fiddle or something. buildAndAttach is a static method of Dot, so make sure you import {Dot}.

@the-drunk-coder
Copy link
Author

the-drunk-coder commented Aug 13, 2024

Here's the relevant code as copied from my project, with the difference that I import from node_modules instead of from the web:

https://jsfiddle.net/adzty1kf/

In my project I import via:

<script src="/node_modules/vexflow4/releases/vexflow-min.js"></script>

instead of:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/cjs/vexflow.js"></script>

The fiddle works, though, and in fact, when I use the second variant in my project, it works as well ... so maybe there's something broken in the npm release ?

EDIT: everything else works as expected when importing via the npm method

@AaronDavidNewman
Copy link
Collaborator

When I look in 'vexflow-min.js', I see this at the end:

// YOU ARE LOOKING AT VEXFLOW LEGACY VERSION 3.0.9.
// SEE THE `build/` FOLDER FOR THE NEWEST RELEASE.

So that is likely your issue. Use the build/cjs version of vexflow.js or vexflow-debug.js

@the-drunk-coder
Copy link
Author

hmm that's odd, as I'm using a package from npm that has only been created about a month ago, as indicated in this comment:

#1625 (comment)

It's marked in npm as version 4.2.5 --> https://www.npmjs.com/package/vexflow4

In my package.json I use that version number as well:

"dependencies": {
        "osc": "2.4.0",
        "vexflow4": "4.2.5"
    }

So if vexflow-min.js really is version 3.0.9, then that'd be really counterintuitive ...

@AaronDavidNewman
Copy link
Collaborator

The code and versions in build directory are 4.2.5. The releases directory is pre-built. I think they keep some older version around for the visual regression tests, or maybe it was an oversight (maybe @ronyeh has an idea).

I think in all cases you want to use one of the packages in /build/cjs, as this would have been build with latest source code.

@ronyeh
Copy link
Collaborator

ronyeh commented Aug 22, 2024

Hello @AaronDavidNewman and @the-drunk-coder,

Sorry for the confusion! Yes, we had been keeping around the legacy version of VexFlow (v 3.0.9) in the releases/ directory.

This was because some old websites and old JSFiddles that depended on v3.0.9 linked directly to:
https://unpkg.com/vexflow/releases/vexflow-min.js

If we had removed the releases/ directly when we published v4.x, we would have broken those old sites. Even if we put v4.x into the releases/ directory (overwriting 3.0.9), we would have broken those old sites, since 4.x introduced breaking changes.

Yes, it's confusing that we ship the legacy version alongside the current one in the build/ directory.

4.x has been out long enough now (and we're working on 5.x). I think it's time we remove that releases/ folder. It's OK if those older JSFiddles break. :-)

I'll introduce a PR to remove the releases/ folder from the NPM package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants