MatAtBread / fast-async

603 stars 21 forks source link

Strange "unexpected token" errors #3

Closed mnpenner closed 8 years ago

mnpenner commented 8 years ago

Sorry for being vague, but I think there is something funny going on with this plugin.

When I use these plugins,

'syntax-async-functions',
'transform-async-to-generator',
'transform-regenerator',
["transform-runtime", {
    "polyfill": true,
    "regenerator": true,
}],

My project compiles fine, but when I try with:

'syntax-async-functions',
['fast-async',{
    compiler: {
        promises: true,
        generators: false
    }
}],
["transform-runtime", {
    "polyfill": true,
    "regenerator": false,
}],

I get a bunch of errors like this:

ERROR in ./assets/scripts/lib/DynamicSelect.js
Module parse failed: /home/mpenner/Projects/webenginex/node_modules/babel-loader/index.js?{"presets":[],"plugins":["syntax-flow","syntax-trailing-function-commas","check-es2015-constants","transform-flow-strip-types","transform-es3-member-expression-literals","transform-es3-property-literals","transform-es5-property-mutators",["transform-es2015-modules-commonjs",{"loose":true}],"transform-class-constructor-call","transform-class-properties","transform-decorators","transform-export-extensions","transform-object-rest-spread","transform-exponentiation-operator","transform-es2015-arrow-functions","transform-es2015-block-scoped-functions","transform-es2015-block-scoping","transform-es2015-classes","transform-es2015-computed-properties","transform-es2015-destructuring","transform-es2015-for-of","transform-es2015-function-name","transform-es2015-literals","transform-es2015-object-super","transform-es2015-parameters","transform-es2015-shorthand-properties","transform-es2015-spread","transform-es2015-sticky-regex","transform-es2015-template-literals","transform-es2015-typeof-symbol","transform-es2015-unicode-regex","syntax-async-functions",["fast-async",{"compiler":{"promises":true,"generators":false}}],["transform-runtime",{"polyfill":true,"regenerator":false}]],"compact":false}!/home/mpenner/Projects/webenginex/assets/scripts/lib/DynamicSelect.js Line 71: Unexpected token
You may need an appropriate loader to handle this file type.
| var $ = require('jquery');
| 
| export {};
| export {};
| 
 @ ./assets/main.js 149:35-73

I'm not even sure what the syntax error is. Those empty export {};s weren't in my code, but I don't think they're a syntax error. And async isn't even used in this file. So I really have no idea what's going on, but I'm pretty sure it has something to do with fast-async.

matAtWork commented 8 years ago

I'm happy to have a look, but can you send me a short snippet or gist which re-creates the error?

mnpenner commented 8 years ago

I was talking to some of the Babel folk. There's actually a ticket open to do with transform-runtime. I think it runs process.exit() or something which causes some of those imports/exports to not be fully processed and it's causing some bugs in various transformers. I don't have the ticket number handy unfortunately, but I suspect the problem is there. kneden has a similar problem.

I don't have a snippet. I gave up on async and just rewrote my code to not use it. I was trying to get it to work in IE8 but regenerator wasn't working, so I thought I'd try this and then kneden. Too much time sunk, bailed out. Sorry :-) If I give it another whirl I'll make you a snippet.

matAtWork commented 8 years ago

No problem - good luck. FYI, we've had success with IE8 using nodent alone, so the code it generates works in IE8. https://github.com/MatAtBread/nodent