chore: remove btoa fallback (#8783)

Since we're targeting NodeJS >16 we don't need any Buffer fallback as it's now built in globally from that version onwards.
pull/8772/head
Jimmy Wärting 2 years ago committed by GitHub
parent b582baa570
commit f76a75b97d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -266,9 +266,6 @@ export function combine_sourcemaps(filename, sourcemap_list) {
if (!map.sources.length) map.sources = [filename]; if (!map.sources.length) map.sources = [filename];
return map; return map;
} }
// browser vs node.js
const b64enc = typeof btoa == 'function' ? btoa : (b) => Buffer.from(b).toString('base64');
const b64dec = typeof atob == 'function' ? atob : (a) => Buffer.from(a, 'base64').toString();
/** /**
* @param {string} filename * @param {string} filename
@ -295,7 +292,7 @@ export function apply_preprocessor_sourcemap(filename, svelte_map, preprocessor_
toUrl: { toUrl: {
enumerable: false, enumerable: false,
value: function toUrl() { value: function toUrl() {
return 'data:application/json;charset=utf-8;base64,' + b64enc(this.toString()); return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
} }
} }
}); });
@ -339,7 +336,7 @@ export function parse_attached_sourcemap(processed, tag_name) {
// ignore attached sourcemap // ignore attached sourcemap
return ''; return '';
} }
processed.map = b64dec(map_data); // use attached sourcemap processed.map = atob(map_data); // use attached sourcemap
return ''; // remove from processed.code return ''; // remove from processed.code
} }
// sourceMappingURL is path or URL // sourceMappingURL is path or URL

Loading…
Cancel
Save