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

Install in the Browser #3

Closed
5 tasks
elf-pavlik opened this issue Sep 23, 2013 · 13 comments
Closed
5 tasks

Install in the Browser #3

elf-pavlik opened this issue Sep 23, 2013 · 13 comments

Comments

@elf-pavlik
Copy link
Member

i would like to experiment with it in: https://github.com/apollo-ng/dspace-client
do you just need to write instructions in README or current code doesn't run in browsers?

steps from levelgraph/levelgraph-n3#2

  • testing with zuul
  • testing Travis + Sauce Labs
  • browserified version in ./build/
  • register with bower and add bower.json
  • update README
@mcollina
Copy link
Collaborator

The current code runs just fine in the browser where LevelGraph can run.
I'm lazy in providing some good instruction in how to make the build.
LevelGraph-jsonld is browserify-compatible, just as levelgraph. Are you
comfortable with Browserify? In case, if you prepare a PR with the
instructions, I'll merge it.
Otherwise, I'll try to write some docs later this week.

@elf-pavlik
Copy link
Member Author

roger! if I figure it on my own, I'll make a PR :)
we also currently use AMD so I might investigate this direction first...

@mcollina
Copy link
Collaborator

Browserify can be used to create amd-compatible modules. You want to
package both levelgraph and levelgraph-jsonld in a single build.

Let me know if you need help!

@elf-pavlik
Copy link
Member Author

i tried adding it to project using browserify, regular levelgraph works fine but levelgraph-jsonld gives me browserify error:

Warning: Cannot find module 'canvas'

fast grep shows some 'canvas' stuff going on in levelgraph->jsonld->jsdom depenency...

jsonld.js/js/request.js tries

var jsdom = require('jsdom');

explaining:

// skip RDFa parsing if is libs missing

in my case i need jsonld without any support for RDFa!

@dlongley i wonder if we can extract something lighter for using as dependency in levelgraph-jsonld ?

@mcollina
Copy link
Collaborator

You are right, json-ld.js is not compatible with browserify.

If you look at: https://github.com/digitalbazaar/jsonld.js/blob/master/js/jsonld.js#L38-L55, it seems the JSON-LD thinks that it is in node while it isn't.
We need to add a browser directive to jsonld.js to instruct browserify not to bundle jsdom at all. Have a look at: https://gist.github.com/shtylman/4339901

I think something similar will do:

browser: {
  "jsdom": false
}

Looking at the JSON-LD library the RDFa stuff seems out of place, and maybe it should belong to a different library, like jsonld-rdfa.js, but that is out of the scope of this issue.

@dlongley
Copy link

I've cc'd @davidlehn on this issue since he has worked on that part of the jsonld.js code (related to RDFa).

@davidlehn
Copy link

FYI, that "browser" info gist changed locations: https://gist.github.com/defunctzombie/4339901

@elf-pavlik
Copy link
Member Author

@mcollina i'll push working version to a branch here later today...
if i add to 'test/mocha.opts' line --check-leaks then test on current master fail with

Error: global leak detected: rval

if you could take a look at it then we would heave working version with all tests passing in the browser by the end of the day 😄

@mcollina
Copy link
Collaborator

I don't have time today, I'll check tomorrow.
If you prepare a PR for a new version I'll revise that.

Il martedì 28 gennaio 2014, ☮ elf Pavlik ☮ notifications@github.com ha
scritto:

@mcollina https://github.com/mcollina i'll push working version to a
branch here later today...
if i add to 'test/mocha.opts' line --check-leaks then test on current
master fail with

Error: global leak detected: rval

if you could take a look at it then we would heave working version with
all tests passing in the browser by the end of the day [image: 😄]


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-33473331
.

@elf-pavlik
Copy link
Member Author

ok! i may need to merge #16 before making this pull request because i already rebased browserify work to include it...

@dlongley
Copy link

dlongley commented Feb 1, 2014

Have you guys tried the "noParse" option with browserify when including jsonld.js? It seems like it would get the job done. If that doesn't work, have you tried ignorify?

@mcollina
Copy link
Collaborator

mcollina commented Feb 2, 2014

noparse is only from the command line for client-based stuff like jquery, and the main principle behind the browserify/node modules is that they should be 'self-contained'. I do not want to mandate special options for everything to work, it should 'just work'.

ignorify is super-old (2 years ago) and it is a web middleware.

@elf-pavlik
Copy link
Member Author

done in #23

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

No branches or pull requests

4 participants