Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using jsonld.js with rollup #355

Closed
lazka opened this issue Jan 15, 2020 · 6 comments
Closed

Using jsonld.js with rollup #355

lazka opened this issue Jan 15, 2020 · 6 comments

Comments

@lazka
Copy link

lazka commented Jan 15, 2020

Hey, more of a support question:

I'm trying to use jsonld.js with rollup for browser bundling and I was wondering if anyone has a working setup for it already or can give some hints on how to improve things (or can recommend an alternative library for parsing jsonld)

I can just import the minified version on npm, but that doesn't give me named exports and no treeshaking and jsonld.js is too large as is.

I have a minimal working rollup+jsonld setup here if someone wants to give it a try: https://github.com/lazka/jsonld-rollup-test

@omirobarcelo
Copy link

Yes, I have also issues with rollup. I'm trying to use jsonld in a Svelte web app.

These are my errors when building, using the library like import * as jsonld from "jsonld":

(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
core-js/fn/object/entries (imported by node_modules\jsonld\lib\index.js,  core-js/fn/object/entries?commonjs-external)
(!) Missing exports
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src\App.svelte
compact is not exported by node_modules\jsonld\lib\index.js
360:   async function showData() {
361:     $$invalidate(1, show = true);
362:     const compacted = await jsonld.compact(doc, context);
                                        ^
363:     console.log(JSON.stringify(compacted, null, 2));

Using the minified version from node_modules liek @lazka does in his repo works, but it's not an ideal solution.

@lazka
Copy link
Author

lazka commented Apr 9, 2020

I've just updated the example repo to jsonld 3.x and rollup 2.x. Minified no-op bundle size is still at 230kb

@davidlehn
Copy link
Member

Current focus is on 1.1 and related features. After that I hope to see the code switch over to ESM style and do some related cleanups. If using tree shaking tools then that should help with the size before even looking at other optimizations.

@dlongley
Copy link
Member

Closing as a duplicate of #399.

@lazka
Copy link
Author

lazka commented May 27, 2020

Nice to see some progress, thanks!

@lazka
Copy link
Author

lazka commented Feb 15, 2021

I've updated my example repo now (newer versions, not using the minified bundle): https://github.com/lazka/jsonld-rollup-test

We are down from 215kb to 115kb minified, which is a nice improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants