File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -81,12 +81,23 @@ op.loadbytecode = function(ctx, file) {
81
81
82
82
var oldLoaderCtx = exports . loaderCtx ;
83
83
exports . loaderCtx = ctx ;
84
- try {
85
- var try_path = './' + file . replace ( / : : / g, '-' ) ;
86
- loadFrom . require ( try_path ) ;
87
- } catch ( e ) {
88
- loadFrom . require ( 'nqp-js-compiled-stuff/' + file . replace ( / : : / g, '-' ) ) ;
84
+ var mangled = file . replace ( / : : / g, '-' ) ;
85
+
86
+ var prefixes = ( process . env . NQPJS_LIB || '' ) . split ( ':' ) ;
87
+ prefixes . push ( './' , 'nqp-js-on-js/' ) ;
88
+ var found = false ;
89
+ for ( var prefix of prefixes ) {
90
+ try {
91
+ loadFrom . require ( prefix + mangled ) ;
92
+ found = true ;
93
+ break ;
94
+ } catch ( e ) {
95
+ if ( e . code !== 'MODULE_NOT_FOUND' ) {
96
+ throw e ;
97
+ }
98
+ }
89
99
}
100
+ if ( ! found ) throw "can't find: " + file + ", looking in: " + prefixes . join ( ', ' ) + " from " + loadFrom . filename ;
90
101
exports . loaderCtx = oldLoaderCtx ;
91
102
92
103
return file ;
You can’t perform that action at this time.
0 commit comments