jsonld.js icon indicating copy to clipboard operation
jsonld.js copied to clipboard

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

Open flyon opened this issue 3 years ago • 1 comments

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

flyon avatar Jan 26 '22 06:01 flyon

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.

davidlehn avatar Jan 26 '22 16:01 davidlehn