xeokit-convert icon indicating copy to clipboard operation
xeokit-convert copied to clipboard

convert2xkt.js breaks TextEncoder & TextDecoder in Browser

Open NiklasPor opened this issue 2 months ago • 0 comments

While trying to use xeokit/convert to convert models from GLTF/IFC to XKT in the browser I noticed that other features of us broke due to convert2xkt.js overwriting the global classes for TextDecoder and TextEncoder:

import { TextEncoder, TextDecoder } from 'node:util';
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;

Not sure what this workaround is for, but I would at the very least to suggest to remove them for the browser environment.

Furthermore it's in general no good practice to have module imports / exports with side effects. If I'm just importing a function without calling it from xeokit/convert, I don't think that any globals should be touched (as this leads to very hard-to-trackdown bugs, like this one).

For anyone also running into this, you can create an pnpm patch and remove the 3 lines of code, the parsers I tested will run afterwards.

NiklasPor avatar Oct 31 '25 23:10 NiklasPor