SPARQL.js
SPARQL.js copied to clipboard
Remove built-ins from SparqlParser.js
The module lib/SparqlParser.js wants to require the node modules fs and path
This is a bit problematic in my setup where I want run browser tests for a component which uses the parser. It is running rollup and, while commonjs can be easily transformed, I'm having a hard time setting it up so that it doesn't choke on the built-in modules.
Would it be possible to move the function exports.main = function commonjsMain (args) {} somewhere else?
Mmm, the prob is that lib/SparqlParser.js is autogenerated.
Thought so :(. I did a dirty, hacky rewrite in the test setup for now...
I suspect that this is also what is preventing usage of quadstore-comunica in Deno:
error: Uncaught ReferenceError: require is not defined
if (require.main === module) {
^
at https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/sparqljs.js:1900:5
at createCommonjsModule (https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/sparqljs.js:204:6)
at https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/sparqljs.js:239:22
Otherwise, Skypack's version available at https://cdn.skypack.dev/[email protected] should be good to go. I can't think of anything outside super-hacky solutions... @tpluscode how have you addressed this?
@jacoscaz this is super specific to @web/test-runner https://github.com/zazuko/rdfjs-elements/blob/27c7b29274077a6f6e281d94fcf747b06bb55ddf/web-test-runner.config.mjs#L23-L32
@RubenVerborgh would you accept a PR that manually removes that code? It's bound to be at least somewhat hacky, though.
This whole library has always been a hack in the first place (was supposed to be a parser for 1 summer until something better was written). So yeah, with a repeatable build process, why not!
for 1 summer
8 years ago :D