New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: monorepo package names and plugin format #5162
Comments
|
This is really exciting seeing it all laid out, definitely going to be a great addition.
import PouchDB from '@pouchdb/core';
import IDBPouch from '@pouchdb/plugin-adapter-indexeddb';
import FooBarPouch from 'pouchdb-plugin-foobar';
PouchDB.plugin(IDBPouch);
PouchDB.plugin(FooBarPouch);
export default PouchDB; So maybe a little asymmetry but I don't think it's an issue? 3 . I like the simplicity for the plugin API, I'd have thought it'd enable lazy-loading down the line too? |
@geppy How about if PouchDB.plugin(foo)
.plugin(bar)
.plugin(baz); |
@nolanlawson I think that'd be great. |
@NickColley The asymmetry is desired. As for lazy-loading, yes, you should be able to trigger-load a plugin. Also I just realized the plugin API actually already does support chaining; we just didn't document it. 😅 |
Counterargument against private modules: it sure feels more natural to |
In fact the more I think about it, the more I can't get over how ugly and hard-to-type those private modules are. Just try saying them aloud. 😛 It's worth pointing out that Lerna is working on adding the ability to manage all npm owners across multiple packages, which would also limit the benefit of having "one" account - which at this point is also still a user rather than an organization, meaning you'll have to change your npm credentials when you publish. Hm, that kinda stinks. I feel like I'm leaning toward prefixes rather than private modules now. |
To me shorter names are better. Can you cut the |
And add a |
I was planning on making this a community thing. There are many combinations I can think of (http with mapreduce, http without mapreduce, websql only, etc.), so I think it's best to take the stand not to support them at all. It will be like 4 lines of code to write your own. :) The reason
The adapters are also plugins; you load them by doing |
HTTP-only is a very common use case. I've got several apps that only fetch data from a remote database. For the amount we can reduce the file size, I think this is well worth having official support. I'm for 3 official presets:
|
For ease of loading plugins, how about: |
Hm, how about the name I feel like PouchDB.plugin(IDBPouch)
.plugin(WebSqlPouch)
.plugin(HttpPouch)
.plugin(mapreduce)
.plugin(replication); |
I agree with this, its a fairly minor details but if every adapter is a plugin I dont think we need the extra prefix.
If its backwards compatible and allows adapters to be installed via it, it looks great to me.
So I dont have much of a preference vs either, but I do think we should be making a distinction between packages designed specifically for user consumption ( |
OK, I'm fine with cutting the For the "internal" modules, I'd rather not have a mix of scoped and non-scoped, so maybe we can just not document them and set the SemVer to 0.0.x? We've already been effectively publishing lots of these things ( BTW I've opened up a vote for scoped vs prefixed, so let's move that discussion over here: #5165 |
Making it possible for plugins to act immediately on the PouchDB object is a very nice extension, in the past some 3rd-party plugins have struggled with that too (e.g. pouchdb-all-dbs, pouchdb-seamless-auth). Chaining As for package naming, no strong opinions there. |
'Nother question... do we even want the
I kind of like just keeping it simple. The READMEs can explain what exactly the modules do. |
I like it, this would also mean less package names would have to be deprecated, which could prevent some confusion. (e.g. no pouchdb-mapreduce -> pouchdb-plugin-mapreduce). Furthermore, since all would use the same API to 'register' anyway ( That said, names do matter to keep track of things. 'adapter' definitely makes things clearer, 'preset-' might as well (uncertain there). |
Not everything would register via The only reason I'm unsure about
|
I prefer As for versioning, we do the |
I am for the prefix style. Will vote. Also perhaps adopt a ember-addon like keyword in package.json
It will make it possible to find them after we have created 2000 addons just like https://www.emberaddons.com/ ;-) |
@broerse That's a good idea; we really should have done that years ago before people started writing plugins though. 😅 I can do @daleharvey No worries, it'll be called |
Closing because this seems more-or-less decided, please move discussion over to #5178. |
(Previous discussion: #5137 #5128)
TLDR: I have three questions for the community:
@pouchdb/
orpouchdb-
prefixes for package names?Private modules vs prefixes
When we publish the monorepo packages, we'll have a choice between the prefix style used by Babel, React, and Ember:
pouchdb-foo
pouchdb-bar
And the "private module" pattern, which is a bit new, but is being used by Angular 2 and Hoodie at least:
@pouchdb/foo
@pouchdb/bar
Each one has benefits and detriments. There is some discussion in this Twitter thread. So question one is whether we go with the private module style or the prefix style.
(I've already registered a npm user named
pouchdb
, which we can apparently upgrade to an organization once organizations are free for open-source.)Package naming conventions
Second question is what to name the modules. I propose the following:
pouchdb
@pouchdb/core
@pouchdb/plugin-mapreduce
@pouchdb/plugin-replication
@pouchdb/plugin-adapter-indexeddb
@pouchdb/plugin-adapter-websql
@pouchdb/plugin-adapter-node-websql
@pouchdb/plugin-adapter-leveldb
@pouchdb/plugin-adapter-memory
@pouchdb/plugin-adapter-localstorage
@pouchdb/plugin-adapter-fruitdown
@pouchdb/preset-browser
@pouchdb/preset-node
@pouchdb/ajax
@pouchdb/generate-replication-id
@pouchdb/checkpointer
@pouchdb/promise
Notice the
plugin-
prefix for plugins,plugin-adapter
prefix for adapters (which are also plugins), and thepreset-
prefix for the "Node version" of PouchDB and the "browser version" of PouchDB. What we used to call "extras" have no prefix. (But maybe they should?)There are also an odds-and-ends modules like
@pouchdb/utils
and@pouchdb/errors
that are mostly grab-bags of different utilities used across the whole codebase. I propose marking these as0.0.x
so we don't need to make any claims for SemVer. Also I think it's pointless to document them, except maybe with a README.New plugin API
In order to enable modules like replication and the adapters to be used as "plugins," I propose adding one new feature to the
PouchDB.plugin()
API: in addition to passing in an object, you can pass in a function that is given thePouchDB
object, and therefore you can do what you want with it. This is useful for adapters:And e.g. replication:
The end result is that we have a nice clean plugin API that hides internal details like the
PouchDB.adapter
API. It also allows things like the http adapter adding both'http'
and'https
', the replication plugin addingPouchDB.replicate
andPouchDB.sync
, and third-party plugins that might bundle multiple plugins together.Here's a full example of what
@pouchdb/preset-browser
would look like:Thanks for your feedback! :) Everything is working pretty well technically right now; I just want to make sure we can reach a consensus on naming convention, style, etc.
The text was updated successfully, but these errors were encountered: