Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyMoneroCoreBridge/locateFile() on node.js didn't find "monero_utils" after bundling with webpack. #100

Open
babel5405 opened this issue Oct 3, 2019 · 2 comments

Comments

@babel5405
Copy link

babel5405 commented Oct 3, 2019

I'm importing mymonero-core-js wiith a standard require() in the main thread of my electron application and everything has been working for a while but I recently added my main.js to my webpack bundle and it's created some issues.

Liine 58 of MyMoneroCoreBridge.js is returning the file the bundle is in, instead of the expected monero_utils, which is causing the block below to move onto it's else, rendering everything non-functional.

if (lastPathComponent == "monero_utils") { // typical node or electron-main process
    fullPath = path.format({
        dir: this_scriptDirectory,
        base: filename
    })
} else {
	console.warn('MyMoneroCoreBridge/locateFile() on node.js didn't find "monero_utils" (or possibly MyMoneroCoreBridge.js) itself in the expected location in the following path. The function may need to be expanded but it might in normal situations be likely to be another bug. ${pathTo_cryptonoteUtilsDir}')
}

(Note, I modified the code above slightly so it could be enclosed completely in a code block for the issue. Just replaced the backtick's with single quotes.)

What can I do to correct the path it's receiving so it gets what it actually needs? I'm assuming there's a reason it expects to be ran from monero_utils, but is there any way to work around that?

@babel5405
Copy link
Author

II'm fairly certain I should be able to exclude the module from webpack and include it separately in the bundle, but ideally I'd still like to be able to pack it with the rest of the main entry point.

@babel5405
Copy link
Author

babel5405 commented Oct 5, 2019

I would like to see if the developers have a better solution, but I went ahead and implemented an exclusion in webpack and it's resolved the issue (though this means the module isn't bundled.)

externals: [
        function(context, request, callback) {
            if (/^mymonero-core-js$/.test(request)) {
                return callback(null, 'commonjs ' + request);
            }
            callback();
        }
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant