Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to port NodeJs Module to XSJSLib?

Hi!

I'm not a Javascript Guru but I already realized that XS could benefit from importing NodeJs modules.

I want to use a node module called "schema-inspector" in a XSJS file I'm developing but actually this question applies for any nodejs module.

There is no 'require' or 'module' namespace on XSJS (at least yet) so I **think** that it's not possible to port a Node module without adjusting its code (mainly the exports part). Am I right?

I know Jasmine was ported to a XSJSLib on SPS 09  and comparing Jasmine version 2.0 with core2.xsjslib file from testtools package it seems SAP developers had a lot of work to make this works.

If there is no easy way to port it, I'm thinking about changing the module and actually creating its "core" object inside the $ namespace. Is this the "right" or at least the good way of doing this? Of course the module extension will have to be renamed to xsjslib.

Rumor has it a future SPS of Hana will have support to NodeJS... is this true? While I'm on SPS 9, what should I do?

Thanks!

Tags:
replied

Yes we are working on NodeJS support as we speak. We already have internal builds running NodeJS. That said, this is a forward facing, roadmap comment and comes with all the legal disclaimers. If everything goes as planned we hope to introduce NodeJS support with SPS 11 at the end of this calendar year. Then you will be able to use require to directly use NodeJS modules.


Until then porting an existing module is difficult to estimate.  It ranges from a lot of basic work to maybe impossible.  NodeJS runs on Google V8 which has some non-standard JavaScript extensions.  Current XSJS runs on Mozilla SpiderMonkey. Its possible that you hit something in the library that uses one of these extensions and isn't portable.

5 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question