Skip to content

Absolute imports don't work. #118

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

Open
popham opened this issue Jan 21, 2019 · 0 comments
Open

Absolute imports don't work. #118

popham opened this issue Jan 21, 2019 · 0 comments

Comments

@popham
Copy link
Contributor

popham commented Jan 21, 2019

Cap'n Proto schemas admit absolute imports that search command-line-parametrized include directories, e.g. capnp compile -ots -I /path/to/reusable/stuff/ some-schema.capnp. I've got an example repo: https://github.com/popham/ts-absolute-import-example (npm run compile generates). Currently my import using Lib = "/lib-file.capnp" gets mapped to import { A } from ".//lib-file.capnp".

I ask because I've been implementing a plugin targeting Flow, but it turns out that emitting TypeScript and plain JavaScript demands only a tiny bit of extra code. Unfortunately, I don't know much of anything about TypeScript, so I have no idea how absolute imports could be supported in this ecosystem. Under Flow I think that I can hack them together with name_mapper under .flowconfig and babel-plugin-module-resolver. My favorite option currently is some sort of "emit includable" option that generates an index file (I've been working to avoid an index blob by default because I expect it to spoil dead code elimination tools). I'm not at all fond of my favorite, however.

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