linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
566 stars 146 forks source link

webpack 5 compatibility - reference to buffer #449

Open devkral opened 4 years ago

devkral commented 4 years ago

Webpack 5 removed all nodejs specific polyfills (you have to include them manually). This causes rdflib.js to fail when not provided a polyfill explicitly (because of a reference to buffer)

It would be nice if this reference could be removed, so you can use rdflib.js without nodejs polyfills.

devkral commented 4 years ago

stack trace (shortened): @ ./node_modules/readable-stream/lib/_stream_readable.js 72:17-58 <= (here are the problems) @ ./node_modules/readable-stream/readable-browser.js 1:10-63 @ ./node_modules/n3/src/N3StreamWriter.js 2:0-44 6:44-53 @ ./node_modules/n3/src/index.js 6:0-44 25:0-47:2 @ ./node_modules/rdflib/esm/parse.js 4:0-42 56:25-35 @ ./node_modules/rdflib/esm/index.js 15:0-28 61:0-63:72

As far I see it is a problem of a dependency. I will report a bugreport separately

srl295 commented 3 years ago

@devkral I also hit this. Also, build:browser does not pass -t web, which hits this err: https://github.com/webpack/webpack/issues/11660

To work around this, so far, having no idea what I'm doing I did this:

Warning: YMMVAFAIKBBQ

Vinnl commented 3 years ago

@srl295 That downgrades you to Webpack 4, which works because it still ships the polyfills by itself. You can still add them manually in Webpack 5 by installing the required polyfills as instructed by the error message, so in the case of buffer that would be npm install buffer, in the case of stream IIRC it's npm install readable-stream. Webpack should then pick that up automatically.

Unfortunately the dependency comes from the package n3, which AFAIK has no plans to move away from it (because it only targets Node) :(