twister-lib.js

62 views
Skip to first unread message

JM

unread,
Sep 9, 2016, 4:19:26 PM9/9/16
to twister-dev
Am I right in understand that "twister-lib.js" is the browserify-d version of src/*  ?   But doesn't include anything from the node_modules?


Julian Steinwachs

unread,
Sep 10, 2016, 1:16:10 AM9/10/16
to twist...@googlegroups.com

No, the twister-lib.js file contains all needed node_modules. the one in the git-repo starts with the bencode package for example: https://raw.githubusercontent.com/Tschaul/twister-lib-js/master/twister-lib.js . Are you trying to use another module loader on top like webpack or systemJS? This second bread of module loaders (AMD-module loaders) was not around at the time i did the setup. I can imagine that they are incompatible.

I setup a test site at https://twister-proxy.tschaul.com/test.html where there is only the twister-lib.js files included. If you put e.g. Twister.getUser("tschaul").doProfile(x=>console.log(x.getAllFields())) into the console you should get my profile information pulled down. Maybe you can work your way back from there.

Also, do you have your source code public somewhere, that i could help you better.

Greetings

Tschaul


On 09.09.2016 22:19, JM wrote:
Am I right in understand that "twister-lib.js" is the browserify-d version of src/*  ?   But doesn't include anything from the node_modules?


--
You received this message because you are subscribed to the Google Groups "twister-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to twister-dev...@googlegroups.com.
To post to this group, send email to twist...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JM

unread,
Sep 12, 2016, 3:11:07 PM9/12/16
to twister-dev, julian.s...@fau.de, julian.s...@mail.de
Thanks for the input.  I don't have my code anywhere yet because I've really just been testing.  I have sample code from the examples etc pulling from my server that work fine with node.

What I am trying to do is to isolate all the requirements to run even just one example outside of nodejs or webpack etc.  For example, even with twister-lib.js, the src/* directory, and the examples, there are still missing dependencies. e.g. It is relying on node for more that are not included in twister-lib.js.

I can get around the need for nodejs "require", but it is still missing dependencies like httprequest.   e.g. I am getting a:
Exception: TypeError: undefined is not a constructor (evaluating 'new global.XMLHttpRequest()')

Maybe I am missing something and all the dependencies are included, but isn't the request wrapper in there still dependent on the nodejs request module for example?  (and the request module's dependencies)?

JM

unread,
Sep 13, 2016, 9:52:46 AM9/13/16
to twister-dev, julian.s...@fau.de, julian.s...@mail.de
Thanks for the link to that site.  I did check out the https://twister-proxy.tschaul.com/test.html site, but on both Firefox and Chrome (both current versions) it is throwing an exception, in case you didn't see:


  1. DOMException: Failed to execute 'querySelectorAll' on 'Element': '*,:x' is not a valid selector. at Error (native) at https://twister-proxy.tschaul.com/build/jquery.min.js:2:10456 at ja (https://twister-proxy.tschaul.com/build/jquery.min.js:2:7344) at ga.setDocument (https://twister-proxy.tschaul.com/build/jquery.min.js:2:10194) at https://twister-proxy.tschaul.com/build/jquery.min.js:2:21790 at https://twister-proxy.tschaul.com/build/jquery.min.js:2:22510 at https://twister-proxy.tschaul.com/build/jquery.min.js:2:207 at https://twister-proxy.tschaul.com/build/jquery.min.js:2:212
    1. code:12
    2. message:"Failed to execute 'querySelectorAll' on 'Element': '*,:x' is not a valid selector."
    3. name:"SyntaxError"
    4. stack:"Error: Failed to execute 'querySelectorAll' on 'Element': '*,:x' is not a valid selector.↵ at Error (native)↵ at https://twister-proxy.tschaul.com/build/jquery.min.js:2:10456↵ at ja (https://twister-proxy.tschaul.com/build/jquery.min.js:2:7344)↵ at ga.setDocument (https://twister-proxy.tschaul.com/build/jquery.min.js:2:10194)↵ at https://twister-proxy.tschaul.com/build/jquery.min.js:2:21790↵ at https://twister-proxy.tschaul.com/build/jquery.min.js:2:22510↵ at https://twister-proxy.tschaul.com/build/jquery.min.js:2:207↵ at https://twister-proxy.tschaul.com/build/jquery.min.js:2:212"
    5. __proto__:DOMException

Likewise in the Chrome console:
> Twister.getUser("tschaul").doProfile(x=>console.log(x.getAllFields())) 
VM278:1 Uncaught ReferenceError: Twister is not defined(…)(anonymous function) @ VM278:1(anonymous function) @ jquery.min.js:2ja @ jquery.min.js:2ga.setDocument @ jquery.min.js:2(anonymous function) @ jquery.min.js:2(anonymous function) @ jquery.min.js:2(anonymous function) @ jquery.min.js:2(anonymous function) @ jquery.min.js:2



On Saturday, September 10, 2016 at 1:16:10 AM UTC-4, Julian Steinwachs wrote:
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

JM

unread,
Nov 1, 2016, 11:07:15 AM11/1/16
to twister-dev
I am back looking at this again.  I guess my real question was which modules are not included in the browserify bundle, but would be handled in the browser or node.  For example, there are modules built into node.js that I don't think are in the browserify bundle.  In short, I'm trying to figure out what are the external dependencies in there?  If I use 
npm-remote-ls twister-lib-js
or (on my local test project)
npm ll


then it appears that it is at minimum there are dependencies that which don't seem to get browserify-d in there:
buffer
crypto
punycode

As far as request goes, maybe it is included, but I am not sure.

crypto-browserify is included in some spots, but so is just crypto.  Ditto buffer is missing if you try to run it outside a real browser or node.

I think having the code with clear module dependencies / clear external APIs are required is important and it is pretty close, but I can't find the last few missing items.  ;-)

I hope this is making sense

Thanks!

JM

unread,
Nov 1, 2016, 11:14:02 AM11/1/16
to twister-dev
e.g.  If you wanted to run it in JSC, clearly the builtin required node modules aren't there and it doesn't look like browserify is getting them all in there.

1776

unread,
Dec 6, 2018, 11:22:52 AM12/6/18
to twister-dev
Hi Julian,
Have you done any work on twister-react recently?  Or twister-js-lib?

Cheers!

Julian Steinwachs

unread,
Dec 6, 2018, 12:45:29 PM12/6/18
to twist...@googlegroups.com

No, both repos are resting since 3 years.

Greetings

Reply all
Reply to author
Forward
0 new messages