GithubHelp home page GithubHelp logo

fly-babel's Introduction

fly-babel

Babel plugin for Fly.

Install

npm install --save-dev fly-babel

API

.babel(options)

All Babel options can be found here.

Note: For most cases, you only to think about presets, plugins, sourceMaps, minified, comments, and/or babelrc.

options.preload

Type: boolean
Default: false

Automatically loads all babel-related plugins & presets from package.json. Will also auto-configure Babel to use these packages. See the example for more.

Usage

Basic

exports.scripts = function * (fly) {
  yield fly.source('src/**/*.js')
    .babel({
      presets: ['es2015']
    })
    .target('dist/js')
}

Source Maps

You can create source maps for each file.

Passing true will create an external .map file. You may also use 'inline' or 'both'. Please see the Babel options for more information.

exports.scripts = function * (fly) {
  yield fly.source('src/**/*.js')
    .babel({
      presets: ['es2015'],
      sourceMaps: true //=> external; also 'inline' or 'both'
    })
    .target('dist/js')
}

Preloading

For the especially lazy, you may "preload" all babel-related presets and plugins defined within your package.json. This spares you the need to define your presets and plugins values manually.

Note: If you require a complex configuration, you need to define that manually. While other plugins & presets will continue to "preload", your manual definitions will not be lost.

exports.scripts = function * (fly) {
  yield fly.source('src/**/*.js')
    .babel({
      preload: true,
      plugins: [
        // complex plugin definition:
        ['transform-async-to-module-method', {
          'module': 'bluebird',
          'method': 'coroutine'
        }]
      ]
    })
    .target('dist');
  //=> after preloading:
  //=>   {
  //=>     presets: ['es2015'],
  //=>     plugins: [
  //=>       'transform-class-properties',
  //=>       ['transform-async-to-module-method', {...}]
  //=>     ]
  //=>   }
}

License

MIT © FlyJS

fly-babel's People

Contributors

hzlmn avatar lukeed avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

mrhack zadvornyi

fly-babel's Issues

no source map files are emitted

It seems that fly-babel plugin doesn't create .js.map files whether the sourceMaps option is set to true or "both"

Code snippet:

export async function builder() {
    await this
        .source("./**/*.es6")
        .babel({
            "stage": 1,
            "sourceMaps": true
        })
        .target("")
}

This package is broken after the fly 1.3.0 release

The latest update to fly(1.3.0) broken this package. Here's the stack trace for the error I'm getting when trying to use the latest version of fly.

stack:
  - ReferenceError: [BABEL] unknown: Unknown option: base.file. Check out http://babeljs.io/docs/usage/options/ for more info
  -     at Logger.error (~/Sites/styleguide.local/site/n/node_modules/babel-core/lib/transformation/file/logger.js 43:11)
  -     at OptionManager.mergeOptions (~/Sites/styleguide.local/site/n/node_modules/babel-core/lib/transformation/file/options/option-manager.js 307:20)
  -     at OptionManager.init (~/Sites/styleguide.local/site/n/node_modules/babel-core/lib/transformation/file/options/option-manager.js 506:10)
  -     at File.initOptions (~/Sites/styleguide.local/site/n/node_modules/babel-core/lib/transformation/file/index.js 243:89)
  -     at new File (~/Sites/styleguide.local/site/n/node_modules/babel-core/lib/transformation/file/index.js 159:72)
  -     at Pipeline.transform (~/Sites/styleguide.local/site/n/node_modules/babel-core/lib/transformation/pipeline.js 49:16)
  -     at Fly.<anonymous> (~/Sites/styleguide.local/site/n/node_modules/fly-babel/index.js 6:34)
  -     at ~/Sites/styleguide.local/site/n/node_modules/fly/lib/fly.js 317:48
  -     at [object Generator].next (native)
  -     at onFulfilled (~/Sites/styleguide.local/site/n/node_modules/co/index.js 65:19)
message: [BABEL] unknown: Unknown option: base.file. Check out http://babeljs.io/docs/usage/options/ for more info

bump & push to npm

@bucaran please update this to 0.7.0 or 0.6.1 & publish to npm.

The registry's latest copy is 0.6.0 and that doesn't include the babel fixes from my last PR.

Thanks!

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.