Skip to content

Commit

Permalink
fix: global.module.paths in workers
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jun 30, 2021
1 parent 1b4ce6c commit ca730d4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/worker/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ require('../common/reset-search-paths');
// Import common settings.
require('@electron/internal/common/init');

// Process command line arguments.
const { hasSwitch, getSwitchValue } = process._linkedBinding('electron_common_command_line');

// Export node bindings to global.
const { makeRequireFunction } = __non_webpack_require__('internal/modules/cjs/helpers') // eslint-disable-line
global.module = new Module('electron/js2c/worker_init');
Expand All @@ -32,4 +35,11 @@ if (self.location.protocol === 'file:') {
// For backwards compatibility we fake these two paths here
global.__filename = path.join(process.resourcesPath, 'electron.asar', 'worker', 'init.js');
global.__dirname = path.join(process.resourcesPath, 'electron.asar', 'worker');

const appPath = hasSwitch('app-path') ? getSwitchValue('app-path') : null;
if (appPath) {
// Search for module under the app directory.
global.module.paths = Module._nodeModulePaths(appPath);
console.log(global.module.paths);
}
}

0 comments on commit ca730d4

Please sign in to comment.