-
-
Notifications
You must be signed in to change notification settings - Fork 871
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
how to use in browser #21
Comments
We use it with browserify with require('ajv') in dependent module, not as a separate bundle, but it should work the way you do it too. Are you using the latest version? it only works from 0.5.2. |
Yes, using the latest versions of browserify and ajv. |
ah, yes, it doesn't create any global at the moment. You can:
and then browserify and use this bundle |
It looks like Browserify does not make require function available with the command I was using. Here is what I used instead:
Then, I was able to use it normally (after including bundle.js)
|
Cool, thanks. I will add to readme. Just to confirm, you are still loading bundle in a separate script tag, correct? |
Yes, I still load bundle.js in a script tag in HTML file.
For some reason, many of the browserify articles do not mention -r option. |
Thanks, added "Using in browser" to readme. |
@epoberezkin Can you add a link to this thread in the readme please? This help me a lot :D |
@nsdelgadov it's changed since then - the supplied bundle already creates global (it is "universal"). So if you load bundle from npm package or from cdnjs you can just use global Ajv. Maybe just one line comment can be added to readme. |
I am writing test cases using Jasmine and need to use ajv through my browser.
I have already attempted to use it with browserify but it doesn't seem to work. Please provide a quick example as to how to use it within browser after bundling the package using browserify.
Here is what I have done so far:
and added that into my jasmine Spec file using:
Then??
The text was updated successfully, but these errors were encountered: