diff --git a/src/bootstrap-window.js b/src/bootstrap-window.js index aecdff764af6b87230df3c6abc61bd228b75fac8..dbf7a2c2f7ea7fe05d8a735f2eec2f052cde9ddf 100644 --- a/src/bootstrap-window.js +++ b/src/bootstrap-window.js @@ -36,6 +36,7 @@ exports.assign = function assign(destination, source) { exports.load = function (modulePaths, resultCallback, options) { // @ts-ignore const webFrame = require('electron').webFrame; + const path = require('path'); const args = exports.parseURLQueryArgs(); const configuration = JSON.parse(args['config'] || '{}') || {}; @@ -55,7 +56,7 @@ exports.load = function (modulePaths, resultCallback, options) { exports.assign(process.env, configuration.userEnv); // Enable ASAR support - bootstrap.enableASARSupport(); + bootstrap.enableASARSupport(path.join(configuration.appRoot, 'node_modules')); // disable pinch zoom & apply zoom level early to avoid glitches const zoomLevel = configuration.zoomLevel; diff --git a/src/bootstrap.js b/src/bootstrap.js index 4f0d039550fdfec41f62e13482c9773d9689771d..d2b6e42affb17c9c10b14769dbedecec0b3ad2ab 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -21,11 +21,18 @@ process.on('SIGPIPE', () => { //#endregion //#region Add support for using node_modules.asar -exports.enableASARSupport = function () { +/** + * @param {string=} nodeModulesPath + */ +exports.enableASARSupport = function (nodeModulesPath) { // @ts-ignore const Module = require('module'); const path = require('path'); - const NODE_MODULES_PATH = path.join(__dirname, '../node_modules'); + let NODE_MODULES_PATH = nodeModulesPath; + if (!NODE_MODULES_PATH) { + NODE_MODULES_PATH = path.join(__dirname, '../node_modules'); + } + const NODE_MODULES_ASAR_PATH = NODE_MODULES_PATH + '.asar'; const originalResolveLookupPaths = Module._resolveLookupPaths;