File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
loaders/node_loader/bootstrap/lib Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,17 @@ const util = require('util');
77
88const cherow = require ( './node_modules/cherow' ) ;
99
10- // eslint-disable-next-line no-empty-function
1110function node_loader_trampoline_initialize ( ) {
12- // Nothing to initialize yet
11+ try {
12+ // Preload MetaCall Monkey Patch
13+ require ( 'metacall' ) ;
14+ } catch ( e ) {
15+ if ( e . code === 'MODULE_NOT_FOUND' ) {
16+ // console.log('NodeJS Warning: MetaCall could not be preloaded');
17+ } else {
18+ console . log ( `NodeJS Error (while preloading MetaCall): ${ e . message } ` ) ;
19+ }
20+ }
1321}
1422
1523function node_loader_trampoline_is_callable ( value ) {
Original file line number Diff line number Diff line change @@ -160,6 +160,15 @@ mod.prototype.require = function (name) {
160160 /* Probably in the future we can differenciate between them, but it is not trivial */
161161 } ;
162162
163+ /* Try to load it with NodeJS first */
164+ try {
165+ return node_require . apply ( this , [ name ] ) ;
166+ } catch ( e ) {
167+ if ( e . code !== 'MODULE_NOT_FOUND' ) {
168+ throw e ;
169+ }
170+ }
171+
163172 const index = name . lastIndexOf ( '.' ) ;
164173
165174 if ( index !== - 1 ) {
@@ -204,8 +213,7 @@ mod.prototype.require = function (name) {
204213} ;
205214
206215/* Debug logs */
207- if ( process . env [ 'NODE_ENV' ] === 'debug' && addon !== undefined )
208- {
216+ if ( process . env [ 'NODE_ENV' ] === 'debug' && addon !== undefined ) {
209217 addon . metacall_logs ( ) ;
210218}
211219
You can’t perform that action at this time.
0 commit comments