mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add pre-resolved path to require('atom')
This commit is contained in:
@@ -12,6 +12,7 @@ nativeModules = process.binding('natives')
|
||||
|
||||
cache =
|
||||
debug: false
|
||||
atomExportsPath: null
|
||||
dependencies: {}
|
||||
extensions: {}
|
||||
folders: {}
|
||||
@@ -101,6 +102,8 @@ resolveFilePath = (relativePath, parentModule) ->
|
||||
return
|
||||
|
||||
resolveModulePath = (relativePath, parentModule) ->
|
||||
return cache.atomExportsPath if relativePath is 'atom'
|
||||
|
||||
return unless relativePath
|
||||
return unless parentModule?.id
|
||||
|
||||
@@ -170,7 +173,7 @@ exports.create = (modulePath) ->
|
||||
|
||||
return
|
||||
|
||||
exports.register = (resourcePath) ->
|
||||
exports.register = ({resourcePath, devMode}={}) ->
|
||||
return if cache.registered
|
||||
|
||||
originalResolveFilename = Module._resolveFilename
|
||||
@@ -182,6 +185,11 @@ exports.register = (resourcePath) ->
|
||||
cache.registered = true
|
||||
cache.resourcePath = resourcePath
|
||||
|
||||
if devMode
|
||||
cache.atomExportsPath = path.join(resourcePath, 'exports', 'atom.coffee')
|
||||
else
|
||||
cache.atomExportsPath = path.join(resourcePath, 'exports', 'atom.js')
|
||||
|
||||
return
|
||||
|
||||
exports.add = (directoryPath, metadata) ->
|
||||
|
||||
@@ -18,7 +18,7 @@ window.onload = function() {
|
||||
require('../src/coffee-cache').register();
|
||||
|
||||
ModuleCache = require('../src/module-cache');
|
||||
ModuleCache.register(loadSettings.resourcePath);
|
||||
ModuleCache.register(loadSettings);
|
||||
ModuleCache.add(loadSettings.resourcePath);
|
||||
|
||||
require(loadSettings.bootstrapScript);
|
||||
|
||||
Reference in New Issue
Block a user