Closed curran closed 4 months ago
A solution to this problem was already proposed by @dummdidumm in here:
https://github.com/sveltejs/prettier-plugin-svelte/pull/239/files#r696572168
This looks promising!
// base64-string.ts
export const stringToBase64 = (str: string) => typeof btoa !== 'undefined' ? bota : Buffer.from(str).toString('base64');
export const base64ToString = (str: string) => typeof atob !== 'undefined' ? bota : Buffer.from(str, 'base64').toString();
There appears to be only two occurrences of Buffer
that need to be changed:
https://github.com/search?q=repo%3Asveltejs%2Fprettier-plugin-svelte%20Buffer&type=code
As an enhancement to the browser build introduced in https://github.com/sveltejs/prettier-plugin-svelte/pull/417, this issue is about removing the dependency on the
Buffer
global, which is present in Node environments but not in browser environments.Currently, this is how the browser build must be consumed in order to work:
The goal with removing the
Buffer
dependency is to make it simpler, like this: