-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fix ES6 support using Babel::Transpiler #5
base: master
Are you sure you want to change the base?
Conversation
Tested on sprockets 3.7.1 with sprockets-es6 0.9.2, but should also work on sprockets 4.x with babel-transpiler gem. This also allows to use ES6 `export default` for defining components.
453e7e3
to
2a9dbdf
Compare
2a9dbdf adds support for |
@@ -30,7 +39,7 @@ def call(input) | |||
map = result['sourceMap'] | |||
|
|||
output << "'object' != typeof VComponents && (this.VComponents = {}); | |||
var module = { exports: null }; | |||
var module = { exports: null }, exports = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Babel uses the exports
object to store exports and then assigns exports['default']
to module.exports
.
There's a problem with While it works fine for detecting ES6 in sprockets, it breaks tooling like Vetur in VSCode, which only support How about autodetecting if Sending non-ES6 code through babel is pretty much a No-OP, so it doesn't really hurt. |
Thanks for your pr |
I think we can still use It is not unnecessary to support es6 we just need a var to assign object to it |
Your are right, What do you think about auto-detection of es6 support? I have already implemented it in my autodetect-es6 branch. |
I think auto-detection is not a good way. <script lang="javascript" es6>
module.exports = {
name: 'app',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script> |
That could work, I'll have to try it out. It could also be a implemented as a configuration setting. |
In this way, we can define |
I thought about doing it, but I didn't see the point because it's only one extra object defined in the scope of the IIFE. |
we can do it later. Split transpiler in to different files so we can have more clear code, and no extra object |
Tested on sprockets 3.7.1 with sprockets-es6 0.9.2, but should also work on sprockets 4 which also uses the babel-transpiler gem for es6 support.