网页 综合 更新时间 2026-11-05 12:53:57

Installation | RxDB

自动蜘蛛 rxdb.info 正文约 2169 字
Installation | RxDB
To install the latest release of rxdb and its dependencies and save it to your package.json, run:
You also need to install the peer-dependency rxjs if you have not installed it before.
RxJS 7 ships an ES5 build and an ES2015 build. The ES2015 build is only resolved when your bundler sets the es2015 export condition. Vite, webpack, Rollup and esbuild do not set it by default, so they bundle the ES5 build together with the tslib helpers. In an RxDB app built with Vite, adding the condition reduces the bundle by about 6.6 KB minified (1.6 KB gzipped). The Angular CLI already sets the condition, so Angular projects need no change.
RxDB is coded with ES8 and transpiled to ES5. This means you have to install polyfills to support older browsers. For example you can use core-js with:
If you need polyfills, you have to import them in your code.
When you use RxDB with Angular or other Webpack based frameworks, you might get the error Uncaught ReferenceError: global is not defined. This is because some dependencies of RxDB assume a Node.js-specific global variable that is not added to browser runtimes by some bundlers. You have to add them manually, like we do here.
In the examples folder you can find CI tested projects for different frameworks and use cases, while in the /config folder base configuration files for Webpack, Rollup, Mocha, Karma, TypeScript are exposed.
Consult package.json for the versions of the packages supported.
If you need the latest development state of RxDB, add it as git dependency into your package.json.
Replace commitHash with the hash of the latest build-commit.
To import rxdb, add this to your JavaScript file to import the default bundle that contains the RxDB core:
RxDB has three kinds of import paths:
All types are exported from rxdb. Use import type so that they do not end up in your bundle.
How to combine these types is shown in the TypeScript tutorial.
For unit tests, use the Memory RxStorage. It needs no setup and all data is gone when the process ends. When your tests need a fresh database per test, give each database a random name with randomToken() from rxdb. More testing patterns are on the testing page.
访问原文 返回搜索 https://rxdb.info/install.html
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。