1.0.4 • Published 7 years ago

preact-cli-unassert v1.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

preact-cli-unassert

Plugin for ⚛️ preact-cli to remove assertions in production.

npm David license

Getting Started

Install it with npm:

npm i -D preact-cli-unassert

or with yarn:

yarn add preact-cli-unassert --dev

This will also install:

And include in your project by creating or adding to preact.config.js.

export default function customWebpackConfiguration(config, env, helpers) {
  // Along with other customizations and plugin...
  require('preact-cli-unassert')(config, env);
}

Example

Use console.assert calls to check your inputs:

import { h } from 'preact';

const Asserted = ({ name }) => {
  console.assert(name != null);
  return <p>Hi {name}!</p>;
}

export default Asserted;

or the usual assert APIs:

import assert from 'assert';

function add (a, b) {
    assert(!isNaN(a));
    assert.equal(typeof b, 'number');
    assert.ok(!isNaN(b));
    return a + b;
}

Related

See also preact-cli-power-assert.

Thanks

Many thanks to Jason Miller for creating ⚛️ Preact, much of the related ecosystem and lots of useful stuff.

Heavily inspired by preact-cli-lodash from Sara Vieira.

License

MIT

1.0.4

7 years ago

1.0.3

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago