Pure JavaScript support for Flatbuffers has been abandoned, and the project website tells you to use transpile from TypeScript.
This is what I tried:
website.fbs.flatc --ts website.fbs to receive website.ts.tsc website.ts to receive website.js.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?
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.