Skip to content

fix(export): shim Node globals so DOCX export works in the webview#106

Merged
Razee4315 merged 1 commit into
mainfrom
fix/docx-export-node-globals
Jul 12, 2026
Merged

fix(export): shim Node globals so DOCX export works in the webview#106
Razee4315 merged 1 commit into
mainfrom
fix/docx-export-node-globals

Conversation

@Razee4315

Copy link
Copy Markdown
Owner

DOCX export threw 'global is not defined' in every packaged build: the converter's browser build expects Node globals the webview lacks. Adds a lazy shim (global/process/Buffer via the buffer polyfill) before the converter chunk loads. Verified against the built bundle in a real browser (fails without shims, valid OOXML zip with them). Full suite green (262). Pre-existing bug, not from the current batch.

@turbodocx/html-to-docx ships a "browser" build that still reaches for
Node's global, Buffer and process; the webview provides none of them,
so exporting to Word threw "global is not defined" the moment the
converter chunk loaded. The vitest suite runs under Node, which
supplies all three, so tests stayed green while every packaged build
was broken -- this predates the current batch and has likely never
worked in an installed build.

Install the three shims (buffer npm polyfill, lazily imported) right
before the converter loads. Verified against the built bundle in a
real browser: conversion fails without the shims and produces a valid
OOXML zip with them. The webview scenario is untestable under vitest
(stripping Node's own globals takes the runner down), documented in
the test file.
@Razee4315
Razee4315 merged commit f605738 into main Jul 12, 2026
8 checks passed
@Razee4315
Razee4315 deleted the fix/docx-export-node-globals branch July 12, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant