Package Exports
- babel-plugin-unassert
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-unassert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
babel-plugin-unassert
Babel plugin to remove assertions on build. Encourages Design by Contract (DbC).
INSTALL
$ npm install --save-dev babel-plugin-unassert
HOW TO USE
via Babel CLI
$ $(npm bin)/babel --plugins babel-plugin-unassert /path/to/src/target.js > /path/to/build/target.js
or shortly,
$ $(npm bin)/babel --plugins unassert /path/to/src/target.js > /path/to/build/target.js
via Babel API
var babel = require('babel-core');
var jsCode = fs.readFileSync('/path/to/src/target.js');
var transformed = babel.transform(jsCode, {
plugins: ['babel-plugin-unassert']
});
console.log(transformed.code);
EXAMPLE
For given math.js
below,
'use strict';
function add (a, b) {
console.assert(typeof a === 'number');
assert(!isNaN(a));
assert.equal(typeof b, 'number');
assert.ok(!isNaN(b));
return a + b;
}
Run babel
with --plugins unassert
to transform tests.
$ $(npm bin)/babel --plugins unassert /path/to/demo/math.js > /path/to/build/math.js
You will see assert calls disappear.
'use strict';
function add(a, b) {
return a + b;
}
AUTHOR
LICENSE
Licensed under the MIT license.