-
Notifications
You must be signed in to change notification settings - Fork 63
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
add plugin mysql #29
add plugin mysql #29
Conversation
@@ -33,7 +34,7 @@ while (topModule.parent) { | |||
export default class PluginInstaller { | |||
private readonly pluginDir: string; | |||
readonly require: (name: string) => any = topModule.require.bind(topModule); | |||
private readonly resolve = (request: string) => (module.constructor as any)._resolveFilename(request, topModule); | |||
private readonly resolve = (request: string) => resolve.sync(request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question about this, the current form (module.constructor as any)._resolveFilename(request, topModule);
ensures that the resolution is done from the point of view of the topmost module (the main app). This is necessary because if for example you have skwalking npm link
ed into a project instead of installed alongside all its dependancies then normal resolve will get the wrong path, one that sits in the skywalking node_modules path instead of the applicatiuon. Does the resolve
package do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed this point. According to the documentation resolve, this can be done by
private readonly resolve = (request: string) => resolve.sync(request, {basedir: path.dirname(topModule.id) });
if You agree i will update later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, well I checked your fix and it seems to work, so I am ok with this.
What do you mean by "does not export"? It HAS a |
I'm sorry my description is not clear enough, I have updated it.
while |
Some ideas for your plugin:
@kezhenxu94 asked me to review this because I also recently added a |
Actually, better look at #31, master had some errors. |
Hey @zijin-m, going back to #27 where you said:
I realize some time has passed, but is there any chance you can provide a short snippet case of this happening before the |
Closing in favor of #54 |
In addition, use the
resolve
package to readpackage.json
becausemysql2
does not addpackage.json
in theexports
field of thepackage.json
file