excluded ajv from test bundles into a separate bundle

master
Evgeny Poberezkin 2015-07-24 22:55:19 +01:00
parent 6b9bc9e464
commit 3d3a350ea7
9 changed files with 18 additions and 13 deletions

2
.gitignore vendored
View File

@ -28,7 +28,7 @@ node_modules
.DS_Store
# Browserified browser tests
# Browserified tests
.browser
# Ajv bundle

View File

@ -73,17 +73,16 @@ ajv compiles schemas to functions and caches them in all cases (using stringifie
You can require ajv directly from the code you browserify - in this case ajv will be a part of your bundle.
If you need to use ajv in several bundles you probably don't won't to have it included separately in each one. In this case you can create browserify bundle using `bin/create-bundle` script (thanks to [siddo420](https://github.com/siddo420)).
If you need to use ajv in several bundles you can create a separate browserified bundle using `bin/create-bundle` script (thanks to [siddo420](https://github.com/siddo420)).
Then you need to load ajv in the browser:
```
<script src="ajv.bundle.js"></script>
```
Then you can use it as shown above - `require` will be global and you can `require('ajv')`.
Now you can use it as shown above - `require` will be global and you can `require('ajv')`.
Ajv passes tests with these browsers:
Ajv was tested with these browsers:
[![Sauce Test Status](https://saucelabs.com/browser-matrix/epoberezkin.svg)](https://saucelabs.com/u/epoberezkin)

View File

@ -1,5 +1,9 @@
#!/usr/bin/env bash
set -e
browserify -r js-beautify -r ./lib/ajv.js:ajv -o .browser/ajv.beautify.js
find spec -type f -name '*.spec.js' | \
xargs -I {} sh -c \
'export f="{}"; browserify $f -t require-globify -r js-beautify -o ${f/spec/.browser};'
'export f="{}"; browserify $f -t require-globify -x ajv -o ${f/spec/.browser};'

View File

@ -15,13 +15,14 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'.browser/*.js'
'.browser/ajv.beautify.js',
'.browser/*.spec.js'
],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
reporters: ['dots'],
// web server port

View File

@ -102,7 +102,8 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'.browser/*.js'
'.browser/ajv.beautify.js',
'.browser/*.spec.js'
],

View File

@ -1,7 +1,7 @@
'use strict';
var Ajv = require('../lib/ajv')
var Ajv = require(typeof window == 'object' ? 'ajv' : '../lib/ajv')
, should = require('chai').should()
, stableStringify = require('json-stable-stringify');

View File

@ -1,7 +1,7 @@
'use strict';
var Ajv = require('../lib/ajv')
var Ajv = require(typeof window == 'object' ? 'ajv' : '../lib/ajv')
, should = require('chai').should();

View File

@ -4,7 +4,7 @@ var jsonSchemaTest = require('json-schema-test')
, path = require('path');
var Ajv = require('../lib/ajv')
var Ajv = require(typeof window == 'object' ? 'ajv' : '../lib/ajv')
, ajv = Ajv({ beautify: true, _debug: false })
, fullAjv = Ajv({ allErrors: true, verbose: true, format: 'full', beautify: true, _debug: false });

View File

@ -1,7 +1,7 @@
'use strict';
var Ajv = require('../lib/ajv')
var Ajv = require(typeof window == 'object' ? 'ajv' : '../lib/ajv')
, should = require('chai').should();