Skip to content

Absolute imports don't work. #118

@popham

Description

@popham

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions