diff --git a/src/index.js b/src/index.js index f20df80..5440a38 100644 --- a/src/index.js +++ b/src/index.js @@ -23,9 +23,9 @@ export default function loader(content) { return ` try { - process.dlopen(module, __dirname + require("path").sep + __webpack_public_path__ + ${JSON.stringify( + process.dlopen(module, require("path").join(__dirname, __webpack_public_path__, ${JSON.stringify( name - )}${ + )})${ typeof options.flags !== "undefined" ? `, ${JSON.stringify(options.flags)}` : "" diff --git a/test/__snapshots__/loader.test.js.snap b/test/__snapshots__/loader.test.js.snap index 3ce6d4b..78dfd50 100644 --- a/test/__snapshots__/loader.test.js.snap +++ b/test/__snapshots__/loader.test.js.snap @@ -5,7 +5,7 @@ exports[`loader should throw an error on broken "node" addon: errors 1`] = `Arra exports[`loader should throw an error on broken "node" addon: module 1`] = ` " try { - process.dlopen(module, __dirname + require(\\"path\\").sep + __webpack_public_path__ + \\"broken.node\\"); + process.dlopen(module, require(\\"path\\").join(__dirname, __webpack_public_path__, \\"broken.node\\")); } catch (error) { throw new Error('node-loader:\\\\n' + error); } @@ -19,7 +19,7 @@ exports[`loader should work: errors 1`] = `Array []`; exports[`loader should work: module 1`] = ` " try { - process.dlopen(module, __dirname + require(\\"path\\").sep + __webpack_public_path__ + \\"hello.node\\", 1); + process.dlopen(module, require(\\"path\\").join(__dirname, __webpack_public_path__, \\"hello.node\\"), 1); } catch (error) { throw new Error('node-loader:\\\\n' + error); }