pouchdb: WebPack related error: LevelUp package.json produces errors

When packaging PouchDB in an app with WebPack, the following error gets output. The current PouchDB npm release doesn’t build because of a bug recently fixed (see #3287). The current github master allows it to proceed but it then hits the error below.

Unless I’m mistaken LevelUP shouldn’t be required in the client? Can it be left out of the package altogether in a similar manor to the fix for #3287 ?

Is it ok to just add levelup: false to the browser section of package.json or should it be replaced with a browser compatible module?

ERROR in ./~/pouchdb/~/levelup/package.json
Module parse failed: /Volumes/Files/Projects/Harvest/app2/node_modules/pouchdb/node_modules/levelup/package.json Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
|   "name": "levelup",
|   "description": "Fast & simple storage - a Node.js-style LevelDB wrapper",
|   "version": "0.18.6",
 @ ./~/pouchdb/~/levelup/lib/util.js 102:30-56

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 23 (16 by maintainers)

Commits related to this issue

Most upvoted comments

For posterity, webpack users, do:

module: {
    loaders: [
        // https://github.com/pouchdb/pouchdb/issues/3319
        {
            test: /\.json$/,
            loader: "json-loader"
        }
    ]
}

Those steps get it working for me, but it still seems to be including a ton of stuff it doesn’t need.

var PouchDb = require('pouchdb/dist/pouchdb');

generates the same warning @timcash mentioned above, but shaves ~300K off the unminified bundle for me.

Here’s what needs to be done (in webpack’s config), to get it working with pouchdb:

  module: {
    loaders: [{
      test: /\.json$/,
      loader: 'json'
    },
    {
      test: /\.j(s|sx)$/,
      loader: 'react-hot!es6-loader!jsx-loader?harmony',
      exclude: /node_modules/
    }],
    noParse: /lie.js/
  },

also, you should work from master, it contains the additional fix.

not sure we can straight use levelup: false but it may be that we only need to switch leveldown in browserify and turning levelup off will be fine

perhaps that might be something we’d want to look at as well.