-
Notifications
You must be signed in to change notification settings - Fork 9
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
Better ES6 support #15
Comments
Would the export format be the object literal of component options? |
Yeah, I was thinking like this: import fade from 'ractive-transitions-fade';
export default {
data: () => ({
// ...
}),
onrender () {
// ...
},
myMethod () {
// ...
},
transitions: { fade }
}; It would have to get rewritten by the loader (since the default export is the return value of |
👍 |
The more I think about it, the more I like sticking with options over extending a class. That way people can use whatever strategy they like to manage creating instances. However, as a coding sugar convenience, maybe we add a check for constructor function and instantiate so we get the comma-less coding style: import fade from 'ractive-transitions-fade';
export default class MyComponent {
data: () => ({
// ...
})
onrender () {
// ...
}
myMethod () {
// ...
}
transitions: { fade }
}; |
Ah, interesting. Is that even possible though? I don't think you can create a class with non-method properties – Babel's REPL discards the string, number and object from this example. |
Oh right. 😭 You can add them after the the prototype (which defeats the purpose of a nicer syntax) or I suppose add them as gets: get transitions() { return { fade }; } |
@martypdx useful additions. I don't think it helps us though, because we're not in a position to transpile that syntax (even if we were comfortable bundling a parser, Acorn – which is the most likely candidate – doesn't support it). Is there much of a benefit to supporting class syntax? Commas aside, I can't think of a situation where it doesn't result in more code, and it seems a bit disingenuous and magical (since you wouldn't actually be using the class you exported) |
Would be good to support
export default
syntax alongsidecomponent exports =
, and have better support forimport
statements (at present they work in an ES6-ified build chain, but only really by accident – you can't author using ES6 imports and expect the component to work in anyone else's environment).For good measure, it'd make sense to support
<script type='module'>
, since linters and highlighters should probably complain if they see imports and exports inside a regular script.The text was updated successfully, but these errors were encountered: