1

I'm using wavesurfer.js with React and Typescript. To get the typings I'm also using the corresponding @types/wavesurfer.js. Now I want to use the cursor plugin. When I'm importing the actual CursorPlugin this way

import CursorPlugin from 'wavesurfer.js/src/plugin/cursor.js';

I get all the type hints etc. but the compiler says:

ERROR in ./path/to/my/component/index.tsx 9:0-62
Module not found: Error: Can't resolve 'wavesurfer.js/src/plugin/cursor.js' in 'path/to/my/component'

Here is the Codesandbox demonstrating this behavior.

I already found a workaround on the interwebs:

import CursorPlugin from 'wavesurfer.js/dist/plugin/wavesurfer.cursor.min.js';

and it works although I don't get type hints this way. But it just doesn't seem to be the "right" way to do it, so I was wandering if anyone else has found any better solution yet?

2
  • I'm having the same issue. This import worked in v5.x, but not in more recent versions. Did you find a solution? Commented Apr 16, 2024 at 15:41
  • @JLGradley unfortunately not, I just went with the workaround I mentioned Commented Apr 18, 2024 at 9:51

1 Answer 1

0

As of v7, the Cursor plugin is now named Hover.

As mentioned in this Github comment, you can import it with the types:

import Hover from 'wavesurfer.js/dist/plugins/hover.js'

With waveform.js v7 you don't need to install @types/wavesurfer.js.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.