Deno support
ProvocaTeach opened this issue · comments
Hello, I am opening an issue for supporting Deno via ES module importing out-of-the-box, per discussion in issue #138 at the suggestion of @jacoscaz.
Deno is a runtime for JavaScript created by Ryan Dahl (who also built Node). Benefits of Deno include:
- Direct support for TypeScript
- Security by default
- Browser-like behavior whenever possible
Members of the Quadstore team may have a better idea than I do of how far-off this is. I don’t have a great sense of how much the most popular RDF/JS projects depend on Node. However, Skypack or a similar Deno-friendly CDN may be a good way to provide stopgap support.
Some helpful Deno links:
- Deno homepage
- Deno v1.13.2 manual
- Skypack docs
- Package checks: Best practices for Node package authors wishing to support ES modules.
- Deno support: How Skypack can be used for Deno specifically, and when this is/isn’t possible.
- 10 Things I Regret About Node.js - Ryan Dahl - JSConf EU: Helpful for understanding the philosophy and design goals of Deno.
- Syntax.fm episode on Deno: A somewhat-silly but comprehensive podcast introduction to Deno that assumes no prior knowledge.
Thanks to the recent addition of separate ESM vs. CJS builds, partial support for Deno is now available through Skypack in quadstore@11.0.0-beta.5
:
import { DataFactory } from 'https://cdn.skypack.dev/rdf-data-factory@1.1.1';
import { Quadstore } from 'https://cdn.skypack.dev/quadstore@11.0.0-beta.4';
import { MemoryLevel } from 'https://cdn.skypack.dev/memory-level@1.0.0';
const backend = new MemoryLevel();
const dataFactory = new DataFactory();
const store = new Quadstore({ backend, dataFactory });
await store.open();
await store.put(dataFactory.quad(
dataFactory.namedNode('ex://s'),
dataFactory.namedNode('ex://p'),
dataFactory.namedNode('ex://o'),
));
const { items } = await store.get({});
console.log(items);
await store.close();
Further work is needed to add support for Deno in quadstore-comunica
, thus enabling SPARQL queries in Deno, and likely depends on fixing this upstream issue: RubenVerborgh/SPARQL.js#139 .
Found a temporary workaround by using import maps to replace Skypack's version of sparqljs@3.5.2
with https://gist.github.com/jacoscaz/022c513ca77b0061c5bfee0356ba3b8d , which contains a small fix for the unchecked usage of require
.
Closing - will be a part of the upcoming 11.0.0
release!