mirror of
https://github.com/systemjs/systemjs.git
synced 2026-02-01 15:59:54 +00:00
provide source maps encoding in Node
This commit is contained in:
parent
857c0ef8d9
commit
e03812ce32
@ -4,7 +4,24 @@ var __exec;
|
||||
|
||||
(function() {
|
||||
|
||||
var hasBtoa = typeof btoa != 'undefined';
|
||||
var hasBuffer = typeof Buffer != 'undefined';
|
||||
try {
|
||||
if (new Buffer('a').toString('base64') != 'YQ==')
|
||||
hasBuffer = false;
|
||||
}
|
||||
catch(e) {
|
||||
hasBuffer = false;
|
||||
}
|
||||
|
||||
var sourceMapPrefix = '\n//# sourceMappingURL=data:application/json;base64,';
|
||||
function inlineSourceMap(sourceMapString) {
|
||||
if (hasBuffer)
|
||||
return sourceMapPrefix + new Buffer(sourceMapString).toString('base64');
|
||||
else if (typeof btoa != 'undefined')
|
||||
return sourceMapPrefix + btoa(unescape(encodeURIComponent(sourceMap)));
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
function getSource(load, wrap) {
|
||||
var lastLineIndex = load.source.lastIndexOf('\n');
|
||||
@ -26,7 +43,7 @@ var __exec;
|
||||
+ (load.source.substr(lastLineIndex, 15) != '\n//# sourceURL='
|
||||
? '\n//# sourceURL=' + load.address + (sourceMap ? '!transpiled' : '') : '')
|
||||
// add sourceMappingURL if load.metadata.sourceMap is set
|
||||
+ (sourceMap && hasBtoa && '\n//# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(sourceMap))) || '');
|
||||
+ (sourceMap && inlineSourceMap(sourceMap));
|
||||
}
|
||||
|
||||
var curLoad;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user