From e5886dda9b3ae8a857a069a9c65737f8e66f2c5c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 27 Mar 2016 19:13:15 +0900 Subject: [PATCH] Avoid re-evaluating internal modules --- lib/common/asar_init.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/common/asar_init.js b/lib/common/asar_init.js index 49b57907c..85bb82858 100644 --- a/lib/common/asar_init.js +++ b/lib/common/asar_init.js @@ -9,6 +9,12 @@ // Make graceful-fs work with asar. var source = process.binding('natives'); source['original-fs'] = source.fs; - return source['fs'] = "var src = '(function (exports, require, module, __filename, __dirname) { ' +\n process.binding('natives')['original-fs'] +\n ' });';\nvar vm = require('vm');\nvar fn = vm.runInThisContext(src, { filename: 'fs.js' });\nfn(exports, require, module);\nvar asar = require('ATOM_SHELL_ASAR');\nasar.wrapFsWithAsar(exports);"; + return source['fs'] = ` +var nativeModule = new process.NativeModule('original-fs'); +nativeModule.cache(); +nativeModule.compile(); +var asar = require('ATOM_SHELL_ASAR'); +asar.wrapFsWithAsar(nativeModule.exports); +module.exports = nativeModule.exports`; }; })();