HomePhabricator

Update dist/ and npm version number

Description

Update dist/ and npm version number

The previous dist/ files were almost five years old (last touched in
change If3409146d7, commit 54372c866e, December 2016). I don’t know how
they were created at the time, but I’ve now found a manual process to
recreate files that can at least be used to power a SPARQL editor
outside of the query service UI. I think this is still an improvement
worth releasing, though in the long run we should obviously be able to
build the package properly.

To produce the CSS and JS files, I reorganized the index.html so that
all the non-node_modules/ files ended up in one JS or CSS bundle,
respectively. This meant moving the JS files in vendor/ (i.e. code that
isn’t ours, but that we commit to Git instead of getting it from npm,
for Reasons™) from the vendor.min.js block into the wdqs.min.js block
(note: at the beginning of the block, not the end!), and splitting a
vendor.min.css block out of the style.min.css block (with the vendor/
CSS file still going into style.min.css). I also removed the files from
index.html that shouldn’t be in the npm package at all: config.js and
init.js. (The resulting index.html diff can be found at P16980 [1].) I
then ran npm run build and copied the resulting build/js/wdqs.min.*.js
and build/css/style.min.*.css into dist/.

To actually use the package, you effectively have to copy most of the
node_modules/ stylesheets and scripts from our index.html into your
custom one, which isn’t great, but would require a much larger effort to
fix (T288466). But once you have that, something like this works:

<script src="node_modules/wikidata-query-gui/dist/js/wdqs.min.js"></script>
<link rel="stylesheet" href="node_modules/wikidata-query-gui/dist/css/style.min.css">

<textarea id="sparql"></textarea>
<script>
  var editor = new wikibase.queryService.ui.editor.Editor();
  editor.fromTextArea(document.getElementById('sparql'));
</script>

and then you get a working editor with syntax highlighting and
hovercards and other amenities. The README has some more usage examples
(e.g. using the SPARQL API), but I haven’t tested those. I think being
able to get a working editor is already useful and worthy of a 0.2.0
release.

[1]: https://phabricator.wikimedia.org/P16980

Bug: T267836
Change-Id: I4de6202b45f6563b7ba291180a499220f4cdafcd

Details

Provenance
Lucas_Werkmeister_WMDEAuthored on Aug 9 2021, 4:14 PM
Parents
rWDQGd037fffcc5c3: Localisation updates from https://translatewiki.net.
Branches
Unknown
Tags
Unknown
ChangeId
I4de6202b45f6563b7ba291180a499220f4cdafcd