This is what I tried using Node.js nightly download without installing
https://www.reddit.com/r/node/comments/10pnv1p/which_files_in_nodejs_tarball_need_to_be_edited/.
Also got the prompt from esbuild that the fs and http modules were built in
to node executable. I can install Node.js to test if that will change
things. I am trying to bundle
https://nodejs.org/api/https.html#httpscreateserveroptions-requestlistener ;(
https://github.com/nodejs/node/blob/v19.6.0/lib/https.js).
On Fri, Feb 3, 2023 at 5:28 AM Jeremy DeJournett <jcdejournett@xxxxxxxxx>
wrote:
Pranav,
Can you share a minimal example which uses all of the dependencies you
need? That would make it more clear where the parts of this build/patch
process are failing.
Thanks,
Jeremy
On Wed, Feb 1, 2023, 11:55 Pranav Samvith Bharadwaja <pranav@xxxxxxxxxx>
wrote:
Hi Jeremy,
I found your suggestion to use esbuild very helpful. I have spent
days using browserify, rollup etc with partial success, but esbuild
was very painless.
I have applied the sed patches too, as instructed. However the
resulting bundle still doesn't run in qjs. It says
SyntaxError: invalid use of 'super'
at ./commonListener.esbuild.js:5
But there is no super in line 5. line 5 through 10 defines __require
method. I have used --format=esm and --platform=node. Perhaps I should
use --platform=neutral? If i use neutral, then the requires of
'http', 'debug', 'fs', etc. It looks like I will still need to write c
modules for 'fs' and 'net' for qjs.
Thanks.
On Tue, Jan 31, 2023 at 1:24 PM Pranav Samvith Bharadwaja
<pranav@xxxxxxxxxx> wrote:
wrote:
Jeremy, Jerry, guest271314,
Thanks for your inputs.
Jeremy, no I havent tried making esbuild, I will do that. I have
been trying to use browserify and other tools to bundle it all into
one file, since my nodejs app has many dependencies, including
mongoose, socketio and express to name a few. While that is still an
unsolved problem, that is not relevant to quickjs. I am working on
"minor patching" for mongoose to make a bundle that runs on nodejs
without any dependencies. I presume that it will also run on quickjs
if it runs on node (except for fs,path,net etc built-ins being
unavailable, needing more patching to replace with what does exist for
quickjs, as mentioned by guest271314). I did try parcel and rollup but
ran into some issues, I think my best bet is to tweak the source code
of mongoose etc and run browserify. I dont remember if I have tried
esbuild. My codebase uses commonJS requires, not es modules. Again,
bundling, while being a problem, is a different problem, I wouldn't
want to impose it on qjs community.
guest271314, thanks for the resources you have sent in the thread, I
will go through them. The answers you have given very patiently does
reflect that I hadn't done enough research about qjs on github before
asking. I am sorry for that.
I have seen the gwsocket solution, and I think it is good for a work
around. I do need websockets (with socketio wrapping) but it is not a
replacement for raw tcp sockets, but the gwsockets gives me an idea to
find something similar for tcp sockets. perhaps using netcat as a
server to receive tcp connections and invoking that via pipes to qjs
environment. I would still like native support for sockets because if
there are multiple clients to an os.exec("nc",...) invoked server then
i wont be able to maintain states of each client. I would instead like
to implement a c module to be included in the qjs build so that the
qjs runtime and qjsc will have a builtin module for tcp sockets. I
think the quickwebserver will be of help to me in this regard, I will
try to understand how it works and implement a C shared library to
provide tcp socket server and client. Perhaps filesystem ops can also
be done in this way.
It will take me a few days, perhaps weeks to make progress on this,
and i hope the results will be helpful to other people as well. Again,
thanks for pointing me in the right direction.
On Tue, Jan 31, 2023 at 7:45 AM guest271314 <guest271314@xxxxxxxxx>
which I might go about implementing a sockets built-in module for the qjs
If tcp sockets are not implemented at all, is there any way in
engine?
https://github.com/ratboy666/qjs-ws,
There are a few ways to do this. See
https://github.com/QuickJS-Web-project/quickwebserver,
https://github.com/scriptableorg/quickjs-http; et al.
send them to a remote client.
Similarly I would like to implement a way to load local files and
https://github.com/blackgate/qjsWebRtcClient,
You can use WebRTC datachannels.
https://github.com/paullouisageneau/libdatachannel.
there a build option using which I can choose whether to use
This resource also claims that qjs uses select instead of libuv. is
select/poll/epoll or libuv?
application and stream the data to the browser where I write the data to a
See https://github.com/saghul/txiki.js.
I use std.popen() in a QuickJS Native Messaging host to call an
MediaStreamTrackGenerator which can be streamed to other peers using
WebRTC, see
https://github.com/guest271314/captureSystemAudio/blob/master/native_messaging/capture_system_audio/capture_system_audio.js
.
https://github.com/guest271314/native-messaging-espeak-ng/blob/deno-server/deno_server.js
I too am interested in using Deno's listenTls()
in QuickJS - without carrying around the entire V8, et al.
QuickJS.
I'll have a closer look at Calling JavaScript from C/C++ using
jcdejournett@xxxxxxxxx> wrote:
On Mon, Jan 30, 2023 at 3:14 PM Jeremy DeJournett <
patching, you can then compile it to QuickJS bytecode which you can embed
Pranav,
Have you tried building your Node module in esbuild? With some minor
in a native binary alongside the interpreter.
https://github.com/ijustlovemath/jescx/blob/master/README.md
Here's how I did something similar a few months ago:
net and fs objects to the global context, but I found this way to be the
There's a few other ways to do this, including adding your very own
most frictionless.
pranav@xxxxxxxxxx> wrote:
Best,
Jeremy
On Mon, Jan 30, 2023, 10:57 Pranav Samvith Bharadwaja <
https://calbertts.medium.com/how-to-create-asynchronous-apis-for-quickjs-8aca5488bb2e
Update:
I found a resource on medium.
curl command to make a http request. Perhaps the medium resource is missingbut in this resource they use the process module to invoke the
something, or they just decided to use a simple tool (curl) instead of
opening a socket and sending uri and headers?
which I might go about implementing a sockets built-in module for the qjsIf tcp sockets are not implemented at all, is there any way in
engine?
send them to a remote client.Similarly I would like to implement a way to load local files and
is there a build option using which I can choose whether to useThis resource also claims that qjs uses select instead of libuv.
select/poll/epoll or libuv? or would i need to implement that as an option
in the qjs engine code as well? Is select much slower than libuv for an
application that mostly deals with io over tcp sockets and rarely ever
needs to read/write files?
pranav@xxxxxxxxxx> wrote:I would appreciate any advice in this matter.
Thanks,
Pranav
On Mon, Jan 30, 2023 at 12:18 PM Pranav Samvith Bharadwaja <
https://www.freelists.org/post/quickjs-devel/Newbie-Getting-something-like-require-to-work,1
Greetings,
I have seen this mailchain
implemented in qjs. But is there an alternative by which we could createI think it is reasonable that net, fs and path are not
tcp/udp sockets?
edits to some node modules, able to bundle them all into a single fileI am trying to compile a node.js project and with some custom
(because require doesnt work with qjs). A database driver would inevitably
use the net built-in module. If an alternative is available i could make
customization for qjs backend versus pre-existing nodejs. Any help is
appreciated.
--
Thanks and Regards,
Pranav.