Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in Cloudflare Pages: Cannot read properties of undefined (reading 'TYPED_ARRAY_SUPPORT') #149

Open
KTibow opened this issue Aug 9, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@KTibow
Copy link

KTibow commented Aug 9, 2022

Describe the bug
When I try to use this library on Cloudflare Pages, I get the error

Cannot read properties of undefined (reading 'TYPED_ARRAY_SUPPORT')

This is relevant to node-libs-browser requiring buffer.

To Reproduce
Make a SvelteKit project, and require this library. Import it dynamically (in order to be able to view the error message, since Cloudflare pages doesn't have logs). When importing it, you get an error like

TypeError: Cannot read properties of undefined (reading 'TYPED_ARRAY_SUPPORT')

Expected behavior
The library to import and run normally in CF Pages' JS interpreter.

Version:

  • node.js: 17
  • xmlbuilder2 ^3.0.2

Additional context
N/A

@KTibow KTibow added the bug Something isn't working label Aug 9, 2022
@frederichoule
Copy link

frederichoule commented Jul 13, 2023

I have the exact same problem. Did you find a workaround @KTibow ?

@KTibow
Copy link
Author

KTibow commented Jul 13, 2023

I'm using fast-xml-parser right now (iirc)

@frederichoule
Copy link

Thanks, just did the same. Works flawlessly.

@Antti-Palola
Copy link

You can also go around this by defining an alias in your build machinery to skip the minified version that has the corrupted polyfill for Buffer. For example in vite config resolve.alias:

    xmlbuilder2: path.resolve(__dirname, "node_modules/xmlbuilder2/lib/index"),

@lifeiscontent
Copy link

@oozcitak any chance you'd accept a PR that fixes this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants