question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove Tone.js from JavaScript package?

See original GitHub issue

The package at https://cdn.jsdelivr.net/npm/@magenta/music@0.0.5/dist/magentamusic.min.js now includes Tone.js as well, as the player using it is exported from core.ts.

I don’t think this is something users would expect, and may cause issues with projects using other versions of Tone.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:27 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
tambiencommented, Jul 23, 2019

Haven’t done a ton of research into this, but shouldn’t tree-shaking remove the need for splitting apart @magenta/music into multiple packages?

In an ideal world import { Coconet } from @magneta/music would only pull in just the model and it’s dependency files, so if that model didn’t rely on anything with Web Audio / Tone.js, then it wouldn’t be compiled into your code. In practice i’ve found that you’ve got to deep require Coconet by doing something like import {Coconet} from @magenta/music/es5/coconet/Model.

Reading a little about tree-shaking with typescript just now, seems like maybe setting the tsconfig to export an esnext module with import/export statements instead of all require statements would enable tree-shaking in compilers that support it (like webpack).

I haven’t tested this out myself, just wondering if this might be a simpler direction that is better setup for future browser/ES6 developments vs reorganizing the codebase into multiple packages.

1reaction
mattetticommented, Jul 20, 2019

@teropa I agree, and ideally we could provide some sort of interface/adapters so one can bring their own player/lower level audio implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove Tone.js from JavaScript package? · Issue #56 - GitHub
I like having the player accessible from our package. ... Tone.js currently doesn't play too nice when it's loaded multiple times on a...
Read more >
tone - npm
js is a Web Audio framework for creating interactive music in the browser. The architecture of Tone.js aims to be familiar to both...
Read more >
Destination - Tone.js
Defined in: Tone/core/context/ToneWithContext.ts ... NOTE: this will disconnect any nodes which were previously chained in the master effects chain.
Read more >
is Tone.js meant to be used within browser? - Google Groups
The library is made for using with the browser, once you install it with npm it should be in the modules folder of...
Read more >
p5.js sound library: how to add/remove p5. Phrases() from p5 ...
You're right, there is a bug in p5.sound so that p5.Part.removePhrase does not work. Here's a fix: Add the following snippet at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found