PouchDB custom build #4449

Closed
nolanlawson opened this Issue Oct 10, 2015 · 8 comments

Comments

Projects
None yet
4 participants
@nolanlawson
Member

nolanlawson commented Oct 10, 2015

I think our build has gotten a bit too big (~47KB). There's nothing we can reasonably remove without removing serious functionality, though.

So I would like to create a custom build. You should be able to build a PouchDB that is missing:

  • idb
  • websql
  • migrations
  • http
  • sync/replicate
  • mapreduce

I think this is technically possible both with a browserifable script and a web UI builder. So the web UI builder would both allow you to download a file and display a browserifiable file that would probably look like this:

var PouchDB = require('pouchdb/custom/pouchdb');
require('pouchdb/custom/idb');
// no websql
require('pouchdb/custom/mapreduce');
// no http
// no migrations
// no replicate/sync
module.exports = PouchDB;

I'll take a stab at it this weekend.

@nickcolley

This comment has been minimized.

Show comment
Hide comment
@nickcolley

nickcolley Oct 10, 2015

Member

We could think about #4199 alongside this.

Member

nickcolley commented Oct 10, 2015

We could think about #4199 alongside this.

nolanlawson added a commit that referenced this issue Oct 10, 2015

nolanlawson added a commit that referenced this issue Oct 11, 2015

nolanlawson added a commit that referenced this issue Oct 11, 2015

@daleharvey

This comment has been minimized.

Show comment
Hide comment
@daleharvey

daleharvey Oct 12, 2015

Member

So I think a custom build is a nice thing to offer to users, however I do not think it is a solution for having to large a distribution. I would still like to make sure we have a "this is pouchdb" distribution that has sensible defaults for most users while being as small as possible.

Member

daleharvey commented Oct 12, 2015

So I think a custom build is a nice thing to offer to users, however I do not think it is a solution for having to large a distribution. I would still like to make sure we have a "this is pouchdb" distribution that has sensible defaults for most users while being as small as possible.

@nolanlawson

This comment has been minimized.

Show comment
Hide comment
@nolanlawson

nolanlawson Oct 12, 2015

Member

I wish we could make it smaller, but aside from removing stuff for edge cases (vuvuzela, websql, blob shims), the only big win I see would be from using rollup, which means switching to ES6 modules: https://github.com/nolanlawson/rollup-comparison.

I consider this more of a stopgap while our build is too big; also a good transitional step. E.g. when we drop WebSQL support, that will just mean that the "this is pouchdb" distribution will lose the "require websql" line from its custom build.

Member

nolanlawson commented Oct 12, 2015

I wish we could make it smaller, but aside from removing stuff for edge cases (vuvuzela, websql, blob shims), the only big win I see would be from using rollup, which means switching to ES6 modules: https://github.com/nolanlawson/rollup-comparison.

I consider this more of a stopgap while our build is too big; also a good transitional step. E.g. when we drop WebSQL support, that will just mean that the "this is pouchdb" distribution will lose the "require websql" line from its custom build.

nolanlawson added a commit that referenced this issue Oct 13, 2015

@nolanlawson

This comment has been minimized.

Show comment
Hide comment
@nolanlawson

nolanlawson Jan 1, 2016

Member

Just investigated, and unfortunately Rollup and tree-shaking don't help us out much here: https://github.com/nolanlawson/test-tree-shaking

I think the best solution is to basically ask users to write their own index.js and exclude what they don't want. It's the simplest to support.

Member

nolanlawson commented Jan 1, 2016

Just investigated, and unfortunately Rollup and tree-shaking don't help us out much here: https://github.com/nolanlawson/test-tree-shaking

I think the best solution is to basically ask users to write their own index.js and exclude what they don't want. It's the simplest to support.

@nickcolley

This comment has been minimized.

Show comment
Hide comment
@nickcolley

nickcolley Jan 25, 2016

Member

👍 for having our normal builds plus the instructions to build their one index.js

Member

nickcolley commented Jan 25, 2016

👍 for having our normal builds plus the instructions to build their one index.js

@kidwm

This comment has been minimized.

Show comment
Hide comment
@kidwm

kidwm Feb 12, 2016

@nolanlawson is it possible to release an ES Modules build like Redux did ?
BTW, I tried to bundle my pouchdb app but always failed with these setting:

plugins: [
        babel({
            "presets": ["es2015-rollup"]
        }),
        nodeResolve({
            jsnext: true,
            main: true
        }),
        commonjs({
            include: 'node_modules/**'
        })
    ]

kidwm commented Feb 12, 2016

@nolanlawson is it possible to release an ES Modules build like Redux did ?
BTW, I tried to bundle my pouchdb app but always failed with these setting:

plugins: [
        babel({
            "presets": ["es2015-rollup"]
        }),
        nodeResolve({
            jsnext: true,
            main: true
        }),
        commonjs({
            include: 'node_modules/**'
        })
    ]
@nolanlawson

This comment has been minimized.

Show comment
Hide comment
@nolanlawson

nolanlawson Feb 13, 2016

Member

It's unfortunately not possible because the PouchDB object is a non-static object. ES6 module tree-shaking works best for static functions.

Member

nolanlawson commented Feb 13, 2016

It's unfortunately not possible because the PouchDB object is a non-static object. ES6 module tree-shaking works best for static functions.

@daleharvey

This comment has been minimized.

Show comment
Hide comment
@daleharvey

daleharvey May 10, 2016

Member

Dupe of #5128

Member

daleharvey commented May 10, 2016

Dupe of #5128

@daleharvey daleharvey closed this May 10, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment