You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Mario Emmenlauer <ma...@emmenlauer.de> on 2019/11/03 11:38:59 UTC

Re: Errors when using browser.js (browserify)

I'm answering my own thread here for reference to other users.
After much try and error, I could find a way to package thrift
nodejs with webpack. I've  compiled a full example of a browser
client with C++ server here on github:
     https://github.com/BioDataAnalysis/thrift-nodejs-browser

For me, things started working when I generated sources as 'js:node'
with the thrift compiler, and I included the 'browser.js' in the
webpack source file 'src/index.js':

     var thrift = require('thrift/lib/nodejs/lib/thrift/browser');

I'm not certain that this is the best or cleanest way. I've found
an example from HIRANO Satoshi that suggested the simpler include:

     var thrift = require('thrift/browser');

which I did not try yet. Feedback is welcome. Also, anyone please
feel free to disseminate my findings to the larger community!

Last, not least, the binary protocol did not *yet* work for me.
This is summarized in https://issues.apache.org/jira/browse/THRIFT-4987
and may be either a problem on my side or a bug in the current
thrift nodejs implementation.

All the best,

     Mario



On 24.10.19 11:49, Mario Emmenlauer wrote:
> 
> I've tried to use thrift/lib/nodejs/lib/thrift/browser.js to create
> a browser client with buffered transport and binary protocol. With
> browserify I can package browser.js, but I do not understand how it
> is supposed to work with the generated files, and the client.
> 
> Should the thrift-compiler-generated files be js or nodejs for this?
> Do they also need to be browserify-ed? And should the client be
> instantiated in js syntax or nodejs syntax in the browser html?
> 
> Currently I just get errors "Thrift undefined" when using the
> browserify-ed browser.js in the browser.
> 
> All the best,
> 
>      Mario Emmenlauer
>