Giter Site home page Giter Site logo

fly-esnext's Introduction

fly-esnext

Allows a flyfile.js to be written with new-age ES6 or ES7 syntax.

Install

npm install --save-dev fly-esnext

That's it! πŸŽ‰ You've now enabled async/await syntax for your flyfile.js!

Note: This will NOT compile your ES6 files into ES5. You must download and setup fly-babel for that.

Usage

A flyfile.js may also include require() statements (not shown).

// flyfile.js

export default async function () {
  await this.source('src/*.js') // etc...
}

export async function lint() {
  await this.source('src/*.js') // etc...
}

export async function styles(obj) {
  await this.source(obj.val || 'src/*.sass') // etc...
}

License

MIT Β© Luke Edwards

fly-esnext's People

Contributors

lukeed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tjbenton

fly-esnext's Issues

fly-esnext not applied

Hi,

I get this error after a fresh install:

> @ dev /Users/ngryman/Projects/noflash
> fly

stack:
  - ~/Projects/noflash/flyfile.js:1
  - (function (exports, require, module, __filename, __dirname) { import browserify from 'browserify'
  -                                                               ^^^^^^
  - SyntaxError: Unexpected token import
  -     at Object.exports.runInThisContext (vm.js 76:16)
  -     at Module._compile (module.js 528:28)
  -     at Object.Module._extensions..js (module.js 565:10)
  -     at Module.load (module.js 473:32)
  -     at tryModuleLoad (module.js 432:12)
  -     at Function.Module._load (module.js 424:3)
  -     at Module.require (module.js 483:17)
  -     at require (internal/module.js 20:19)
  -     at new Fly (~/Projects/noflash/node_modules/fly/lib/index.js 19:43)
  -     at Object.<anonymous> (~/Projects/noflash/node_modules/fly/lib/cli/spawn.js 37:9)
  -     at next (native)
  -     at tryCatcher (~/Projects/noflash/node_modules/bluebird/js/release/util.js 16:23)
  -     at PromiseSpawn._promiseFulfilled (~/Projects/noflash/node_modules/bluebird/js/release/generators.js 97:49)
  -     at Promise._settlePromise (~/Projects/noflash/node_modules/bluebird/js/release/promise.js 572:26)
  -     at Promise._settlePromise0 (~/Projects/noflash/node_modules/bluebird/js/release/promise.js 612:10)
  -     at Promise._settlePromises (~/Projects/noflash/node_modules/bluebird/js/release/promise.js 691:18)
message: Unexpected token import

I'm running fly through a npm run-script.

I've got the following fly packages as dependencies:

{
    "fly": "beta",
    "fly-autoprefixer": "^1.0.0",
    "fly-browserify2": "^2.0.1",
    "fly-esnext": "^2.0.0",
    "fly-sass": "^2.0.0"
}

Node version is 6.5.0.

Thanks!

Transform flyfile AST

Seems like right now, fly-esnext just replace some syntax constructions using regular expressions. It would be nice if it use babylon or uglify etc. to transfrom file AST, it will be more correct behavior for syntax transformations.

use async programatically

Is it possible to use this module to run programatically?

const fly = new Fly({
  plugins: [
    require('fly-typescript'),
    require('fly-clear'),
    require('fly-flatten'),
  ],

  tasks: {
    async default(fly) {
      yield fly.clear('dist');
      yield fly.source('server/templates/**/*')
        .flatten({ levels: 5 })
        .target('dist/server/templates');
    },
  }
})

await fly.start()

β€œTypeError: Cannot read property 'error' of undefined” when running: fly

Hello! I'm trying to run the following command:

$ ./node_modules/fly/cli.js -f flyfile.js

And I receive the following error:

stack: 
  - TypeError: Cannot read property 'error' of undefined
  -     at OptionManager.mergeOptions (~/Workspace/abc/node_modules/fly-esnext/node_modules/babel-core/lib/transformation/file/options/option-manager.js 126:28)
  -     at OptionManager.addConfig (~/Workspace/abc/node_modules/fly-esnext/node_modules/babel-core/lib/transformation/file/options/option-manager.js 107:10)
  -     at OptionManager.findConfigs (~/Workspace/abc/node_modules/fly-esnext/node_modules/babel-core/lib/transformation/file/options/option-manager.js 168:35)
  -     at OptionManager.init (~/Workspace/abc/node_modules/fly-esnext/node_modules/babel-core/lib/transformation/file/options/option-manager.js 229:12)
  -     at compile (~/Workspace/abc/node_modules/fly-esnext/node_modules/babel-core/lib/api/register/node.js 117:22)
  -     at normalLoader (~/Workspace/abc/node_modules/fly-esnext/node_modules/babel-core/lib/api/register/node.js 199:14)
  -     at Object.require.extensions.(anonymous function) [as .js] (~/Workspace/abc/node_modules/fly-esnext/node_modules/babel-core/lib/api/register/node.js 216:7)
  -     at Module.load (module.js 458:32)
  -     at tryModuleLoad (module.js 417:12)
  -     at Function.Module._load (module.js 409:3)
message: Cannot read property 'error' of undefined

The following are my dependencies with their respective version:

$ npm list --depth=0
[email protected] ~/Workspace/abc
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
└── [email protected]

Rewrite `import` statements

At the very least, raw imports can be done easily:

import foo from 'bar';
//=> var foo = require('bar');

Handling multiple and/or partial imports will be more problematic:

import { foo, bar } from 'baz';
//=> var foo = require('baz').foo;
//=> var bar = require('baz').bar;

Handling aliases is the next step:

import * as foo from 'bar';
//=> var foo = require('bar');

import { foo as bar } from 'baz';
//=> var bar = require('baz').bar;

Concerns

  • Handling default exports (β•―Β°β–‘Β°οΌ‰β•―

References

#4, wendux/fly#239, wendux/fly#159 (comment)

Doesn't get applied to nested required files.

We usually set up our projects like below and then just require the sub tasks by using fs.readdirSync and looping over the files. This package is only accounting for the flyfile.js file.

tasks
β”œβ”€β”€ build.task.js
β”œβ”€β”€ clean.task.js
β”œβ”€β”€ fonts.task.js
β”œβ”€β”€ images.task.js
β”œβ”€β”€ js.task.js
β”œβ”€β”€ modernizr.task.js
β”œβ”€β”€ server.task.js
β”œβ”€β”€ styles.task.js
β”œβ”€β”€ templates.task.js
└── watch.task.js
flyfile.js

I tried using babel-register and it will run the task but then fail fails with with this output.

[12:59:02] build failed because Cannot read property 'apply' of undefined
[12:59:02] Task chain was aborted!

packages

"babel-preset-latest": "~6.22.0",
"babel-preset-stage-0": "~6.22.0",
"babel-register": "~6.22.0",
"fly-esnext": "~2.0.0",
"fly": "~2.0.10-beta",

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.