diff --git a/atom/browser/api/lib/exports/electron.coffee b/atom/browser/api/lib/exports/electron.coffee index 768224d95..f0c3b87c9 100644 --- a/atom/browser/api/lib/exports/electron.coffee +++ b/atom/browser/api/lib/exports/electron.coffee @@ -1,9 +1,6 @@ # Import common modules. module.exports = require '../../../../common/api/lib/exports/electron' -v8Util = process.atomBinding 'v8_util' -v8Util.setHiddenValue module.exports, 'electronModule', true - Object.defineProperties module.exports, # Browser side modules, please sort with alphabet order. app: diff --git a/atom/browser/lib/rpc-server.coffee b/atom/browser/lib/rpc-server.coffee index 5c67026de..df6d4f1f9 100644 --- a/atom/browser/lib/rpc-server.coffee +++ b/atom/browser/lib/rpc-server.coffee @@ -18,10 +18,6 @@ valueToMeta = (sender, value, optimizeSimpleObject=false) -> meta.type = 'date' if value instanceof Date meta.type = 'promise' if value?.constructor.name is 'Promise' - # require('electron'). - if meta.type is 'object' and v8Util.getHiddenValue value, 'electronModule' - meta.type = 'electronModule' - # Treat simple objects as value. if optimizeSimpleObject and meta.type is 'object' and v8Util.getHiddenValue value, 'simple' meta.type = 'value' @@ -49,8 +45,6 @@ valueToMeta = (sender, value, optimizeSimpleObject=false) -> meta.members = plainObjectToMeta value else if meta.type is 'date' meta.value = value.getTime() - else if meta.type is 'electronModule' - meta.members = (name for name of value) else meta.type = 'value' meta.value = value diff --git a/atom/renderer/api/lib/remote.coffee b/atom/renderer/api/lib/remote.coffee index a38d6ec0b..e177ea4bb 100644 --- a/atom/renderer/api/lib/remote.coffee +++ b/atom/renderer/api/lib/remote.coffee @@ -49,15 +49,6 @@ metaToValue = (meta) -> when 'date' then new Date(meta.value) when 'exception' throw new Error("#{meta.message}\n#{meta.stack}") - when 'electronModule' - # require('electron'). - ret = {} - for member in meta.members - do (member) -> - Object.defineProperty ret, member, - enumerable: true - get: -> exports.getBuiltin member - ret else if meta.type is 'function' # A shadow class to represent the remote function object. @@ -157,6 +148,9 @@ exports.require = (module) -> meta = ipcRenderer.sendSync 'ATOM_BROWSER_REQUIRE', module moduleCache[module] = metaToValue meta +# Optimize require('electron'). +moduleCache.electron = exports + # Alias to remote.require('electron').xxx. builtinCache = {} exports.getBuiltin = (module) ->