digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.65k stars 195 forks source link

Support for importing parts of the library, but not all. json-ld minified is currently 97kb #468

Open flyon opened 2 years ago

flyon commented 2 years ago

I want to use jsonld.js in my library, but when I do so the already minified bundle increases with 97kb, which is quite a bit.

I only need to parse compact json-LD formats. It would be great if I can

import {compact} from 'jsonld/compact' 
const compacted = await compact(doc, context);

thereby shaving off some kb for the other formats that I don't need.

For illustration: 81kb for jsonld minified and 16kb for rdf-canonize (you can ignore reflect-metadata in this image) image

davidlehn commented 2 years ago

Yes, we want to do this. It's been a matter of letting the ecosystem catch up to where it's practical to do, and of course, time. We've gotten some experience lately with module conversion so hopefully we can build off of that. I image the goal will be to make it so high level function and all the utility functions can be used independently. There's a lot of usage between them, but hopefully it will help reduce some unneeded bloat in common use cases.

See also https://github.com/digitalbazaar/jsonld.js/issues/399.