|
|
@ -1,6 +1,7 @@ |
|
|
|
'use strict' |
|
|
|
'use strict' |
|
|
|
var base64 = require('js-base64').Base64 |
|
|
|
var base64 = require('js-base64').Base64 |
|
|
|
var swarmgw = require('swarmgw')() |
|
|
|
var swarmgw = require('swarmgw')() |
|
|
|
|
|
|
|
var resolver = require('@resolver-engine/imports').ImportsEngine() |
|
|
|
var request = require('request') |
|
|
|
var request = require('request') |
|
|
|
|
|
|
|
|
|
|
|
module.exports = class CompilerImports { |
|
|
|
module.exports = class CompilerImports { |
|
|
@ -112,13 +113,19 @@ module.exports = class CompilerImports { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
if (found) return |
|
|
|
|
|
|
|
|
|
|
|
if (found) { |
|
|
|
resolver |
|
|
|
return |
|
|
|
.resolve(url) |
|
|
|
} else if (/^[^:]*:\/\//.exec(url)) { |
|
|
|
.then(result => { |
|
|
|
cb('Unable to import "' + url + '": Unsupported URL schema') |
|
|
|
return resolver.require(url) |
|
|
|
} else { |
|
|
|
}) |
|
|
|
|
|
|
|
.then(result => { |
|
|
|
|
|
|
|
cb(null, result.source, url, result.provider, result.url) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
|
|
err |
|
|
|
cb('Unable to import "' + url + '": File not found') |
|
|
|
cb('Unable to import "' + url + '": File not found') |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|