Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

concat directory separators instead of "/" to make it work on Windows #39

@Gohan

Description

@Gohan

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

The problem:

node-loader won't work well with Quasar-framework + electron + webpack process flow on Windows:

the generate code: process.dlopen(module, __dirname + "/" + __webpack_public_path__ + ${JSON.stringify(name)}${typeof options.flags !== 'undefined' ? , ${JSON.stringify(options.flags)} : ''}); fails with "/" on windows platform.

I tried to use require("path").sep to make the loader more platform sensitive for Windows compability

Here is the diff that solved my problem:

diff --git a/node_modules/node-loader/dist/index.js b/node_modules/node-loader/dist/index.js
index b57fb73..fef0365 100644
--- a/node_modules/node-loader/dist/index.js
+++ b/node_modules/node-loader/dist/index.js
@@ -31,7 +31,7 @@ function loader(content) {
   this.emitFile(name, content);
   return `
 try {
-  process.dlopen(module, __dirname + "/" + __webpack_public_path__ + ${JSON.stringify(name)}${typeof options.flags !== 'undefined' ? `, ${JSON.stringify(options.flags)}` : ''});
+  process.dlopen(module, __dirname + require("path").sep + __webpack_public_path__ + ${JSON.stringify(name)}${typeof options.flags !== 'undefined' ? `, ${JSON.stringify(options.flags)}` : ''});
 } catch (error) {
   throw new Error('node-loader:\\n' + error);
 }

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions