Skip to content

Cannot use xmlbuilder2 with Vite: Uncaught TypeError: Class extends value undefined is not a constructor or nullΒ #216

@tylerc

Description

@tylerc

Describe the bug

After upgrading to v4 of xmlbuilder2 in a Vite project, importing xmlbuilder2 is now failing with the following errors:

XMLBuilderCBImpl.ts:33 Uncaught TypeError: Class extends value undefined is not a constructor or null
    at node_modules/xmlbuilder2/lib/builder/XMLBuilderCBImpl.js (XMLBuilderCBImpl.ts:33:39)
    at __require (xmlbuilder2.js?v=ad1f0bdc:3:50)
    at node_modules/xmlbuilder2/lib/builder/index.js (index.ts:2:1)
    at __require (xmlbuilder2.js?v=ad1f0bdc:3:50)
    at node_modules/xmlbuilder2/lib/index.js (index.ts:1:1)
    at __require (xmlbuilder2.js?v=ad1f0bdc:3:50)
    at index.ts:1:66

Downgrading to v3 of xmlbuilder2 fixes the error.

To Reproduce

A repo containing a minimal reproduction is here: https://github.com/tylerc/xmlbuilder2-vite-repro

The offending code is simply:

import { create } from "xmlbuilder2";
console.log(create);

Expected behavior

I would expect to still be able to use xmlbuilder2 v4 in a Vite project like I can with v3.

Version:

  • node.js: v24.12.0
  • xmlbuilder2 4.0.3
  • Vite 7.3.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions