Giter Club home page Giter Club logo

duo-babel's Introduction

Build Status

duo-babel

duo-plugin for babel.

Installation

$ npm install duo-babel

Usage

From the CLI:

$ duo --use duo-babel

Using the API:

var Duo = require('duo');
var babel = require('duo-babel');

Duo(__dirname)
  .entry('index.js')
  .use(babel())
  .run(function (err, results) {
    // ...
  });

API

babel([options])

Initialize a duo plugin. Available options:

  • extensions a list of file extensions that should be transpiled (default: ['.js', '.jsx', '.es', '.es6'])
  • onlyLocals specify that any remotes should not be transpiled
  • only a list of glob patterns to only transpile
  • ignore a list of glob patterns to not transpile (the opposite of only)
  • anything else is passed directly to babel

Selective Transpiling

In many cases, onlyLocals is needed early on. Your local scripts need to be transpiled, but most of your dependencies don't need it. However, as time goes on and you publish your own dependencies using ES6, you'll need something more selective.

You can add an array as either only or ignore (not both) to selectively enable babel's transpilation.

Your patterns should match the directory structure that duo uses. (and that you can see on disk)

  • lib/**.js will match any JS file in the local lib dir
  • components/lodash-lodash@*/**.js will match any version of lodash
  • components/component-*/**.js will match anything in the component organization.

Source Maps

ES6 source-maps are turned on automatically when duo has enabled source-maps, this feature can be disabled by explicitly setting the sourceMaps option.

License

The MIT License

Copyright (C) 2014 BDO a.s <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

duo-babel's People

Contributors

dominicbarnes avatar hkjels avatar rivergrimm avatar sebmck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

duo-babel's Issues

chokes with .babelrc files

.babelrc

{
  "presets": [ "es2015", "react" ],
  "plugins": [
    [
      "transform-react-jsx", {
        "pragma": "element"
      }
    ]
  ]
}

output:

~/dev/src/github.com/segmentio/icons on master [!] ∴ ./node_modules/.bin/duo --use ./preview/duo-plugins.js index.js 

        using : babel
     building : index.js
        using : compatibility
        using : stoj
        error : Error: [BABEL] /Users/stephenmathieson/dev/src/github.com/segmentio/icons/index.js: Unknown option: /Users/stephenmathieson/dev/src/github.com/segmentio/icons/.babelrc.presets
    at Ware.babel (/Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo-babel/index.js:78:13)
    at Ware.<anonymous> (/Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo/node_modules/ware/node_modules/wrap-fn/index.js:75:16)
    at Ware.<anonymous> (/Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo/node_modules/ware/node_modules/wrap-fn/index.js:57:27)
    at next (/Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo/node_modules/ware/lib/index.js:85:20)
    at Ware.run (/Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo/node_modules/ware/lib/index.js:88:3)
    at Duo.<anonymous> (/Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo/node_modules/thunkify/index.js:43:12)
    at Duo.next (/Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo/node_modules/co/index.js:90:21)
    at /Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo/node_modules/co/index.js:93:18
    at /Users/stephenmathieson/dev/src/github.com/segmentio/icons/node_modules/duo/node_modules/co-fs/node_modules/thunkify/index.js:28:12
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

but:

 ~/dev/src/github.com/segmentio/icons on master [!] ∴ rm .babelrc 

 ~/dev/src/github.com/segmentio/icons on master [!] ∴ ./node_modules/.bin/duo --use ./preview/duo-plugins.js index.js 

        using : babel
     building : index.js
        using : compatibility
        using : stoj
        built : index.js
        wrote : index.js

 ~/dev/src/github.com/segmentio/icons on master [!] ∴ 

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.