node: prefix breaks my bundler
Closed this issue ยท 9 comments
Is there a good reason to use node:buffer over buffer for foreign module import statements? I'm not an expert, but what I have learned is that both parcel and esbuild seem to have a real problem with this, and iiuc it's not reconized by older versions of node.
Just curious, but why bundle a node app at all?
The node: prefix is there to ensure you're definitely getting the intended module supplied by node and not another package from node_modules with the same name, or something that has been injected into the require cache.
esbuild is fine with it, you just need to provide a --platform=node argument. I'm not sure about parcel.
Oh, and you're right about it not being recognized by older versions of node, but it was introduced in 14.x line. LTS ended for the prior version to that nearly 4 years ago and security updates ended 2 years ago, so it probably shouldn't be used anymore. ๐
What i meant to say is bundling it as a browser application. I have dependencies on purescript-bytestring which require this.
Not gonna lie, I'm not a frontend developer and do know much about these things. What i have noticed is that parcel and esbuild both didn't like this prefix when trying to provide this buffer lib as a polyfill for node:buffer, but when I changed it to simply buffer (e.g. see here) everything worked.
From what I can tell, no other node purescript libs in my deps (e.g. process, crypto, etc) use this node: prefix. I have found various issues concerning this node: prefix for esbuild, but for parcel I don't see anything that works out of the box. Have you ever experienced this problem, is there a straightforward solution?
From what I can tell, no other node purescript libs in my deps (e.g. process, crypto, etc) use this node: prefix.
In the latest breaking changes, I updated all the Node purescript libs to use the node: prefix as that's what the Node docs say to do in their docs. If I missed one, it was on accident. For example, https://github.com/purescript-node/purescript-node-os/blob/v5.1.0/src/Node/OS.js#L24 and https://github.com/purescript-node/purescript-node-child-process/blob/v11.1.0/src/Node/UnsafeChildProcess/Unsafe.js#L20.
Thanks for looking into this, but in the end I just made the long overdue decision to remove the dependency on purescript-bytestring (no longer maintained) which then fixed the problem. I don't know why that worked, but honestly I don't need to know. ๐
๐ I feel like it probably shouldn't depend on this if it's not a node specific library, so that's probably the right call until there's a replacement.
made the long overdue decision to remove the dependency on
purescript-bytestring
@martyall I'm not sure about your situation but maybe this would help: https://github.com/rowtype-yoga/purescript-arraybuffer-builder
@jamesdbrock cool, didn't know about that lib. In this case I would use something like that if it also had the equivalent of Haskell's Data.Binary.Get
In this case I would use something like that if it also had the equivalent of Haskell's
Data.Binary.Get
@martyall The equivalent of Data.Binary.Get is https://github.com/rowtype-yoga/purescript-parsing-dataview