rdflib.js icon indicating copy to clipboard operation
rdflib.js copied to clipboard

webpack 5 compatibility - reference to buffer

Open devkral opened this issue 5 years ago • 4 comments

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 avatar Oct 23 '20 20:10 devkral

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

devkral avatar Oct 23 '20 20:10 devkral

@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:

  • npm i --save webpack@4
  • npx webpack --progress -t web

Warning: YMMVAFAIKBBQ

srl295 avatar Nov 24 '20 16:11 srl295

@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) :(

Vinnl avatar Nov 24 '20 17:11 Vinnl