js-assert
v2.0.4
Published
JS assert implementation (work like java "assert") which only exists on debug mode
Downloads
5
Readme
JS Assert
What it does?
To add check on debug mode only (similar to java "assert" keyword) and being removed on production mode
How to use it?
By Webpack:
Add webpack-assert-loader as the first loader of js, with "dev" query param specified.
An example to config webpack:
var webpackConfig = {
/* ... other webpack config ...*/
module: {
loaders: {[
test: /\.js$/,
loader: 'js-assert/webpack-assert-loader?dev=' + (isDev ? 'true' : 'false')
]}
}
};
It's achieved by replacing __assert__
call to add dev check in webpack-assert-loader,
so webpack will strip __assert__
call on production mode.
By UglifyJs Tool:
Set compress.pure_func
to include __assert__
on production building.
It's achieved by manually specifying the __assert__
call doesn't affect anything.
So it'll be stripped out (if it's returned result is not saved to some local variable...).
Changes Log
2.0.3
- Use a single webpack loader to strip
__assert__
call on production mode, instead of cooperated with another webpack plugin