@rabbitcc/babel

0.0.3 • Public • Published

babel plugins

remove test plugin

This plugin erasure describe() and import assert from 'assert'. Allow you write test in your source file, e.g.

Input:

function sum(a, b) {
  return a + b
}

/**
 * test
 */

import assert from 'assert'

describe('sum()', () => {
  it('should eq 3', () => {
    assert.ok(sum(1, 2), 3)
  })
})

Output:

function sum(a, b) {
  return a + b
}

/**
 * test
 */


// 'import' and 'describe' was removed

Usage

{
  "plugins": ["@rabbitcc/remove-test"]
}

// or with options

{
  "plugins": [["@rabbitcc/remove-test", {
    // options see below..
  }]]
}

// remove on production evn

{
  "env": {
    "plugins": ["@rabbitcc/remove-test"]
  }
}

Plugin options:

type Options = {
  /**
   * remove test helper modules if match test, e.g. "import 'foo'" with `test: /foo/`
   */
  test?: RegExp,
  /**
   * like test, used for remove test helpers modules
   */
  include?: Array<string>
}

Readme

Keywords

none

Package Sidebar

Install

npm i @rabbitcc/babel

Weekly Downloads

0

Version

0.0.3

License

GPL-3.0

Unpacked Size

46.6 kB

Total Files

5

Last publish

Collaborators

  • rabbitcc