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

Remove built-ins from SparqlParser.js

Open tpluscode opened this issue 4 years ago • 2 comments

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?

tpluscode avatar Mar 23 '21 12:03 tpluscode

Mmm, the prob is that lib/SparqlParser.js is autogenerated.

RubenVerborgh avatar Mar 23 '21 13:03 RubenVerborgh

Thought so :(. I did a dirty, hacky rewrite in the test setup for now...

tpluscode avatar Mar 23 '21 13:03 tpluscode

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 avatar Aug 30 '22 12:08 jacoscaz

@jacoscaz this is super specific to @web/test-runner https://github.com/zazuko/rdfjs-elements/blob/27c7b29274077a6f6e281d94fcf747b06bb55ddf/web-test-runner.config.mjs#L23-L32

tpluscode avatar Sep 01 '22 09:09 tpluscode

@RubenVerborgh would you accept a PR that manually removes that code? It's bound to be at least somewhat hacky, though.

jacoscaz avatar Sep 27 '22 07:09 jacoscaz

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!

RubenVerborgh avatar Sep 27 '22 19:09 RubenVerborgh

for 1 summer

8 years ago :D

tpluscode avatar Sep 27 '22 19:09 tpluscode