@@ -9,6 +9,20 @@ var path = require('path');
9
9
var Module = require ( 'module' ) ;
10
10
var fs = require ( 'fs' ) ;
11
11
12
+ var sourceMapSources = global . nodeEsModuleLoaderSourceMapSources = global . nodeEsModuleLoaderSourceMapSources || { } ;
13
+
14
+ require ( 'source-map-support' ) . install ( {
15
+ retrieveSourceMap : function ( source ) {
16
+ if ( ! sourceMapSources [ source ] )
17
+ return null ;
18
+
19
+ return {
20
+ url : source . replace ( '!transpiled' , '' ) ,
21
+ map : sourceMapSources [ source ]
22
+ } ;
23
+ }
24
+ } ) ;
25
+
12
26
function NodeESModuleLoader ( baseKey , rcPath ) {
13
27
if ( ! isNode )
14
28
throw new Error ( 'Node module loader can only be used in Node' ) ;
@@ -50,7 +64,7 @@ NodeESModuleLoader.prototype[RegisterLoader.normalize] = function(key, parent, m
50
64
} ) ;
51
65
} ;
52
66
53
- var PROCESS_REGISTER_CONTEXT = RegisterLoader . processRegisterContext ;
67
+ var PROCESS_REGISTER_CONTEXT = RegisterLoader . processRegisterContext || 'processRegisterContext' ;
54
68
55
69
// instantiate just needs to run System.register
56
70
// so we fetch the source, convert into the Babel System module format, then evaluate it
@@ -77,13 +91,15 @@ NodeESModuleLoader.prototype[RegisterLoader.instantiate] = function(key, metadat
77
91
filename : key + '!transpiled' ,
78
92
sourceFileName : key ,
79
93
moduleIds : false ,
80
- sourceMaps : 'inline' ,
94
+ sourceMaps : true ,
81
95
plugins : [ require ( 'babel-plugin-transform-es2015-modules-systemjs' ) ] ,
82
96
extends : loader . rcPath
83
97
} ) ;
84
98
85
99
// evaluate without require, exports and module variables
86
- ( 0 , eval ) ( output . code + '\n//# sourceURL=' + fileUrlToPath ( key ) + '!transpiled' ) ;
100
+ var path = fileUrlToPath ( key ) + '!transpiled' ;
101
+ sourceMapSources [ path ] = output . map ;
102
+ ( 0 , eval ) ( output . code + '\n//# sourceURL=' + path ) ;
87
103
loader [ PROCESS_REGISTER_CONTEXT ] ( key ) ;
88
104
89
105
resolve ( ) ;
0 commit comments