Skip to content

Refactor with TS Paths feature #199

@jasonkuhrt

Description

@jasonkuhrt

Would like to refactor and centralize a libs dir that the rest of the codebase can reference via ~<module-name>. About the feature: https://dev.to/larswaechter/path-aliases-with-typescript-in-nodejs-4353. https://www.typescriptlang.org/docs/handbook/module-resolution.html

This would require TS Config paths config like so:

"compilerOptions": {
  "baseURL": "./src",
  "paths": {
    "~*": ["./lib/*"]
  }
}

Problem is TS does not translate the mapping at build time. Surprisingly.

microsoft/TypeScript#26722

Some tools trying to help in this space listed at:

microsoft/TypeScript#26722

But they are runtime oriented. We would want a build time option, since we're a library and not an app.

One build time option is this Go-based lib https://github.com/joseluisq/go-tspath. Introducing a non-node dep for a small use-case like this though doesn't feel right.

Build our own tool?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/refactorAddress tech debt, internal incidental complexity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions