Skip to content

Docx exporter requires additional undocumented setup to work with Vite #1676

Open
@richardvanbergen

Description

@richardvanbergen

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

  1. https://stackblitz.com/edit/github-7wt3cfcn?file=App.tsx
  2. Go to vite.config.ts
  3. Remove nodePolyfills() from plugins.
  4. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions