lukeed / fly-esnext

Allow for ES6 and ES7 support throughout a Fly environment.
Other
12 stars 1 forks source link

fly-esnext not applied #4

Open ngryman opened 8 years ago

ngryman commented 8 years ago

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!

lukeed commented 8 years ago

Hey @ngryman, thanks for editing. It makes much more sense now 😸

This plugin only parses async/await functions & rewrites into generator/yield pairings.

You'd have to require() any external dependencies, as there's too much variability in capturing and rewriting import statements.

lukeed commented 8 years ago

If you want to post your flyfile.js contents, I can give you a definitive answer.

ngryman commented 8 years ago

@lukeed I've already tried to replace imports with requires without success. Then I get the following error:

stack:
  - ~/Projects/noflash/flyfile.js:24
  - export async function build() {
  - ^^^^^^
  - SyntaxError: Unexpected token export
  -     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 export
lukeed commented 8 years ago

@ngryman Hmmm.... I just ran this flyfile on 6.5 and 6.9.1 without any problems.

Since I don't know if there are any syntax errors within yours, do you mind running this one & tell me if it works?

Thanks!

ngryman commented 8 years ago

Ok, I figured it out!

I had a syntax error (missing colon) in my flyfile.js. It seems that any error thrown is somehow catched by fly-esnext and reports the misleading one I've pasted above.

lukeed commented 8 years ago

Okay, then that makes sense. That's why your second trace (with the export error) occurred on line 24.