Ive been learning to use nodejs through site generators like 11ty
11ty documentation shows to add plugins like this:
const eleventyNavigation = require("@11ty/eleventy-navigation");
module.exports = function(eleventyConfig){
eleventyConfig.addPlugin(eleventyNavigation);
// other config options
}
Which seems to be the standard across node, require before module.exports, then use the constant to refer to it.
But recently I found a plugin document it like this:
module.exports = function(eleventyConfig){
eleventyConfig.addPlugin(require("eleventy-plugin-find"));
}
Is there any difference or downside to requiring node modules like this?
Personally I like doing it this way more because fewer lines and less variable definitions means less chances for me to make mistakes. I could see a problem for the more standard use of node modules, but for something like plugins where they're called only once this seems like a much cleaner way of doing it.
This may be more opinion based but I'd prefer not to pick up bad habits if this is something frowned upon.