File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
packages/cubejs-backend-native/js Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -118,25 +118,29 @@ export type TransformDataResponseNative = {
118118 result : string
119119} ;
120120
121+ let loadedNative : any = null ;
122+
121123export function loadNative ( ) {
124+ if ( loadedNative ) {
125+ return loadedNative ;
126+ }
127+
122128 // Development version
123129 if ( fs . existsSync ( path . join ( __dirname , '/../../index.node' ) ) ) {
124- return require ( path . join ( __dirname , '/../../index.node' ) ) ;
130+ loadedNative = require ( path . join ( __dirname , '/../../index.node' ) ) ;
131+ return loadedNative ;
125132 }
126133
127134 if ( fs . existsSync ( path . join ( __dirname , '/../../native/index.node' ) ) ) {
128- return require ( path . join ( __dirname , '/../../native/index.node' ) ) ;
135+ loadedNative = require ( path . join ( __dirname , '/../../native/index.node' ) ) ;
136+ return loadedNative ;
129137 }
130138
131139 throw new Error (
132140 `Unable to load @cubejs-backend/native, probably your system (${ process . arch } -${ process . platform } ) with Node.js ${ process . version } is not supported.` ,
133141 ) ;
134142}
135143
136- export function isSupported ( ) : boolean {
137- return fs . existsSync ( path . join ( __dirname , '/../../index.node' ) ) || fs . existsSync ( path . join ( __dirname , '/../../native/index.node' ) ) ;
138- }
139-
140144function wrapNativeFunctionWithChannelCallback (
141145 fn : ( extra : any ) => unknown | Promise < unknown > ,
142146) {
You can’t perform that action at this time.
0 commit comments