blake-regalia / graphy.js

A collection of RDF libraries for JavaScript
https://graphy.link/
ISC License
161 stars 3 forks source link

Remove references or imports to node specific objects like process or global #37

Open Antoniossss opened 3 years ago

Antoniossss commented 3 years ago

Since it supposed to work with webpack I should be able to use it out of the box. However

npm install --save @graphy/content.ttl.read

and than in method

const reader = ttlReader();
reader.read(graphContent);
reader.on('data', console.log);

fails with

image

Also I had to add

to the index.html as it was failing with global is undefined error

Antoniossss commented 3 years ago

I did litle digging and found out that back in the days angular cli was shimming node specific tooling https://github.com/angular/angular-cli/pull/9812/commits/bd4d3c57c72712a646ffdc2787ae2fc95c56d61a

if i recreate node shimming with stub impl reding ttls works just fine. that means that library imports node specific things like process or global without using them.

My suggestion is to remove references to node tooling, especially global and process in modules i which they are not used directly (content ttl read is one of examples)

blake-regalia commented 3 years ago

process is used in @graphy/core.iso.stream (a dependency of ttl.read) as a polyfill for browsers and old versions of node https://github.com/blake-regalia/graphy.js/blob/master/src/core/iso/stream.js.jmacs#L194 Next major release drops support for node.js < v12, and readable-stream has standardized .destroy in standalone package away from node core with a browser variant. So next release should avoid this particular issue. At least for v4 in the meantime there is a workaround. Thanks for posting.

Antoniossss commented 3 years ago

Great to hear that. I am loking forward to get typed version of graphy. Keep up the good work