solid-contrib / data-modules

Solid Data Modules
5 stars 1 forks source link

built and minified js bundle of the contacts module #100

Closed michielbdejong closed 1 month ago

michielbdejong commented 3 months ago

Hi @angelo-v,

Modern javascript practices notwithstanding ;) I would like to include your data module as a bundled and minified .js file that I can directly put into a <script src=""> tag in my html. I tried using a <script module src=""> tag but didn't get that working.

michielbdejong commented 3 months ago

Using webpack probably?

michielbdejong commented 3 months ago

This is also what rdflib uses

angelo-v commented 3 months ago

Here is a working example of how you can use the module with Plain HTML and ESM import, without a build step.

The key is to generate an import map, which you can do e.g. via https://generator.jspm.io

An application that wants to use this module either has to create a bundle itself, or use importmaps. I do not think it is recommended to do the bundling in the library itself. Otherwise we need to include rdflib and all its dependencies as well. Usually a client app needs more than only this module as a dependency. If everything is bundled already there will be a lot of code duplication.

angelo-v commented 1 month ago

I found a simpler example using esm.sh and added it to the readme: https://github.com/solid-contrib/data-modules/tree/main/contacts#usage-in-the-brower-via-cdn

This should be a sufficient solution to run it in a browser without any build / install step.