Skip to content

Commit 220b916

Browse files
Fix import for buffer as per usage instructions
1 parent 30468b7 commit 220b916

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/xl-docx-exporter/src/docx/docxExporter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ export class DOCXExporter<
154154
geistMonoFont instanceof Uint8Array
155155
) {
156156
// conversion with Polyfill needed because docxjs requires Buffer
157-
const Buffer = (await import("buffer")).default.Buffer;
157+
// NOTE: the buffer/ import is intentional and as documented in
158+
// the `buffer` package usage instructions
159+
// https://github.com/feross/buffer?tab=readme-ov-file#usage
160+
const Buffer = (await import("buffer/")).Buffer;
158161

159162
if (interFont instanceof ArrayBuffer) {
160163
interFont = Buffer.from(interFont);

shared/util/fileUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function loadFontDataUrl(requireUrl: { default: string }) {
2626

2727
export async function loadFileBuffer(requireUrl: {
2828
default: string;
29-
}): Promise<Buffer | ArrayBuffer> {
29+
}) {
3030
if (import.meta.env.NODE_ENV === "test") {
3131
// in vitest, this is the url we need to load with readfilesync
3232
// eslint-disable-next-line

0 commit comments

Comments
 (0)