Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import path for iov-cli is confusing #1120

Open
ethanfrey opened this issue Jul 8, 2019 · 0 comments
Open

Import path for iov-cli is confusing #1120

ethanfrey opened this issue Jul 8, 2019 · 0 comments

Comments

@ethanfrey
Copy link
Contributor

I made a new project that imported @iov/core and @iov/cli and added a number of helper functions for opinionated high-level access to the chain into src/wallet.ts. I ran them through tests and 💯 Then I launched ./node_modules/bin/iov-cli, which started up great and could create keys, but when I tried import * as wallet from "./src/wallet" and any variant I could think of, import failed.

I finally managed to get a workaround with an absolute path on my filesystem.
import * as wallet from "PWD/src/wallet", where I manually replaces PWD with the output of pwd on my shell, so it looked like: import * as wallet from "/home/ethan/js/iov-connect/src/wallet". This let me try out the code, but is not a good user interface.

I dug into the cli code a bit and it seems that installationDir is changing the import root. And TsRepl will override the process.cwd() with the installation dir. This seems necessary for some startup scripts, but makes it very hard to import relatively inside the repl.

This root may make some sense when running inside the iov-core repo, but when imported outside, I have no idea where it is. I did not want to change this directly as I did not know why that was needed (for the setup imports?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant