beakerbrowser / webdb

The Web is your database.

Home Page:https://www.npmjs.com/package/@beaker/webdb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

required is not defined

arni077 opened this issue · comments

const WebDB = require('@beaker/webdb')
var webdb = new WebDB('webdb-example')

when i try to instansiate webdb inside an async function in order to use it like it is written in the example you published here, the debugger responds with: require is not defined. what i'm doing wrong here?

Do i have to import module.js ?
or how to import browserify?

Hey @arni077

If you're using in Beaker, you do need to bundle the code (for now). This tutorial may be helpful: https://writingjavascript.org/posts/introduction-to-browserify

Sounds like a great reason to publish WebDB on Dat for es6 imports. :P

Was just thinking that :)

@pfrazee

const WebDB = require('@beaker/webdb')
Do i need to import this module (@beaker/webdb) ?or is it a built-in which i can require freely?

@arni077 It's a module published on npm (https://www.npmjs.com/package/@beaker/webdb). You have to npm install it and then bundle it using browserify (what I linked above).

After I wrote WebDB, beaker got native support for modules. @RangerMauve was suggesting that we switch to that to make life easier, and I agree, but that'll be a future task