As the title says, I didnβt find a way to install and use a third party pack while using WASM swipl. Can this be done?
You mean a Prolog pack? pack_install/1,2 wonβt work. Typically Iβd clone the pack as a git submodule of your application and use attach_packs/1,2 to make them available.
Thank you @jan. Iβm not sure how to use the attach_packs/1,2
family of predicates. I put the pack in static/prolog/packs
in my webapp, and am trying to include them with:
:- attach_packs('static/prolog/packs').
:- use_module(library(mavis)).
but this doesnβt work, and pack_attach/1
doesnβt really take a string as an argument, and Iβm unsure what the right way of setting this up is.
attach_packs/1 takes a directory name as argument. Is the directory really there in the WASM version? And is mavis below that dir with a file pack.pl
and a directory prolog
holding mavis.pl
?
Iβm not sure, hereβs how my directory structure looks like:
...
βββ src
β βββ app.css
β βββ app.html
β βββ lib
β β βββ components
β β βββ ... js specific components ...
β β βββ index.js
β βββ routes
β βββ +layout.svelte
β βββ +page.svelte
βββ static
β βββ favicon.png
β βββ prolog
β β βββ ... application specific prolog code ...
β βββ prolog_packs
β βββ mavis-0.2.3
β βββ pack.pl
β βββ prolog
β β βββ mavis.pl
β βββ README.md
β βββ t
β βββ intersection.pl
β βββ predicates.pl
β βββ subtypes.pl
...
I am passing the prolog_packs
directory, in different variations, and the command doesnβt error out, but then the command:
:- attach_packs('/prolog_packs').
:- use_module(library(mavis)).
Fails because source_sink library(mavis) does not exist
. I suppose the static
directory could not be the right place, because thatβs for js
to find stuff, not prolog, but I installed swipl wasm version from npm
, so Iβm not sure where else to put the files.
Iβm afraid I know very little about web packaging. What matters is what ends up in the WASM file system. Or, do you plan to server the Prolog files from the server?
A good way to package many applications for the wasm version is to use
swipl qlf compile --include <mainfile.pl>
That should give a stand-alone .qlf file that you can then load from the WASM app. Does require swipl to be the same version as the WASM version you target.
There may be other ways. The docs may help. @jeswr, how do you package?