mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
move source map sanitization back to translate for build support
This commit is contained in:
parent
2f56b0c904
commit
8a688f7d21
@ -177,6 +177,30 @@
|
||||
|
||||
hook('translate', function(translate) {
|
||||
return function(load) {
|
||||
|
||||
/*
|
||||
* Source map sanitization for load.metadata.sourceMap
|
||||
* Used to set browser and build-level source maps for
|
||||
* translated sources in a general way.
|
||||
*
|
||||
* This isn't plugin-specific, but can't go anywhere else for now
|
||||
* As it is post-translate
|
||||
*/
|
||||
var sourceMap = load.metadata.sourceMap;
|
||||
|
||||
// if an object not a JSON string do sanitizing
|
||||
if (sourceMap && typeof sourceMap == 'object') {
|
||||
var originalName = load.name.split('!')[0];
|
||||
|
||||
// force set the filename of the original file
|
||||
sourceMap.file = originalName + '!transpiled';
|
||||
|
||||
// force set the sources list if only one source
|
||||
if (!sourceMap.sources || sourceMap.sources.length == 1)
|
||||
sourceMap.sources = [originalName];
|
||||
load.metadata.sourceMap = JSON.stringify(sourceMap);
|
||||
}
|
||||
|
||||
var loader = this;
|
||||
if (load.metadata.loaderModule && load.metadata.loaderModule.translate && load.metadata.format != 'defined') {
|
||||
return Promise.resolve(load.metadata.loaderModule.translate.call(loader, load)).then(function(result) {
|
||||
|
||||
@ -498,26 +498,6 @@ function createEntry() {
|
||||
|
||||
hook('instantiate', function(instantiate) {
|
||||
return function(load) {
|
||||
/*
|
||||
* Source map sanitization for load.metadata.sourceMap
|
||||
* Used to set browser and build-level source maps for
|
||||
* translated sources in a general way.
|
||||
*/
|
||||
var sourceMap = load.metadata.sourceMap;
|
||||
|
||||
// if an object not a JSON string do sanitizing
|
||||
if (sourceMap && typeof sourceMap == 'object') {
|
||||
var originalName = load.name.split('!')[0];
|
||||
|
||||
// force set the filename of the original file
|
||||
sourceMap.file = originalName + '!transpiled';
|
||||
|
||||
// force set the sources list if only one source
|
||||
if (!sourceMap.sources || sourceMap.sources.length == 1)
|
||||
sourceMap.sources = [originalName];
|
||||
load.metadata.sourceMap = JSON.stringify(sourceMap);
|
||||
}
|
||||
|
||||
if (load.metadata.format == 'detect')
|
||||
load.metadata.format = undefined;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user