journeyapps / node-sqlcipher

SQLCipher bindings for Node
https://journeyapps.com
BSD 3-Clause "New" or "Revised" License
206 stars 66 forks source link

Webpack node-sqlcipher #62

Open nimeshkan opened 3 years ago

nimeshkan commented 3 years ago

I tried to add to mozilla-iot code , @ry @journeyapps/sqlcipher gateway/build/webpack:/src/sqlcipher/lib sync:2 var e = new Error("Cannot find module '" + req + "'"); ^ Error: Cannot find module gateway/src/sqlcipher/lib/binding/napi-v6-linux-x64/node_sqlite3.node' at webpackEmptyContext (gateway/build/webpack:/src/sqlcipher/lib sync:2:1) at Object. (gateway/build/webpack:/src/sqlcipher/lib/sqlite3-binding.js:4:15) at Object../src/sqlcipher/lib/sqlite3-binding.js gateway/build/gateway.js:17792:30) at webpack_require (/gateway/build/webpack:/webpack/bootstrap:19:1) at Object../src/sqlcipher/lib/sqlite3.js (gateway/build/webpack:/src/sqlcipher/lib/sqlite3.js:2:15) at webpack_require (/home/nimesh/workspace/XERUS/HUB/Sriharsha-alert/gateway/build/webpack:/webpack/bootstrap:19:1) at Object../src/sqlcipher/sqlite3.js (gateway/build/webpack:/src/sqlcipher/sqlite3.js:1:18) at webpack_require (gateway/build/webpack:/webpack/bootstrap:19:1) at Object../src/db.js gateway/build/webpack:/src/db.js:15:19) at webpack_require (gateway/build/webpack:/webpack/bootstrap:19:1)

rkistner commented 3 years ago

Native node modules are in general not well suited for webpack.

You should be able to exclude it from bundling by using externals, for example:

module.exports = {
  // ...
  externals: {
    '@journeyapps/sqlcipher': 'commonjs2 @journeyapps/sqlcipher',
  }
};

(not tested, and will depend on your specific setup)