diff --git a/README.md b/README.md index 9419fe0..fb38aed 100644 --- a/README.md +++ b/README.md @@ -551,9 +551,7 @@ validate({ userId: 1, postId: 19 }) ### Using transpilers with asynchronous validation functions. -To use a transpiler you should separately install it (or load its bundle in the browser). - -Ajv npm package includes minified browser bundle of regenerator and nodent in dist folder. +[ajv-async](https://github.com/epoberezkin/ajv-async) uses [nodent](https://github.com/MatAtBread/nodent) to transpile async functions. To use another transpiler you should separately install it (or load its bundle in the browser). #### Using nodent @@ -561,6 +559,8 @@ Ajv npm package includes minified browser bundle of regenerator and nodent in di ```javascript var ajv = new Ajv; require('ajv-async')(ajv); +// in the browser if you want to load ajv-async bundle separately you can: +// window.ajvAsync(ajv); var validate = ajv.compile(schema); // transpiled es7 async function validate(data).then(successFunc).catch(errorFunc); ``` diff --git a/karma.conf.js b/karma.conf.js index 91cde55..ab2d0de 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -17,7 +17,7 @@ module.exports = function(config) { files: [ 'dist/ajv.min.js', 'node_modules/chai/chai.js', - 'dist/nodent.min.js', + 'node_modules/ajv-async/dist/ajv-async.min.js', 'node_modules/bluebird/js/browser/bluebird.core.min.js', '.browser/*.spec.js' ], diff --git a/karma.sauce.js b/karma.sauce.js index 1316ab0..18e85d6 100644 --- a/karma.sauce.js +++ b/karma.sauce.js @@ -112,7 +112,7 @@ module.exports = function(config) { files: [ 'dist/ajv.min.js', 'node_modules/chai/chai.js', - 'dist/nodent.min.js', + 'node_modules/ajv-async/dist/ajv-async.min.js', 'node_modules/bluebird/js/browser/bluebird.core.min.js', '.browser/*.spec.js' ], diff --git a/package.json b/package.json index 6ac14f7..d0182fc 100644 --- a/package.json +++ b/package.json @@ -19,15 +19,13 @@ "test-debug": "mocha spec/*.spec.js --debug-brk -R spec", "test-cov": "nyc npm run test-spec", "test-ts": "tsc --target ES5 --noImplicitAny lib/ajv.d.ts", - "bundle": "node ./scripts/bundle.js . Ajv pure_getters", - "bundle-nodent": "node ./scripts/bundle.js nodent", - "bundle-all": "del-cli dist && npm run bundle && npm run bundle-nodent", + "bundle": "del-cli dist && node ./scripts/bundle.js . Ajv pure_getters", "bundle-beautify": "node ./scripts/bundle.js js-beautify", "build": "del-cli lib/dotjs/*.js '!lib/dotjs/index.js' && node scripts/compile-dots.js", "test-karma": "karma start --single-run --browsers PhantomJS", - "test-browser": "del-cli .browser && npm run bundle-all && scripts/prepare-tests && npm run test-karma", + "test-browser": "del-cli .browser && npm run bundle && scripts/prepare-tests && npm run test-karma", "test": "npm run jshint && npm run eslint && npm run test-ts && npm run build && npm run test-cov && if-node-version 4 npm run test-browser", - "prepublish": "npm run build && npm run bundle-all", + "prepublish": "npm run build && npm run bundle", "watch": "watch 'npm run build' ./lib/dot" }, "nyc": { @@ -88,7 +86,6 @@ "karma-phantomjs-launcher": "^1.0.0", "karma-sauce-launcher": "^1.1.0", "mocha": "^4.0.0", - "nodent": "^3.1.3", "nyc": "^11.0.2", "phantomjs-prebuilt": "^2.1.4", "pre-commit": "^1.1.1", diff --git a/spec/ajv-async.js b/spec/ajv-async.js new file mode 100644 index 0000000..d141256 --- /dev/null +++ b/spec/ajv-async.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = typeof window == 'object' ? window.ajvAsync : require('' + 'ajv-async'); diff --git a/spec/ajv_async_instances.js b/spec/ajv_async_instances.js index 73fa36b..8facd36 100644 --- a/spec/ajv_async_instances.js +++ b/spec/ajv_async_instances.js @@ -2,7 +2,7 @@ var Ajv = require('./ajv') , util = require('../lib/compile/util') - , setupAsync = require('ajv-async'); + , setupAsync = require('./ajv-async'); module.exports = getAjvInstances;