Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

packaging a nodejs c++ shared lib

I made a nodejs shared library and now I want to package it in order to deploy it. I would like being able to use it with angular 2 application packaged thanks to webpack.

the shared lib is located in a folder build/Release.

how to proceed to package it nicely in webpack ? or is it a particular package.json declaration ?

having a look at nodejs documentation, dll names are using extension .node (https://nodejs.org/api/addons.html#addons_loading_addons_using_require)

webpack node-loader may help ? https://webpack.js.org/loaders/node-loader/

I will use server side rendering , otherwise that won't be possible.

Regards, Steph

like image 273
sancelot Avatar asked Jul 24 '17 08:07

sancelot


1 Answers

using node-loader or node-native-loader, it does not want to load the node module . in webpack.config.js , I have added next rules :

"rules": [
  {
    "test": /\.node$/,
    "loader": "node-native-loader?from=app"
  },

results in : Cannot find module './control.node'.

like image 181
sancelot Avatar answered Oct 23 '22 12:10

sancelot