-
-
Notifications
You must be signed in to change notification settings - Fork 22
Setup Angular 6 with music-metadata-browser #13
Comments
For music-metadata parsing, on the browser side, you better use this npm. That will get rid of the fs dependency. But, there are some things you have to take care of, due to some Node specific dependencies which needs to be poly-filled: Using Angular 6 you need to polyfill stream & assert in your tsconfig.json: "paths": {
"stream": [ "node_modules/readable-stream" ],
"assert": [ "node_modules/assert" ]
} An example can be found in audio-tag-analyzer. Not so many projects are using music-metadata-browser @bfromager, so I am looking forward to hear if things work out for you. |
Thx for your quick reply. |
Did you add stream-readable and assert as dependencies to your project? You basically tell the TypeScript compilere where to look for the stream & assert dependency. Compare your project with the audio-tag-analyzer. I If you tell me where to find it I can have a look to your code. |
Since I just ran into this:
and then polyfill some globals in
in addition to the |
@wulfsberg thanks for sharing that, really useful! Although I don't understand why you need to install assert, buffer and readable-stream since those are already dependencies of music-metadata-browser. |
Good question, really. I saw the compile sequence complain about missing them, and installed and polyfilled them without thinking about them already being dependencies. |
It it is tricky, I know. I think these polyfill dependencies, which probably prevent music-metadata-browser from working straight away, is the main reason for the larger audience not to use it. |
I have this same problem. I followed these steps, but the error remains. I don't have tsconfig.json, but in my project I have tsconfig.app.json and tsconfig.spec.json. Both I put "paths". And I followed the trick by @wulfsberg as well. Is there more change to do? |
@lucaskawasaki Can you check in your code so I can replicate your issue? |
Thanks for the answer. Well, I followed the steps at https://www.npmjs.com/package/music-metadata-browser First I ran And I tried to run:
So, I changed the:
And changed the polyfills.ts: |
One thing I notice is that you are using es2015 modules, while I use common.js. To clarify the architecture a bit, music-metadata is module written for Node.js. music-metadata-browser aims to adapt/wraps it in a module suitable to be used to be executed in the browser. Typically not directly imported by the browser, but first pre-processed with a module-bundler like webpack, into a single downloadable and optimized JavaScript file. |
I also ran into this problem, however the only way I managed to fix it was by manually changing the reference from Edit: ran into some more issues involving global so I manually changed all references to window and now it's working like a charm. Could you maybe update it eventually? It's quite useful for my project. I'm using Angular 8 |
I think you are referring to line 43 from buffer version 4.3.0, released on 12 Jan 2016, included by webpack/node-libs-browser. As you can see I have already proposed to update assert in that same library, and it seems it is not very likely any change is done. You can find a working Angular 8 sample here. |
@Borewit thanks! I'm sorry I thought it was a problem with your things. Still a beginner to the angular/ts world. |
No problem, those poly-fills are tricky. |
Replacement of issue Borewit/music-metadata#163 from @bfromager:
The text was updated successfully, but these errors were encountered: