babel-plugin-transform-bluebird

0.1.1 • Public • Published

babel-plugin-transform-bluebird

replace Promise with bluebird plugin.

Installation

npm install bluebird babel-plugin-transform-bluebird --save

Example

In

Promise.resolve().then(() => new Promise((resolve) => resolve()))

Out

import _Promise from "bluebird";
_Promise.resolve().then(() => new _Promise(resolve => resolve()));

Support syntax

  • new Promise
  • Promise.resolve
  • Promise.reject
  • Promise.all
  • Promise.race
  • doStuff(Promise)

But, syntax instanceof Promise / any === Promise doesn't transform. And if the Promise is already import in file, the file does not transform.

// does not transform
foo instanceof Promise
 
// does not transform
foo === Promise
 
// does not transform
import Promise from 'q';
Promise.resolve();

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-bluebird"]
}

Via CLI

$ babel --plugins transform-bluebird script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-bluebird"]
});

Development

Requirement global

  • NodeJS v5.11.0
  • Npm v3.8.6
git clone https://github.com/59naga/babel-plugin-transform-bluebird
cd babel-plugin-transform-bluebird
npm install
 
npm test

License

MIT

Package Sidebar

Install

npm i babel-plugin-transform-bluebird

Weekly Downloads

7

Version

0.1.1

License

MIT

Last publish

Collaborators

  • 59naga