Search code examples
javascriptnode.jswebpackelectronflatbuffers

Using multiple js files generated by flatbuffers in electron/webpack


I have a question regarding using code generated for javascript with flatbuffers.

Now I have item.fbs and itemManager.fbs which contains a table including a vector of item.fbs. And it generated 2 js files. When using the itemManager in js, it would throw error of not finding item constructor events.js:163 Uncaught TypeError: my.namespace.Item is not a constructor. I didn' t find any code regarding importing item_generated.js in item_manager_generated.js. I' m wondering how to use it properly in ES6 (with the template of https://github.com/SimulatedGREG/electron-vue) ? Declaring both item and itemManager in a single flatbuffers file and import this file works well.


Solution

  • I workaround this by using the --gen-all flag when using flatc to compile the schema files for now.