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

Support for Alias HQ #106

Open
davestewart opened this issue Sep 8, 2020 · 4 comments
Open

Support for Alias HQ #106

davestewart opened this issue Sep 8, 2020 · 4 comments

Comments

@davestewart
Copy link

Hey @ilearnio,

I've just released a package called Alias HQ:

It's an end-to-end solution for configuring, refactoring, maintaining and using path aliases.

Was doing some research on how to use aliases with Node, and this lib came up.

I've added it as a ticket to support this library:

That will be another way to solve #105, at least in the front end world.

If you have any thoughts, let me know!

@davestewart
Copy link
Author

OK, this was super-easy and very meta!

As an experiment, I wanted to update Alias HQ to use aliases itself:

  • I wrote an Alias HQ Node plugin to remap the Alias HQ Webpack plugin.
  • I then used the Alias HQ CLI to convert all relative paths of Alias HQ itself.
  • Finally:
    • I called the plugin
    • which calls your API
    • which allows Alias HQ to load itself... using aliases!

image

The plugin is this:

const moduleAlias = require('module-alias')
const webpack = require('../webpack')

module.exports = function (config, options) {
  const paths = webpack(config, options)
  Object.keys(paths).forEach(key => {
    moduleAlias.addAlias(key, paths[key])
  })
  return true
}

Implementation is this:

require('alias-hq').get('node')

@davestewart
Copy link
Author

OK, have added support in v5.1:

The plugin integration is here:

Not sure if you want to mention it in your docs at all?

@Kehrlann
Copy link
Collaborator

Hey @davestewart , sorry, I've been quite busy lately ! Just wanted to let you know I'll take a look next week.

@davestewart
Copy link
Author

Hey, no worries! I know what it's like trying to keep a hand on all the OSS projects. They are constantly asking for time you don't always have 😬

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

2 participants