Giter VIP home page Giter VIP logo

babel-transform-dir's Introduction

Build Status

babel-transform-dir

Transforms javascript files within a directory by babel, and expose a Promise API.

Install

$ npm install babel-transform-dir --save

Usage

|-- lib/   # empty
|-- src/
|     |-- a.js
|     |-- b.js
|-- .babelrc
const transform = require('babel-transform-dir')

// Transform all javascript files in `./src` and write the result to `./lib`
transform('./src', './lib')
.then(() => {
  console.log('done')
})

// Or explicitly specify babel config
readJson('./.babelrc')
.then((babel_config) => {
  return transform('./src', './lib', {
    babel: babel_config,
    // Invokes whenever a file is transformed and written.
    onFile: (file) => {
      console.log(`src/${file} -> lib/${file}`)
    }
  })
})
.then(() => {
  console.log('done')
})

// src/a.js -> lib/a.js
// src/b.js -> lib/b.js
// done

License

MIT

babel-transform-dir's People

Contributors

dickie81 avatar kaelzhang avatar zapaiaavantrip avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

babel-transform-dir's Issues

Remove package-lock

The file is meant for apps, not libraries, and isn't even published to npm. You'll just end up with different versions than your consumers.

Race condition

A race condition is created due to Promise.all when there are similar paths:

path/to/file1.js
path/to/file2.js

fs-extra's mkdirs (within outputFile) won't be finished creating those dirs on the first file before any following file attempts to do the same. No error is thrown externally because fs-extra catches and checks if the dir exists.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.