forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use per process native module loader for compiled JS source
- Loading branch information
1 parent
136c5dc
commit 65a1776
Showing
9 changed files
with
89 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
|
||
namespace node { | ||
class Environment; | ||
} | ||
} // namespace node | ||
|
||
namespace atom { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
'use strict' | ||
|
||
;(function () { // eslint-disable-line | ||
return function (source, require, asarSource) { | ||
// Expose fs module without asar support. | ||
|
||
// NB: Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular | ||
// dependency. So to expose the unmodified Node 'fs' functionality here, | ||
// we have to copy both 'fs' *and* 'internal/fs/streams' and modify the | ||
// copies to depend on each other instead of on our asarified 'fs' code. | ||
source['original-fs'] = source.fs.replace("require('internal/fs/streams')", "require('original-fs/streams')") | ||
source['original-fs/streams'] = source['internal/fs/streams'].replace("require('fs')", "require('original-fs')") | ||
|
||
// Make asar.js accessible via "require". | ||
source.ELECTRON_ASAR = asarSource | ||
|
||
// Monkey-patch the fs module. | ||
require('ELECTRON_ASAR').wrapFsWithAsar(require('fs')) | ||
} | ||
})() | ||
/* global source, require */ | ||
|
||
// Expose fs module without asar support. | ||
// NB: Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular | ||
// dependency. So to expose the unmodified Node 'fs' functionality here, | ||
// we have to copy both 'fs' *and* 'internal/fs/streams' and modify the | ||
// copies to depend on each other instead of on our asarified 'fs' code. | ||
source['original-fs'].replace("require('internal/fs/streams')", "require('original-fs/streams')") | ||
source['original-fs/streams'].replace("require('fs')", "require('original-fs')") | ||
|
||
// Monkey-patch the fs module. | ||
require('electron/js2c/asar').wrapFsWithAsar(require('fs')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters