elastic / elastic/apm-agent-nodejs
Add support for npm aliases
- Dominant language
- JavaScript
- Stars
- 594
- Forks
- 244
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 16
Description
With npm cli v6.9.0, [npm now supports aliases](https://github.com/npm/rfcs/blob/latest/implemented/0001-package-aliases.md). This means that you can install more than one version of the same package. Users can then give each package their own name (the alias) which is then used as the argument to the `require` function instead of the actual name of the package.
The downside of this is that our require hook will not detect that the module is loaded because it purely looks at the string being passed into the `require` function.
Possible solutions:
- Allow the user to configure the agent with a mapping of aliases to actual module names.
- Implement a clever solution that parses the `package.json` file of the project to detect those aliases automatically.
- Read the `name` field of `package.json` of the module being required instead of relying on the name given to the `require` function.
Contributor guide
Assessment
This issue has not been assessed yet.