image-js / iobuffer

Read and write binary data in ArrayBuffers
http://image-js.github.io/iobuffer/
MIT License
43 stars 6 forks source link

Getting `TextEncoder is not a constructor` in v5.2.0 #56

Closed coeing closed 1 year ago

coeing commented 1 year ago

Hi there,

I am using your package through fast-png. My own package has to run in Node and in the browser. But in the angular application I use it in I am getting an error when using iobuffer@5.2.0:

ERROR Error: Uncaught (in promise): TypeError: util__WEBPACK_IMPORTED_MODULE_0__.TextEncoder is not a constructor
TypeError: util__WEBPACK_IMPORTED_MODULE_0__.TextEncoder is not a constructor

Not sure why it did not break in 5.1.0, but when I stick my application to that version it still works. It might be a good idea to move the new TextEncoder() into the encode function

https://github.com/image-js/iobuffer/blob/59190fe589d302931e86097803470d6f4e2e028b/src/text.ts#L8

philibe commented 1 year ago

Thanks @coeing. It works with 5.1.0

targos commented 1 year ago

This is fixed in v5.2.1. Sorry for the breakage.