/alias-hq

Manage a single set of folder aliases and convert as-needed to other formats

Primary LanguageJavaScriptMIT LicenseMIT

Alias HQ

tests

Manage a single set of folder aliases and convert on-the-fly to other formats

Alias HQ logo

Abstract

Alias HQ makes the management, creation and use of path aliases easy.

import { SomeService } from '@services'

It uses your js/tsconfig.json as the single source of truth:

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "@services/*": ["app/services/*"],
      ...
    }
  }
}

And provides a simple API to use in the rest of your toolchain:

// webpack.config.js
import hq from 'alias-hq'

module.exports = {
  resolve: {
    alias: hq.get('webpack') // or jest, rollup, or your own transform...
  }
}

No more wrangling multiple incompatible configuration files:

// webpack, eslint, etc
'@services': '/volumes/projects/path/to/project/src/app/services'
// jest
'^@services/(.*)$': '<rootDir>/src/app/services/$1'
// rollup
{
  find: '@services',
  replacement: '/volumes/projects/path/to/project/src/app/services'
}

Alias configuration is just a simple import and one-liner conversion.

Integrations and tooling

Webpack, Jest and Rollup are supported out of the box, with new functionality available as plugins.

Aliases are supported by VSCode and Webstorm so auto-completion should just work.

Finally, an accompanying CLI makes it super simple to create, inspect, debug and convert paths:

cli

See here for video :)

Get started

To start using aliases in your own project:

For more information about what the package can do:

If you've an additional format you'd like to contribute: