Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!