Skip to content

Commit f76a75b

Browse files
authored
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.
1 parent b582baa commit f76a75b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

packages/svelte/src/compiler/utils/mapped_code.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,6 @@ export function combine_sourcemaps(filename, sourcemap_list) {
266266
if (!map.sources.length) map.sources = [filename];
267267
return map;
268268
}
269-
// browser vs node.js
270-
const b64enc = typeof btoa == 'function' ? btoa : (b) => Buffer.from(b).toString('base64');
271-
const b64dec = typeof atob == 'function' ? atob : (a) => Buffer.from(a, 'base64').toString();
272269

273270
/**
274271
* @param {string} filename
@@ -295,7 +292,7 @@ export function apply_preprocessor_sourcemap(filename, svelte_map, preprocessor_
295292
toUrl: {
296293
enumerable: false,
297294
value: function toUrl() {
298-
return 'data:application/json;charset=utf-8;base64,' + b64enc(this.toString());
295+
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
299296
}
300297
}
301298
});
@@ -339,7 +336,7 @@ export function parse_attached_sourcemap(processed, tag_name) {
339336
// ignore attached sourcemap
340337
return '';
341338
}
342-
processed.map = b64dec(map_data); // use attached sourcemap
339+
processed.map = atob(map_data); // use attached sourcemap
343340
return ''; // remove from processed.code
344341
}
345342
// sourceMappingURL is path or URL

0 commit comments

Comments
 (0)