i'm trying to import the sqlite3 library within a web worker using RequireJS, i'm using this library of sqlite3:
https://github.com/mapbox/node-sqlite3
i use this code, but doesn't work:
importScripts("../node_modules/requirejs/require.js");
console.log("before require");
require(
{baseUrl:"/home/pi/node_modules/"},
["sqlite3"], function(sqlite3)
{
console.log("before db creation");
this.db = new sqlite3.Database('MyDB.db');
console.log("after db creation");
}
);
this.onmessage = function(event) {
...
};
i create the web worker in this way:
var Worker = require('webworker-threads').Worker;
var worker= new Worker('myworker.js');
the result of the console log is this:
before require
and doesn't print anything else, how i can solve the problem?