You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
readable-stream has circular dependencies which cause inheriting a class which is still
undefined at that moment, resulting in a runtime error.
readable-stream is imported by @ledgerhq/hw-app-btc/src/hashPublicKey > ripemd160 > hash-base.
To fix the build, we replace it by stream which gets polyfilled by rollup-plugin-node-polyfills.
Note that stream and readable-stream are largely compatible and effectively the same code.
However, the stream polyfill used by rollup-plugin-node-polyfills is an older version which has
less problems with circular dependencies. The circular dependencies are currently being resolved
in readable-stream though and once merged (see nodejs/readable-stream#348)
the replacement should be removed or even turned around. Note that without the replacement, the
stream polyfill and readable-stream are both bundled, which is not desirable.
Note that the stream polyfill / older readable-stream version also has circular dependencies but
is able to run.
Other options tried to resolve this issue which didn't help were:
- Update readable-stream: the circular dependencies are still present in the current version of
readable-stream. See nodejs/readable-stream#348 for progress on that
issue getting resolved.
- Update rollup-plugin-node-polyfills dependencies and polyfills: While the plugin is not being
updated and maintained anymore, there has been a recent pull request with updates:
ionic-team/rollup-plugin-node-polyfills#14. This didn't help though.
Other options which have not been tried:
- Using @rollup/plugin-commonjs option dynamicRequireTargets: replicates the logic for dynamic
requires and might fix problems with circular dynamic requires.
- rewrite imports as in rollup/rollup#1507 (comment):
This is in the end similar to what we did.
Note that also re-ordering of the plugin order mitigated the issue of builds that fail to run,
however, still readable-stream has more circular dependencies than the stream polyfill and
therefore we keep this fix for now.
The re-ordering of plugins will be re-visited in a later change / commit.
0 commit comments