Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda