Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
How to use Flatbuffers with JavaScript in the browser?

Pure JavaScript support for Flatbuffers has been abandoned, and the project website tells you to use transpile from TypeScript.

This is what I tried:

  1. Write a Flatbuffers file website.fbs.
  2. Run flatc --ts website.fbs to receive website.ts.
  3. Run tsc website.ts to receive website.js.
  4. Run browserify website.js -o website.browser.js to receive a file which I can include with <script src="website.browser.js"></script>.

But console.log(Website) tells me there is no Website object.

What is the correct path to use Flatbuffers with JavaScript in the browser?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The problem is that browserify does not export to global namespace (window) by default. By supplying the -s parameter to browserify you can get it to export to a global symbol:

browserify website.js -o website.browser.js -s website

After that you should be able to find window.website with the same API as before with the old direct to js code generator.

Or, in my opinion, the better option is to use a more modern bundler (Rollup, Parcel, esbuild, Webpack etc.) and have it bundle the generated ts (or js) together with your application in a single step so that you do not need to use the global namespace at all. That would also allow for more efficient and small code, better IDE support and probably some other benefits.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda