0.0.3 • Published 6 years ago

@rabbitcc/babel v0.0.3

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
6 years ago

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>
}