CRUD.js icon indicating copy to clipboard operation
CRUD.js copied to clipboard

The Database object does not seem to be exported correctly

Open davidpaulsson opened this issue 8 years ago • 4 comments

When I try to use the lib I only get a Uncaught ReferenceError: Database is not defined.

Here's a pen to illustrate where I've inlined your script and then added the example from the README. http://codepen.io/davidpaulsson/pen/KdJJGQ

davidpaulsson avatar Nov 18 '15 06:11 davidpaulsson

I discussed this with @valeriangalliat last night and his advice would be to use CRUD.js in a file, the usual, and then browserify than file in a single bundle that should be included in a page. The reason behind this is that in theory, browserify is not supposed to define globals.

KittyGiraudel avatar Nov 18 '15 08:11 KittyGiraudel

So for a project that does not have a browserify build step, CRUD.js is out of the question?

davidpaulsson avatar Nov 18 '15 09:11 davidpaulsson

Not entirely sure to be honest. Maybe let’s hear from @valeriangalliat when he’s up. :)

KittyGiraudel avatar Nov 18 '15 09:11 KittyGiraudel

in theory, browserify is not supposed to define globals.

I mean, I wouldn't be surprised if Browserify had an option to export a module as a global in the bundle. But the way I've always used Browserify was by having my own main.js requiring other modules. This way I bundle my main.js and everything comes packaged and self contained without any global.

We could look at how WebTorrent handles this, since they use Browserify and still provide a standalone file defining a global for users not willing to use Browserify. Looks like this command is doing the magic.

So that's the thing you want to add to CRUD.js to support exporting a global. But yep I believe the current dist/CRUD.min.js is useless right now since not exposing anything.

valeriangalliat avatar Nov 18 '15 13:11 valeriangalliat