Skip to content

Conversation

@mondoreale
Copy link
Contributor

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 streamreadable-stream and timerstimers-browserify
    • Use import.meta.url for migrations path instead of __dirname

⚠️ Breaking: Named exports only - Removed default export

…tils

- Move Persistence interface from Persistence.ts to types.ts
- Update import in PersistenceManager to use type-only import
…directories

- Move `BrowserPersistence` and `ServerPersistence` to `_browser` and `_nodejs`
directories respectively.
- Rename both classes to `Persistence` with named exports, enabling consistent imports via the `@/` path alias that resolves to the appropriate platform directory at build time.
Switch from Node.js `crypto.randomBytes` to `@noble/post-quantum/utils`
`randomBytes` for browser compatibility across encryption utilities
and test files.
Replace migrationsPath with migrationsUrl to use import.meta.url in
shared code, avoiding path/url imports. Node.js Persistence converts
URL to path using fileURLToPath.
@github-actions github-actions bot added cli-tools Related to CLI Tools Package utils sdk node labels Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli-tools Related to CLI Tools Package node sdk utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants