You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking to extend the functionality of a Gatsby Plugin, specifically gatsby-transformer-cloudinary. The change I want to make is very specific to a job so very unlikely to be incorporated into the plug-in itself, so I want to just extend the plug-in. I'd like to avoid forking the repo to avoid merging headaches; though if that's the best option, so be it.
I had found this article suggesting a way to extend/replace functionality in node modules. For example:
// include the module that you like extend
var fs = require('fs');
// add a new function, printMessage(), to the module
fs.printMessage = function(str) {
console.log("Message from newly added function to the module");
console.log(str);
}
// re-export the module for changes to take effect
module.exports = fs
// you may use the newly added function
fs.printMessage("Success");
Could the same technique be used for a gatsby plug-in, and would it be enough to "extend" the module in an index.js of a different plug-in if I had the Cloudinary plugin as a dependency?
If it helps, I'd be looking to amend this method of the plug-in, calling out to some additional functionality just ahead of the call to createImageNode.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm looking to extend the functionality of a Gatsby Plugin, specifically gatsby-transformer-cloudinary. The change I want to make is very specific to a job so very unlikely to be incorporated into the plug-in itself, so I want to just extend the plug-in. I'd like to avoid forking the repo to avoid merging headaches; though if that's the best option, so be it.
I had found this article suggesting a way to extend/replace functionality in node modules. For example:
Could the same technique be used for a gatsby plug-in, and would it be enough to "extend" the module in an index.js of a different plug-in if I had the Cloudinary plugin as a dependency?
If it helps, I'd be looking to amend this method of the plug-in, calling out to some additional functionality just ahead of the call to createImageNode.
Thanks,
Beta Was this translation helpful? Give feedback.
All reactions