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

Gulp task? ES6 classes? #17

Open
kristianmandrup opened this issue Mar 5, 2017 · 6 comments
Open

Gulp task? ES6 classes? #17

kristianmandrup opened this issue Mar 5, 2017 · 6 comments

Comments

@kristianmandrup
Copy link

kristianmandrup commented Mar 5, 2017

Is there a gulp task for futurescript compilation?
I'd like to use it with Polymer using a custom build pipeline, here the one for es6 via babel

I guess I'd have to create my own little gulp task for futurescript! :)

gulp-marko-compile could be a good baseline with this guide

Btw, can/does FutureScript classes compile to ES6 compatible classes with extends?
Ie. can it generate something akin to this ES6 class based syntax for Polymer 2?

// Subclass existing element
class MyElementSubclass extends MyElement {
  static get is() { return 'my-element-subclass'; }
  static get properties() { return { /* properties metadata */ } }
  static get observers() { return [ /* observer descriptors */ ] }
  constructor() {
    super();
    ...
  }
  ...
}

// Register custom element definition using standard platform API
customElements.define(MyElementSubclass.is, MyElementSubclass);
@kristianmandrup
Copy link
Author

I created this gulp task for now. Haven't tested it yet.

https://github.com/kristianmandrup/gulp-futurejs-compile

Please review ;)

@zhanzhenzhen
Copy link
Owner

zhanzhenzhen commented Mar 5, 2017

FutureScript classes are compiled to ES6 class. But if you use Babel, it will not be ES6 classes. fus-ext classes are still using Babel (for compatibility reasons) so its classes are also not ES6 classes.

FutureScript's from is equivalent to ES6's extends. And it also supports static get. So it supports this kind of code. See the Class section in the manual.

@zhanzhenzhen
Copy link
Owner

zhanzhenzhen commented Mar 5, 2017

I'm not familiar with Polymer.

@zhanzhenzhen
Copy link
Owner

zhanzhenzhen commented Mar 5, 2017

Is there a gulp task for futurescript compilation?

FutureScript compiler itself isn't using any node modules like gulp. But if you want to know if you can compile FutureScript in a gulp task, yes you can use the fus command-line in it using child-process. For your "internal API" suggestion, OK I'll implement it in later versions (may be next version). Once implemented we can also use internal APIs.

@kristianmandrup
Copy link
Author

kristianmandrup commented Mar 5, 2017

I already created a small gulp plugin for compiling FutureScript code as noted in my last comment.
Will use it in my gulp build pipeline such as for Google Polymer 2 Web components.

Thanks for answering my questions about classes. Looks like I will have to first compile with FutureScript compiler then with Babel after?

@zhanzhenzhen
Copy link
Owner

Yes, I suggest using Babel, particularly if the code will be run on browsers.

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

2 participants