cancel
Showing results for 
Search instead for 
Did you mean: 

How to port NodeJs Module to XSJSLib?

FabioPagoti
Active Contributor
0 Kudos

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!

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

Hi Fabio,

regarding the rumor of HANA and NodeJS, you can watch the week 3 last unit video of the openSAP course Software Development on SAP HANA (Delta SPS 09) - Thomas Jung and Rich Heilman. In that video Thomas Jung and Rich Heilman taking about some things discussed to be supported in future within HANA. One topic is NodeJS. Ok, it is no full official statement that it will be supported definitely with one of the future support packages, but I think the chance is more than good .

Should you port it. I think this is a question of your personal motivation. Depending on that how many dependencies exist to other NodeJS libs, this can maybe result in an "endless" story. But this "negative" statement from me should not hinder you to try it.

Best Regards,

Florian

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

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.

0 Kudos

Great, waiting for NodeJS,  is there any environment available to test NodeJS support?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Well it isn't released for customers/partners yet; so no public test. But I see from your profile that you are listed as working for SAP.  XS Advanced is part of internal Orange builds.  Download it (or access it on Monsoon) and give it a spin.

Answers (1)

Answers (1)

FabioPagoti
Active Contributor
0 Kudos

Thanks and .

I hadn't realize how much trouble I could have with dependencies.. I guess by the time I would have finished porting the modules SPS 11 would already be available.

Even though this node module has "only" one dependency, it might have some V8 dependent feature... which makes this task not worth the effort.

Thanks a lot guys! It's unfortunate that this won't be on SPS 10 but it's awesome to now this future is so near according to the plan.