Package nodejs module as a jar - javascript

Most of my projects are built in Java and there was one set of requirement which we created using using NodeJS. Node JS had better options in buiding that utility and that is the reason we went with NodeJS.
Now I want to use that utility in all other java based projects as a dependent jar rather than invoking this Node JS service.
Is it possible to bundle this Node JS module into a jar and add it as a dependency in other java projects?

Related

Can we use angular without node?

We are working with Django as a server framework and used JavaScript for client-side scripting. Now we are migrating to Angular4, do we need to run a node.js server with the existing running Django server?
No, Angular is basically concerned with your front-end in your case, you don't need to use Node together with Django for your back-end.
However, what you would need node for is the build process and dependencies, as Node helps in the building process of your Angular project and in the management of your dependencies, this is facilitated also with NPM.
Apart from that, Node also allows you use the port:4200 when serving using ng serve.... Once your project passes the development stage and you have a dist folder, you don't need the ng serve process anymore and the files within the folder are static and can be run like your normal index.html files...
I do hope this is helpful.
Angular is for your front-end. You can use what you want for the back-end.
You can use Node to build your sources, to convert typescript files to javascript files.

package and distribute JavaScript library such that it can be imported as a script or as a npm module

I am amateur in using JavaScript, and trying to develop a utility which is dependent on a JS SDK. I want to use npm and create this utility code such that I create a new npm module - so that others can use in there npm project and frameworks like react, angular etc
and I also want to package it and minify with its dependent SDK - so that developer can use the same library using a script tag as well.
So please guide me or refer me some resources online which can explain me this 2 things in a clean manner.

Example of kotlin project with shared module for js

Since 1.1 Kotlin has support for compiling code to JS. I want to find example of gradle project how to share some code (for example data-models) between js and jvm platforms. Ideally project should have this structure:
common module (compiles to .js and .class)
backend module (jvm)
frontend module (js, managed by webpack)

Running node.js code in Excel user-defined function

It would be nice if one can run node.js code inside Excel user-defined functions. Something like using js code like VBA.
I googled for solutions but cannot find any. Is it possible to do this?
Yes, if you want to use packages from NPM. You could use webpack to combine all the stuff to one js file, it should work.
webpack as a static module bundler for modern JavaScript applications. When webpack processes your application, it internally builds a dependency graph which maps every module your project needs and generates one or more bundles. you could refers to this document.
You could also refer to a sample, Yeoman, the Yeoman generator creates a Node.js Office Add-in project. it use webpack combine all files into one js file.

How do I reference a js file from a node module in HTML?

I've used JetBrains WebStorm to create a Node.js Express App. I used npm (via File->Settings->Node.js and NPM) to install a package called validator which is used for string validation.
The package was installed under node_modules, which is fine. If I do var validator = require('validator'); in my server code, I can use the validation functions successfully.
The problem is that I would also like to use validator in client JavaScript. I can include the script like this:
<script src="/javascripts/xss-filters.min.js"></script>
But that means I have to copy xss-filters.min.js from the node_modules folder into the public javascripts folder. Then, if I ever update the package with npm, the files will be out of sync.
Is there some way to reference node_modules from my view, or to create some sort of linked file or file reference or something? I'd rather not have to maintain this manually.
you should consider using browserify, which allows you to require modules in the browser by building all the dependencies. so basically you code like you would do in server side http://browserify.org
You can done it by using another node.js module, called node-browserify
how to use node.js module system on the clientside
You can try to use bower, or yeoman.
bower - will simplify the process to include js libs.
yeoman - will help you to build projects with the the libraries that you need.

Categories