Open
Description
Describe the bug
Docx requires node polyfill to work in browsers when building with Vite to polyfill nodebuffer
. This requirement is not documented.
Vite does not ship with node types and so requires extra setup and installation of vite-plugin-node-polyfills
in order to work.
To Reproduce
- https://stackblitz.com/edit/github-7wt3cfcn?file=App.tsx
- Go to
vite.config.ts
- Remove
nodePolyfills()
from plugins. - Click the export button
Expected
docXDocument
is created.
Actual
Uncaught (in promise) Error: nodebuffer is not supported by this platform
at a.checkSupport (chunk-JSORLMQ6.js?v=af075e90:18683:43)
at new f (chunk-JSORLMQ6.js?v=af075e90:18488:84)
at n.generateInternalStream (chunk-JSORLMQ6.js?v=af075e90:18211:18)
at n.generateAsync (chunk-JSORLMQ6.js?v=af075e90:18213:23)
at _Packer2.<anonymous> (chunk-JSORLMQ6.js?v=af075e90:20955:18)
at Generator.next (<anonymous>)
at chunk-JSORLMQ6.js?v=af075e90:55:61
at new Promise (<anonymous>)
at __async (chunk-JSORLMQ6.js?v=af075e90:39:10)
at _Packer2.pack (chunk-JSORLMQ6.js?v=af075e90:20953:12)