-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Issue with adapter pouchdb-adapter-idb on dev vs production builds #2798
Comments
Can you paste the code where you import rxdb and the plugins? |
So, reading the docs, I see it's related to https://rxdb.info/custom-build.html. I am a little confused by the docs and think they could use some modification. On the install page it says to use: import {
createRxDatabase,
RxDatabase
/* ... */
} from 'rxdb'; On the custom build page it says:
But I don't know what I am doing this: import {
addRxPlugin,
createRxDatabase,
RxDatabase,
RxDocument,
RxCollection,
} from 'rxdb'; These are the plugins I have to add: import { RxDBQueryBuilderPlugin } from 'rxdb/plugins/query-builder';
import { RxDBValidatePlugin } from 'rxdb/plugins/validate';
import { RxDBUpdatePlugin } from 'rxdb/plugins/update';
addRxPlugin(require('pouchdb-adapter-idb'));
addRxPlugin(RxDBQueryBuilderPlugin);
addRxPlugin(RxDBValidatePlugin);
addRxPlugin(RxDBUpdatePlugin); create-react-app obviously tree-shakes out the unnecessary stuff in production builds, but not development builds, which is good! - but stuff working in dev and not production in RxDB is bad. Thank you so much for responding so quickly! ⚡ |
Whenever you do a custom build, do not import anything import {
addRxPlugin,
createRxDatabase,
RxDatabase,
RxDocument,
RxCollection,
} from 'rxdb/plugins/core'; Please help me by adjusting the documentation. It is very hard for me to understand what is needed because I know RxDB too much :) |
But I’m not trying to do a custom build. I’m just trying to use the
library, as painlessly as possible, inside create-react-app, which is why I
did import from rxdb.
It’s also not clear to me why these plugins are tree-shaken out of the
production build if they are obviously being used by something in the
development build.
I think there’s a bug in here somewhere, in addition to a documentation
update.
…On Sat, Jan 16, 2021 at 11:47 AM Daniel Meyer ***@***.***> wrote:
Whenever you do a custom build, do not import anything from 'rxdb'.
Instead you should import from the core module.
import {
addRxPlugin,
createRxDatabase,
RxDatabase,
RxDocument,
RxCollection,} from 'rxdb/plugins/core';
Please help me by adjusting the documentation. It is very hard for me to
understand what is needed because I know RxDB too much :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2798 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFIKAOMHJ2ELEAWP23VRA3S2GYIJANCNFSM4WECQ2PA>
.
|
Ah sorry. Now I understand. |
Can you remove this line in your |
@pubkey - confirmed this changes the behaviour. You can clearly see it in the bundle size:
Not to put too fine a point on it, because I'm sure you understand what is happening, but just for full clarity: |
Thank you. |
* CHANGE import default plugins by wrapping createRxDatabase * ADD caching to linter * CHANGE set sideEffects: false in main module * FIX typings * FIX couch test * FIX couch test * USE exports field instead of one package.json per plugin * ADD hint * Revert "USE exports field instead of one package.json per plugin" This reverts commit 079a682. * ADD sideEffects to changelog * ADD bug checklist to readme
Case
Bug
Issue
Errors in production build of create-react-app using
pouchdb-adapter-idb
but NOT in development.Info
Code
When I run my create-react-app in development mode, everything works fine. But when I build it for production, I receive these errors:
So far I've received 3 different ones about various plugins because it was working in development but not in a production build. The errors are very helpful and I was able to fix it quickly, but the difference between a development and production build is concerning.
Not sure what the difference is between production and development, or what repository this PR needs to go on, but something funny is happening.
By the way, thanks for the amazing library!
The text was updated successfully, but these errors were encountered: