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

Create "resolveAlias" method #95

Open
Vasile-Peste opened this issue Apr 13, 2020 · 3 comments
Open

Create "resolveAlias" method #95

Vasile-Peste opened this issue Apr 13, 2020 · 3 comments

Comments

@Vasile-Peste
Copy link

Vasile-Peste commented Apr 13, 2020

I see that for advanced usage I can require the module and use methods like addAlias for adding new aliases.

I would like to be able also to resolve an alias. Use case:

const moduleAlias = require('module-alias');
const fs = require('fs');

fs.readFileSync(moduleAlias.resolveAlias("#root/my-file.txt");
@Kehrlann
Copy link
Collaborator

Would require.resolve("#root/your-module") solve your problem ?

Note, it's for resolving modules rather than files, see this discussion for more info: #71

@ghost
Copy link

ghost commented Sep 25, 2020

@Kehrlann, in commonjs looks good, but how about ES6 import? I'm using Typescript, so in the compilation is src/ and in the runtime is dist/. For example.

@Kehrlann
Copy link
Collaborator

@lvfxbr I highly looking into tsconfig-paths for TypeScript code ; rather than have to fiddle around with module-alias

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