petersirka / nosql

NoSQL embedded database for small node.js projects
Other
295 stars 48 forks source link

browserify can not bundle nosql? #43

Closed anlexN closed 6 years ago

anlexN commented 6 years ago
> browserify app/test.js app/bundle.js
Error: Cannot find module './lib/rng' from 'D:\workspace\test\app'
    at C:\Users\demo\AppData\Roaming\npm\node_modules\browserify\node_modules\browser-resolve\node_modules\resolve\lib\async.js:55:21
    at load (C:\Users\demo\AppData\Roaming\npm\node_modules\browserify\node_modules\browser-resolve\node_modules\resolve\lib\async.js:69:43)
    at onex (C:\Users\demo\AppData\Roaming\npm\node_modules\browserify\node_modules\browser-resolve\node_modules\resolve\lib\async.js:92:31)
    at C:\Users\demo\AppData\Roaming\npm\node_modules\browserify\node_modules\browser-resolve\node_modules\resolve\lib\async.js:22:47
    at FSReqWrap.oncomplete (fs.js:166:21)
petersirka commented 6 years ago

Hi @anlexN, there is a problem with no NoSQL embedded. There is missing rng module... what is it?

anlexN commented 6 years ago

I am sorry, i forget broserify -o options

browserify app/test.js -o app/bundle.js

but my bundle.js is wrong:

Database {filename: "./test.nosql", filenameTemp: "./test.nosql-tmp", filenameMeta: "./test.meta", directory: ".", filenameBackup: "test_backup.nosql", …}
Uncaught ReferenceError: setImmediate is not defined
    at Database.one (bundle.js:6195)
    at Database.insert (bundle.js:6036)
    at Object.31.nosql (bundle.js:5912)
    at s (bundle.js:1)
    at e (bundle.js:1)
    at bundle.js:1
Database.one @ bundle.js:6195
Database.insert @ bundle.js:6036
31.nosql @ bundle.js:5912
s @ bundle.js:1
e @ bundle.js:1
(anonymous) @ bundle.js:1

I don't use setImmediate. i follow your nosql document!, and my project code is

const NoSQL = require("nosql");

const db = NoSQL.load("./test.nosql");
console.log(db);

db.insert({ email: 'petersirka@gmail.com' }, true).where('email', 'petersirka@gmail.com');
petersirka commented 6 years ago

Do you know that NoSQL embedded won't work in your browser? It's for Node.js platform only because it's need a direct access to (HDD) disk.

I see a problem in setImmediate --> which version of Node.js do yo use?

A simple fallback for setImmediate:

if (typeof(setImmediate) === 'undefined') {
    global.setImmediate = setTimeout;
    global.clearImmediate = clearTimeout;
}
anlexN commented 6 years ago

i don't know , because your document don't say about this.

node -v v9.5.0

i use your fallback, but problem is still be alive.

const NoSQL = require("nosql");

const db = NoSQL.load("./test.nosql");
console.log(db);

db.insert({ email: 'petersirka@gmail.com' }, true).where('email', 'petersirka@gmail.com');

if (typeof (setImmediate) === 'undefined') {
    global.setImmediate = setTimeout;
    global.clearImmediate = clearTimeout;
}

otherwise, i want to ask nosql is only maintained by totaljs.com engineer?

petersirka commented 6 years ago

Yes, this is good but I think that browserify creates something different. Where/How do you use output from browserify?

i want to ask nosql is only maintained by totaljs.com engineer?

Yes. Is a problem with it?

anlexN commented 6 years ago
  1. i plan to select offline-first database like nosql, to replace indexdb in browser. so browserify , webpack and etc can let me use all npm module in the web browser.
  2. i hope nosql is friendly to the web all thing, not just node.
  3. i think contributors from outside totoljs team, from around the world, nosql can be longer and longer. no matter what future, no matter how much money.
petersirka commented 6 years ago
  1. nice plan
  2. no, it's only for Node.js platform and this is a big problem for you
  3. DB grows up, but nosql is not latest version ... latest version uses Total.js framework and I have a plan to upgrade nosql module.

But as I wrote, it's for Node.js platform only. It's not compatible with web, it's like SQLITE3.

anlexN commented 6 years ago

You number 3, do you mean that only total.js framework can give nosql much and much power? why does team stick to the view that it's for nodejs.? because of there have no some good api in the web?

petersirka commented 6 years ago

Yes and no. Total.js has improved version of NoSQL and at some time I copy all new changes to nosql module. Now nosql module has older version of NoSQL than Total.js.

why does team stick to the view that it's for nodejs?

Because NoSQL embedded works with real files... All data are stored on HDD, therefore is nosql targeted for Node.js platform only.

anlexN commented 6 years ago

understand your any means. but please push integrity nosql module