Khan / Prototope

Swift library of lightweight interfaces for prototyping, bridged to JS
http://khan.github.io/Prototope
230 stars 18 forks source link

[Hold] Transform JavaScript with Babel before running #79

Closed sophiebits closed 9 years ago

sophiebits commented 9 years ago

This lets you use let/const, arrow functions, and more.

I updated all the examples that I could figure out how to run so they use let/const. Also threw in an arrow function for fun, though there weren't many short functions so using them elsewhere is more a matter of taste.

NachoSoto commented 9 years ago

Nice :D

saniul commented 9 years ago

@spicyj, awesome! :+1:

Sent from my iPhone

On 16 Apr 2015, at 19:53, Ben Alpert notifications@github.com wrote:

This lets you use let/const, arrow functions, and more. Line numbers in error messages are wrong now though...

I updated all the examples I could figure out how to run to use let/const. Also threw in an arrow function for fun, though there weren't many short functions so using them elsewhere is more a matter of taste.

You can view, comment on, or merge this pull request online at:

https://github.com/Khan/Prototope/pull/79

Commit Summary

Transform JavaScript with Babel before running File Changes

M Examples/Animated Gif/AnimatedGif.js (4) M Examples/Behaviors/main.js (20) M Examples/CameraLayer/main.js (6) M Examples/Color Puddles/main.js (22) M Examples/Hello Color/Hello Color.js (8) M Examples/Masking/Masking.js (28) M Examples/ShapeLayer/ShapeLayer.js (20) M Examples/SquishyBall/main.js (61) M Examples/TestInsets/main.js (4) M Examples/TestText/main.js (10) M Prototope.xcodeproj/project.pbxproj (4) M PrototopeJSBridge/Context.swift (12) A ThirdParty/babel/README.md (5) A ThirdParty/babel/browser-polyfill.js (5) A ThirdParty/babel/browser.js (73) Patch Links:

https://github.com/Khan/Prototope/pull/79.patch https://github.com/Khan/Prototope/pull/79.diff — Reply to this email directly or view it on GitHub.

jbrennan commented 9 years ago

Can you sell me on the benefits of using this? Debugging of prototypes is unfortunately pretty challenging and often the line number errors are a last bastion of helpfulness in those situations (I wouldn’t want to lose them).

andymatuschak commented 9 years ago

:heart: :heart: @spicyj!!!

@jbrennan: It lets us use features from JS ES6 without waiting for JavaScriptCore to finish implementing them. Being able to use arrows would be freaking sweet! I believe @spicyj implemented this because I was complaining about JavaScript's nutso variable scope semantics (variables declared in statement blocks [like within a for] have function scope, not block scope!!), and let fixes that.

It looks like we could preserve line numbers by using https://github.com/mozilla/source-map/. Will try to take a look at that this weekend!

jbrennan commented 9 years ago

I’m going to vote we hold on merging this until we can get line numbers working. I agree scope is whacko in JS but I think it’s more tolerable than having incomprehensibler errors. :neckbeard:

andymatuschak commented 9 years ago

👍

On Apr 17, 2015, at 8:37 AM, Jason Brennan notifications@github.com wrote:

I’m going to vote we hold on merging this until we can get line numbers working. I agree scope is whacko in JS but I think it’s more tolerable than having incomprehensibler errors.

— Reply to this email directly or view it on GitHub.

sophiebits commented 9 years ago

^^ Now updated with source map support. :)

saniul commented 9 years ago

👍❤️❤️❤️

andymatuschak commented 9 years ago

dammit @spicyj :D

sophiebits commented 9 years ago

I figured that it would be easier for me to get the JS infra set up here… feel free to make changes from here if you like though. :)

andymatuschak commented 9 years ago

Oh my gosh and you added stack traces to the protonopes too. This is so lovely! Arrow functions, better scope semantics, and better diagnostics! :heart: :ship:

andymatuschak commented 9 years ago

how to github