From 1b055993d58d4f07729d7154087621de7b7c35fb Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Fri, 30 Jun 2017 11:18:48 +0200 Subject: [PATCH] Use .node extension for requiring native module According to the [Node.js documentation][1] the file extension CAN be omitted but omitting it has the disadvantage that webpack can't match these modules. So if you try to package a JavaScript application which use node-canvas then you can't simply use webpack plugins like [node-native-loader][2]. With this little change webpack and the node-native-loader plugin can be used to easily create an application package with the canvas.node lib copied beside the packed JavaScript and everything works fine. [1]: https://nodejs.org/api/addons.html#addons_loading_addons_using_require [2]: https://www.npmjs.com/package/node-native-loader --- lib/bindings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bindings.js b/lib/bindings.js index c5c95b522..c0afc9841 100644 --- a/lib/bindings.js +++ b/lib/bindings.js @@ -1,3 +1,3 @@ 'use strict'; -module.exports = require('../build/Release/canvas'); +module.exports = require('../build/Release/canvas.node');