fix(export): shim Node globals so DOCX export works in the webview#106
Merged
Conversation
@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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.