@@ -14,8 +14,7 @@ let setImmediatePromise = () => new Promise(resolve => {
14
14
setImmediate ( resolve ) ;
15
15
} ) ;
16
16
17
- const rel_path_cache = { } ;
18
- const import_cache = { } ;
17
+ export const import_cache = new Map ( ) ;
19
18
20
19
let nix_path_parsed = ( ( ) => {
21
20
let nixpath = process . env . NIX_PATH ;
@@ -55,16 +54,18 @@ async function importTail(real_path) {
55
54
}
56
55
}
57
56
try {
58
- console . log ( ' ' + fmtTdif ( process . hrtime ( tstart ) ) + '\tloaded' ) ;
57
+ console . log ( real_path + ' ' + fmtTdif ( process . hrtime ( tstart ) ) + '\tloaded' ) ;
59
58
let trld = translate_inline_srcmap ( fdat , real_path ) ;
60
- console . log ( ' ' + fmtTdif ( process . hrtime ( tstart ) ) + '\ttranslated' ) ;
59
+ console . log ( real_path + ' ' + fmtTdif ( process . hrtime ( tstart ) ) + '\ttranslated' ) ;
61
60
let stru ;
62
61
stru = ( new Function ( 'nixRt' , 'nixBlti' , trld ) ) ;
63
62
// call the yield here to allow any hanging events to proceed
64
- await setImmediatePromise ( ) ;
63
+ // await setImmediatePromise();
65
64
stru = stru ( buildRT ( real_path ) , nixBlti ) ;
66
- console . log ( ' ' + fmtTdif ( process . hrtime ( tstart ) ) + '\tevaluated' ) ;
67
- import_cache [ real_path ] = stru ;
65
+ console . log ( real_path + ' ' + fmtTdif ( process . hrtime ( tstart ) ) + '\tevaluated' ) ;
66
+ import_cache . set ( real_path , stru ) ;
67
+ console . debug ( real_path + ' -res-> ' ) ;
68
+ console . debug ( stru ) ;
68
69
return stru ;
69
70
} catch ( e ) {
70
71
console . log ( real_path , e ) ;
@@ -77,7 +78,10 @@ export function import_(xpath) {
77
78
return xpath . then ( import_ ) ;
78
79
if ( xpath instanceof Error )
79
80
throw xpath ;
80
- return import_cache [ xpath ] = importTail ( xpath ) ;
81
+ if ( ! import_cache . has ( xpath ) ) {
82
+ import_cache . set ( xpath , importTail ( xpath ) ) ;
83
+ }
84
+ return import_cache . get ( xpath ) ;
81
85
}
82
86
83
87
function buildRT ( opath ) {
0 commit comments