Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getAssetClass() {
try {
return require('parcel').Asset;
} catch (e) {
return require('parcel-bundler').Asset;
}
}
const Asset = require('parcel-bundler').Asset;
const isURL = require('./utils/is-url');
const urlJoin = require('./utils/urlJoin');
class UrlsAsset extends Asset {
constructor(...args) {
super(...args);
this.type = 'json';
}
async collectDependencies() {
for (let key of Object.keys(this.ast)) {
const originalPath = this.ast[key];
const assetPath = this.addURLDependency(originalPath);
if (!assetPath) throw new Error(`Cannot resolve dependency '${originalPath}'`);
if (!isURL(assetPath)) {
this.ast[key] = urlJoin(this.options.publicURL, assetPath);