Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use this with ES6 modules? #69

Open
sferoze opened this issue Feb 27, 2016 · 3 comments
Open

Can I use this with ES6 modules? #69

sferoze opened this issue Feb 27, 2016 · 3 comments

Comments

@sferoze
Copy link

sferoze commented Feb 27, 2016

I really want to use coffeescript again but I am using the modules beta dev of Meteor.

This means I can import pacakges and such.

But I am not sure if it will work with coffeescript.

Any idea?

@jsdf
Copy link
Owner

jsdf commented Apr 16, 2016

coffee-react-transform won't be any different to normal coffeescript. I'm not sure how the Meteor modules support works, but basically you need to figure out what ES5 javascript code Meteor converts the ES6 import statement into and just write that in coffeescript. Eg. if it's like babel, it will basically convert an import statement into a require() statement.

@jeffmicklos
Copy link

jeffmicklos commented Apr 22, 2016

I am in a similar situation and was wondering if there is a feasible way out... I am backticking my ES6 import and export statements in my CoffeeScript, which SystemJS later picks up and does its magic with. I am running into an issue of: Got an unexpected exception from the coffee-script compiler. The original exception was: Error: Parse Error: Line 1: Illegal import declaration, supposedly because the React transformer doesn't know how to deal with ES6 Module syntax. Is there some option I can pass that allows the ES6 import and export statements? I did some digging and didn't come up with anything :/ Example code:

`import BaseComponent from 'base_component.js'`

class Header extends BaseComponent
  @propTypes:
    username : React.PropTypes.string
    ...

  constructor: (props) ->
    super
    ...

`export default Header`

Hate to make it seem like I am asking you to do my work for me, I just feel that you are the most qualified person to answer such questions! Thanks!

@jsdf
Copy link
Owner

jsdf commented Apr 22, 2016

coffee-react-transform will leave these statements untouched. coffee-script will also just pass them straight through. What will process the es6 import syntax? No browser supports it natively yet. Have you configured SystemJS to know that it needs to apply ES6 transpilation (eg. babel or traceur) to the output of the coffee-script compiler? SystemJS itself doesn't understand ES6 import/export syntax directly, it first runs a transpiler and then whatever that outputs in place of import/export is what it understands at runtime.
You could configure SystemJS to apply babel processing to the output of coffeescript. Regardless, coffee-react-transform will have no impact on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants