mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-22 12:29:53 +00:00
use more aggressive module preload
This commit is contained in:
parent
58482ecc63
commit
cc6443bb6c
@ -64,6 +64,7 @@ const builtinModules = [
|
|||||||
'ngx-toastr',
|
'ngx-toastr',
|
||||||
'rxjs',
|
'rxjs',
|
||||||
'rxjs/operators',
|
'rxjs/operators',
|
||||||
|
'rxjs-compat/Subject',
|
||||||
'terminus-core',
|
'terminus-core',
|
||||||
'terminus-settings',
|
'terminus-settings',
|
||||||
'terminus-terminal',
|
'terminus-terminal',
|
||||||
@ -72,11 +73,14 @@ const builtinModules = [
|
|||||||
|
|
||||||
const cachedBuiltinModules = {}
|
const cachedBuiltinModules = {}
|
||||||
builtinModules.forEach(m => {
|
builtinModules.forEach(m => {
|
||||||
|
const label = 'Caching ' + m
|
||||||
|
console.time(label)
|
||||||
cachedBuiltinModules[m] = nodeRequire(m)
|
cachedBuiltinModules[m] = nodeRequire(m)
|
||||||
|
console.timeEnd(label)
|
||||||
})
|
})
|
||||||
|
|
||||||
const originalRequire = nodeRequire('module').prototype.require
|
const originalRequire = (global as any).require
|
||||||
nodeRequire('module').prototype.require = function (query) {
|
;(global as any).require = function (query) {
|
||||||
if (cachedBuiltinModules[query]) {
|
if (cachedBuiltinModules[query]) {
|
||||||
return cachedBuiltinModules[query]
|
return cachedBuiltinModules[query]
|
||||||
}
|
}
|
||||||
@ -156,14 +160,14 @@ export async function loadPlugins (foundPlugins: IPluginInfo[], progress: Progre
|
|||||||
console.info(`Loading ${foundPlugin.name}: ${nodeRequire.resolve(foundPlugin.path)}`)
|
console.info(`Loading ${foundPlugin.name}: ${nodeRequire.resolve(foundPlugin.path)}`)
|
||||||
progress(index, foundPlugins.length)
|
progress(index, foundPlugins.length)
|
||||||
try {
|
try {
|
||||||
console.timeStamp('Loading ' + foundPlugin.name)
|
const label = 'Loading ' + foundPlugin.name
|
||||||
console.time('Loading ' + foundPlugin.name)
|
console.time(label)
|
||||||
let packageModule = nodeRequire(foundPlugin.path)
|
let packageModule = nodeRequire(foundPlugin.path)
|
||||||
let pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
let pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
||||||
pluginModule['pluginName'] = foundPlugin.name
|
pluginModule['pluginName'] = foundPlugin.name
|
||||||
pluginModule['bootstrap'] = packageModule.bootstrap
|
pluginModule['bootstrap'] = packageModule.bootstrap
|
||||||
plugins.push(pluginModule)
|
plugins.push(pluginModule)
|
||||||
console.timeEnd('Loading ' + foundPlugin.name)
|
console.timeEnd(label)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Could not load ${foundPlugin.name}:`, error)
|
console.error(`Could not load ${foundPlugin.name}:`, error)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user