0.0.3 • Published 8 years ago

jassert v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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

1.0.3

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago