-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Description
When Buffer is used in client or common code, webpack bundles a costly ~30kb polyfill. Looks like it does it per each plugin where Buffer is used. In some cases, it is possible to avoid using it in clientside code altogether, but probably we at least could share the Buffer polyfill across plugins.
Some clientside usages I found:
- Core
kibana/src/core/public/utils/crypto/sha256.ts
Line 164 in 3c30878
data = Buffer.from(data, encoding); - Canvas
kibana/x-pack/plugins/canvas/common/lib/embeddable_dataurl.ts
Lines 10 to 13 in 57a53db
export const encode = (input: Partial<EmbeddableInput>) => Buffer.from(JSON.stringify(input)).toString('base64'); export const decode = (serializedInput: string) => JSON.parse(Buffer.from(serializedInput, 'base64').toString()); - Enterprise Search
Line 172 in 6f5cd00
if (Buffer.byteLength(textInput) > MAX_UPLOAD_BYTES) { - Fleet
decoded = Buffer.from(id, 'base64').toString('utf8'); - Fleet (should use
global.Bufferto avoid webpack from polyfilling it)(typeof Buffer === 'function' && Buffer.from(namespace).length > 100) - Lists (it's in the
commondir. Is it actually used in the Browser?)kibana/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.mock.ts
Lines 19 to 21 in 9bf488e
export const getImportListItemAsBuffer = (input: string[]): Buffer => { return Buffer.from(input.join('\r\n')); }; - Maps
return { ...icon, svg: Buffer.from(icon.svg, 'base64').toString('utf-8') }; - Maps
return { ...icon, svg: Buffer.from(icon.svg).toString('base64') }; - Synthetics
kibana/x-pack/plugins/synthetics/public/components/monitor_management/action_bar/action_bar.tsx
Line 68 in 80a2aa1
id: monitorId ? Buffer.from(monitorId, 'base64').toString('utf8') : undefined, - Synthetics
kibana/x-pack/plugins/synthetics/public/components/monitor_management/monitor_list/actions.tsx
Line 48 in 80a2aa1
href={`${basePath}/app/uptime/edit-monitor/${Buffer.from(id, 'utf8').toString('base64')}`} - Synthetics
kibana/x-pack/plugins/synthetics/public/pages/monitor_management/edit_monitor.tsx
Line 34 in a4a0822
return getMonitor({ id: Buffer.from(monitorId, 'base64').toString('utf8') }); - [ ]
- Data (should be easy to remove. Trying now) [data][bfetch] Avoid using
Bufferin client code #107278 (review)return Buffer.from(val, 'base64').toString('utf8'); - Bfetch (should be easy to remove. Trying now) [data][bfetch] Avoid using
Bufferin client code #107278 (review)
const buff = Buffer.from(response, 'base64'); - Possibly other
