Commit 2c84e0a
authored
Bundle
### Summary
Introduces a Rollup-based bundling system for the SDK, enabling proper
platform-specific builds for both Node.js and browser environments with
architectural refactoring to support environment-specific code via the
`@/` path alias pattern.
### Key Changes
- **Rollup bundling pipeline** - Added `rollup.config.mts` producing
multiple output formats:
- Node.js: ESM (`.js`) and CJS (`.cjs`)
- Browser: ESM (`.js`) and CJS (`.cjs`)
- UMD: Regular and minified builds for `<script>` tag usage
- **Platform-specific code organization** - Introduced `_browser/` and
`_nodejs/` directories with `@/` path alias that resolves to the correct
platform at build time:
- `Persistence`: Browser uses IndexedDB, Node.js uses SQLite
- `createRSAKeyPair`: Browser uses WebCrypto, Node.js uses native crypto
- **TypeScript configuration refactor** - Split into
`tsconfig.node.json` and `tsconfig.browser.json` for separate
compilation targets
- **Browser compatibility improvements**:
- Replaced `crypto.randomBytes` with `@noble/post-quantum/utils`
- Added `publicEncrypt` and `privateDecrypt` to `@streamr/utils`
- Aliased `stream` → `readable-stream` and `timers` →
`timers-browserify`
### Known Limitations
- `Persistence.exists()` is not implemented for browser (throws error) -
this functionality is Node.js only
### Future Considerations
- In the SDK, browser-specific code lives in `src/_browser/` and
Node.js-specific code in `src/_nodejs/`. This underscore-prefixed
directory pattern could be applied to other packages in the monorepo
that need platform-specific implementations.sdk for browser (no polyfills required!), and for Node.js (#3358)1 parent 99d3dca commit 2c84e0a
File tree
77 files changed
+1276
-2631
lines changed- docs/docs/usage/sdk
- packages
- browser-test-runner
- sdk
- bin
- scripts
- src
- _browser
- _nodejs
- contracts
- encryption
- utils
- persistence
- test
- browser-smoke-test
- end-to-end
- exports/tests
- integration
- test-utils
- fake
- types
- unit
- utils
- src
- browser
- nodejs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
77 files changed
+1276
-2631
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
3 | 2 | | |
4 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
5 | 12 | | |
6 | 13 | | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
0 commit comments