cardano-js-sdk icon indicating copy to clipboard operation
cardano-js-sdk copied to clipboard

core: rxjs is not optional

Open klntsky opened this issue 2 years ago • 3 comments

Summary

I'm trying to initialize a project using @cardano-sdk/core and node fails

Steps to reproduce the bug

  1. Initialize a new npm package with npm & nodejs v18.18.2
  2. set type:module in package.json
  3. Add @cardano-sdk/core to the dependencies
  4. enter node repl and import it

Actual Result


[nix-shell:~/c/cjssdk-test]$ node --experimental-specifier-resolution=node
(node:2382229) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.
(Use `node --trace-warnings ...` to show where the warning was created)
Welcome to Node.js v18.18.2.
Type ".help" for more information.
> const c = await import('@cardano-sdk/core')
Uncaught:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'rxjs' imported from /home/me/c/cjssdk-test/node_modules/@cardano-sdk/core/dist/esm/CardanoNode/util/bufferChainSyncEvent.js
    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
    at new NodeError (node:internal/errors:405:5)
    at packageResolve (node:internal/modules/esm/resolve:890:9)
    at moduleResolve (node:internal/modules/esm/resolve:939:20)
    at defaultResolve (node:internal/modules/esm/resolve:1132:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18) {
  code: 'ERR_MODULE_NOT_FOUND'
}
>

Expected Result

Importing works

SDK version

0.21.0

Environment type

  • [X] Node.js
  • [ ] Browser
  • [ ] Browser Extension
  • [ ] Other

Environment details

nodejs v18.18.2

klntsky avatar Nov 28 '23 10:11 klntsky

Why is rxjs a peer dependency @mkazlauskas ?

rhyslbw avatar Nov 29 '23 11:11 rhyslbw

core package was supposed to only import types from rxjs in order to define ObservableCardanoNode interface, but clearly it's no longer the case. We should probably hoist bufferChainSyncEvent to projection package.

mkazlauskas avatar Nov 29 '23 12:11 mkazlauskas

This issue should be solved in version 0.40.0

AngelCastilloB avatar Sep 25 '24 02:09 AngelCastilloB