Borewit / music-metadata-browser

Browser version of music-metadata parser Supporting a wide range of audio and tag formats.
MIT License
240 stars 21 forks source link

Polyfill required with Vite 4 - Buffer is not defined #952

Closed not-matt closed 4 months ago

not-matt commented 6 months ago

Thanks for your work on this library. This isn't necessarily an issue with this library but worth documenting.

Leaving this here in case it helps anyone in future.

ReferenceError: Buffer is not defined
    MpegParser MpegParser.js:218

To fix, I used vite-plugin-node-polyfills

My vite config:

import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { nodePolyfills } from "vite-plugin-node-polyfills";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [nodePolyfills(), svelte()],

  resolve: {
    alias: {
      src: "/src"
    }
  }
});
Borewit commented 4 months ago

Maybe get rid of Buffer Borewit/token-types#650

Duplicate of #417, and probably many more complains about difficulties poly-filling Node Buffer

Borewit commented 4 months ago

You may try music-metadata ≥ 9 , which is guaranteed Buffer free.