input-output-hk/cardano-js-sdk

core: rxjs is not optional

klntsky opened this issue · 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

  • Node.js
  • Browser
  • Browser Extension
  • Other

Environment details

nodejs v18.18.2

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.