CodeKit2 icon indicating copy to clipboard operation
CodeKit2 copied to clipboard

[Feature request] Support JSX

Open Andreyco opened this issue 10 years ago • 60 comments

Since Reactjs is very popular, I'd like to see support for JSX in CK2.

For starters, reload page on JSX file save event. Yes, this can be hotfixed by adding .jsx into "Generic Page Extensions", but it's not the right solution.

Compiling JSX into pure JS would be pure awesomeness. FB provides tools to do that, which you can find here Allowing to use ES6 syntax with transpiling back to ES5 (using --harmony flag) would be even more awesome.

Thanks for consideration.

Keep on super good work you are doing! :)

Andreyco avatar May 02 '15 08:05 Andreyco

ok, I don't want to take this feature request TOO far, but many of the ReactJS implementations also use browserify/webpack type of "modular" implementation (being able to use modules from npm etc).

It would be great if CodeKit can support this too - too ambitious?

ericbae avatar May 11 '15 02:05 ericbae

+1000

watzon avatar May 28 '15 15:05 watzon

was actually surprised this wasn't already supported when I opened my new project in codekit today!

chrisdrackett avatar May 29 '15 04:05 chrisdrackett

+1

CallMeTuesday avatar Jun 05 '15 18:06 CallMeTuesday

+1

jitinl avatar Jun 27 '15 18:06 jitinl

Meanwhile, Facebook banned it's React-tools, which contained JSX transpiler in favor of Babel.

Babel transpiles ES6 (and part of ES7) into ES5, which allows us to write javascript of future right now. Also, it understands JSX, so no problem here.

Talking about implementation, I think it would be best to add record to "Special Language Tools", similar to Autoprefix, let's say.

Thus, original title could be "Add Babel support."

Andreyco avatar Jun 27 '15 20:06 Andreyco

I really wanted this in CodeKit so I "made it work" by renaming my .jsxfiles to .coffee and changing the CoffeeScript compiler in CodeKit to a custom CoffeeScript compiler - the Babel compiler. So CodeKit thinks it's compiling CoffeeScript files - but the files are in real jsx or ES6 and the compiler is the jsx compiler.

This is working for me - for JSX code as well as ES6 as far as I could try. Here's the code: https://github.com/jitinl/codekit-jsx-hack if anyone wants to check it out.

jitinl avatar Jun 28 '15 22:06 jitinl

That's a pretty cool hack actually. :+1:

ericbae avatar Jun 28 '15 22:06 ericbae

That is a nifty hack, but it's also not necessary. I spent a lot of time creating Hooks for exactly this sort of scenario. You can simply add a Hook to your project that says, "Anytime I save a JS file, do X". Hooks are meant for stuff like this, where people want to extend CodeKit without waiting for me to integrate everything.

bdkjones avatar Jun 28 '15 23:06 bdkjones

I actually thought of using hooks in the beginning. But the thing is that (as far as I understand) you can only add hooks after CodeKit finishes processing the files and not before. This created two problems that I can remember:

  1. If I am merging multiple files (using @codekit-prepend) - like a mix of plain JS files (say jquery.min.js) and my own JSX/ES6 files - CodeKit would try to merge all of them and then run my hook. This would mean that even something like jQuery gets compiled by Babel which is not required.
  2. I won't be able to use CodeKit's minification - that's because I need to minify after the compilation not before. Uglify will not be able to process the uncompiled JSX syntax anyways.

What I was really looking for is a hook that runs before CodeKit processes files and this hack was the only workaround I could come up with. This way Babel only compiles only the JSX/ES6 scripts (and leaves the rest alone), and minification works successfully.

But I guess if somebody does not need CodeKit's minification - and the letting all merged scripts go through Babel is not a problem, setting a hook is probably an easier task.

jitinl avatar Jun 29 '15 05:06 jitinl

You could simply call Uglify.js yourself from the Hook, after running everything through Babel.

On 28 Jun 2015, at 22:33, jitinl [email protected] wrote:

I actually thought of using hooks in the beginning. But the thing is that (as far as I understand) you can only add hooks after CodeKit finishes processing the files and not before. This created two problems that I can remember:

If I am merging multiple files (using @codekit-prepend) - like a mix of plain JS files (say jquery.min.js) and my own JSX/ES6 files - CodeKit would try to merge all of them and then run my hook. This would mean that even something like jQuery gets compiled by Babel which is not required.

I won't be able to use CodeKit's minification - that's because I need to minify after the compilation not before. Uglify will not be able to process the uncompiled JSX syntax anyways.

What I was really looking for is a hook that runs before CodeKit processes files and this hack was the only workaround I could come up with. This way Babel only compiles only the JSX/ES6 scripts (and leaves the rest alone), and minification works successfully.

But I guess if somebody does not need CodeKit's minification - and the letting all merged scripts go through Babel is not a problem, setting a hook is probably an easier task.

— Reply to this email directly or view it on GitHub https://github.com/bdkjones/CodeKit/issues/554#issuecomment-116443910.

bdkjones avatar Jun 29 '15 05:06 bdkjones

I agree - I could say create two hooks - one for Babel and one for uglify.js and that would work nicely (except that I won't be using the CodeKit interface for minifying anymore). But any help with the first problem? I do want to merge my files using @codekit-prepend but don't want all of them to run through the first hook (the compiler) - only the JSX ones.

jitinl avatar Jun 29 '15 05:06 jitinl

Well Babel should ignore any JS syntax that doesn’t need to be transpiled, correct?

On 28 Jun 2015, at 22:39, jitinl [email protected] wrote:

I agree - I could say create two hooks - one for Babel and one for uglify.js and that would work nicely (except that I won't be using the CodeKit interface for minifying anymore). But any help with the first problem? I do want to merge my files using @codekit-prepend but don't want all of them to run through the first hook (the compiler) - only the JSX ones.

— Reply to this email directly or view it on GitHub https://github.com/bdkjones/CodeKit/issues/554#issuecomment-116448457.

bdkjones avatar Jun 29 '15 06:06 bdkjones

I agree it should, theoretically. I just tried running it on jQuery and it did make some changes but very few (9 lines were changed) and I am guessing they would probably be harmless. I was actually expecting it to make loads of changes - I guess I was wrong. That said, I quickly created a hook for running Babel and tested it in my project - it does something to the React-Router library code that I am using and that starts throwing some error. My guess is Babel is modifying the React-Router code in a way that it does not work anymore. I think it has something to do with the new ES6 module system and the module system that React-Router is using.

Maybe I made a mistake somewhere and I am not sure, but at this moment the CoffeeScript hack feels significantly faster (since it does not have to compile the library scripts), safer and is easy for me to use so I will keep on using it :)

Thanks

jitinl avatar Jun 29 '15 11:06 jitinl

Having at least gotten the attention of Bryan, can we find out whether Babel will be supported in the future releaes of CodeKit? :) (pretty please?)

ericbae avatar Jun 29 '15 11:06 ericbae

Yes.

Sent from my iPhone

On Jun 29, 2015, at 04:09, Eric Bae [email protected] wrote:

Having at least gotten the attention of Bryan, can we find out whether Babel will be supported in the future releaes of CodeKit? :) (pretty please?)

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

bdkjones avatar Jun 29 '15 17:06 bdkjones

+1

meetbryce avatar Jul 14 '15 04:07 meetbryce

@jitinl I've made a post on using CodeKit's hooks to transpile babeljs files, not sure if it'll be much/any faster than your current workaround, but this post does explain at the bottom how to use @codekit-prepend per usual and still be able to use CodeKit's built-in minification workflow.

@bdkjones The only issue with hooks I've had so far is not being able to "Anytime I save a JS file, do X" due to CK needing to process the file in some way before a hook is triggered, the options being The full path of any processed file, The filename of any processed file, and The output path of any processed file

It would be amazing to see The full path of any saved file and The filename of any saved file :)

I've tried to work around this on JS files with JSHint/JSLint being the The filename of any processed file trigger, which does trigger the hook, but unfortunately CK_INPUT_PATHS is not set. This feels like a bug so I've submitted an issue https://github.com/bdkjones/CodeKit/issues/574 but I guess this could be by design?

subhaze avatar Jul 26 '15 21:07 subhaze

Hi Brian,

Do you have an ETA on when Babel/JSX will be added?

Thanks!

mewejo avatar Sep 09 '15 09:09 mewejo

+1

arthurperton avatar Oct 06 '15 10:10 arthurperton

+100

ghost avatar Oct 10 '15 07:10 ghost

+1

mwaustin avatar Oct 15 '15 21:10 mwaustin

+1

fmaida avatar Nov 07 '15 16:11 fmaida

+1

kylegillen avatar Dec 01 '15 20:12 kylegillen

+1

xiaohenry avatar Dec 28 '15 05:12 xiaohenry

++

marioluevanos avatar Jan 27 '16 03:01 marioluevanos

+1

breadadams avatar Jan 29 '16 17:01 breadadams

+1

jschuur avatar Feb 06 '16 14:02 jschuur

+2

jamespwolpert avatar Feb 06 '16 18:02 jamespwolpert

+1

leojh avatar Feb 09 '16 20:02 leojh

+1

PrimozRome avatar Feb 12 '16 08:02 PrimozRome

So, Foundation (for Sites) 6.2 was launched yesterday, and as all it's JS is now written in ES2015, it requires Babel to build. Would be good to have an ETA on this, so Foundation users can decide whether they need to look at using Gulp for Foundation.

purplespider avatar Feb 27 '16 11:02 purplespider

The ETA is soon-ish.

bdkjones avatar Feb 27 '16 19:02 bdkjones

Oh, I just said hi on twitter. nice to see this!

ml242 avatar Mar 01 '16 20:03 ml242

+1

whtsky avatar Mar 06 '16 07:03 whtsky

+1

nick-skriabin avatar Mar 11 '16 22:03 nick-skriabin

I also just updated a project to Foundation 6.2.. now i'm stuck cause I can't minify javascript :( Hoping the update with babel is out soon.

dmcgrew avatar Mar 17 '16 12:03 dmcgrew

It's April now, any more news on the ETA?

ties-s avatar Apr 03 '16 11:04 ties-s

I've had to resort to learning gulp.. well trying to anyway. What a major pain that is compared to using CodeKit. Still can't use Foundation 6.2.

dmcgrew avatar Apr 03 '16 12:04 dmcgrew

+1 my hook methods for babel integration are quirky and I have been resorting to manual transpiling.

robstown avatar Apr 11 '16 22:04 robstown

Pay attention to the release notes coming later this week. Things are coming.

bdkjones avatar Apr 11 '16 22:04 bdkjones

:)

On Mon, Apr 11, 2016 at 6:18 PM, Bryan Jones [email protected] wrote:

Pay attention to the release notes coming later this week. Things are coming.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/bdkjones/CodeKit/issues/554#issuecomment-208590331

robstown avatar Apr 11 '16 22:04 robstown

This is retroactively why I've been procrastinating on my ReactJS project.

glennpeters avatar Apr 12 '16 23:04 glennpeters

@glennpeters haha that's the excuse we're all using 😉

On a side note, there are some great React.js tutorials out there that teach you how to get it running with gulp (via terminal). Not trying to steer anyone away from Codekit, it's great, but this gives us (or atleast gave me) an opportunity to learn another way of building/compiling .jsx.

breadadams avatar Apr 20 '16 09:04 breadadams

I should do that while I'm waiting / procrastinating. Useful job skill, at the very least.

glennpeters avatar Apr 20 '16 17:04 glennpeters

I sure hope you meant to say "Pay attention to the release notes coming later next week. Things are coming." Or did I miss something last week?

bfkss avatar Apr 21 '16 17:04 bfkss

Well, I'm hoping for this week. But you never know. Updating the engines in 2.x, testing and shipping is more of a process than you'd think. But seriously, it's coming...

hanginthere

bdkjones avatar Apr 21 '16 17:04 bdkjones

You are like the worst at keeping secrets

guymeyer avatar Apr 21 '16 17:04 guymeyer

@bdkjones I appreciate your hard work, and especially how your hard works means I have to do less hard work.

glennpeters avatar Apr 21 '16 17:04 glennpeters

We'll just Elon Musk it. "This isn't the final design." "This isn't the real steering wheel." "We're going to tweak things." "This is pretty much going to be a Chevy Suburban when we actually launch."

bdkjones avatar Apr 21 '16 17:04 bdkjones

If it goes from 0-60 in 2.8s, you can give it whatever steering wheel you want. I can't wait for plaid mode ...and native JSX/ES6/ES7 transpiling.

On Thu, Apr 21, 2016 at 1:28 PM, Bryan Jones [email protected] wrote:

We'll just Elon Musk it. "This isn't the final design." "This isn't the real steering wheel." "We're going to tweak things." "This is pretty much going to be a Chevy Suburban when we actually launch."

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/bdkjones/CodeKit/issues/554#issuecomment-213027941

robstown avatar Apr 21 '16 21:04 robstown

I could just make out what @bdkjones is saying in that cryptic screenshot...

"I've been working on CodeKit 3 for a year and I can't wait to release it. But before I do, I need some brave......."

Brave what?!?!? suspense is killing me.

ericbae avatar Apr 21 '16 23:04 ericbae

@bdkjones I, too, appreciate your hard work. And I don't want to bother you, it's just the excitement that gets me :)

@ericbae since it says "CodeKit 3 Beta" I'd guess some "brave beta testers"? And I'm totally up for that

bfkss avatar Apr 22 '16 10:04 bfkss

I hereby volunteer to be a 'not-so-brave' beta tester for Version 3.0 with the precondition that I am granted immunity from the "shipped bug" penalty established for the release of Version 2.0, ie:

"For every bug that ship[s], [ @bdkjones ] will kill a beta tester."

robstown avatar Apr 27 '16 19:04 robstown

http://incident57.com/codekit/3

bdkjones avatar Apr 29 '16 00:04 bdkjones

So really late hit but NOW I really want to play with CK3. Hopefully together with Babel/React/JSX support you will be able to incorporate a scaffolding tool like Facebook's new create-react-app. That would make CK3 da bomb!! (no actual bombs or terrorists were engaged in writing this comment)

cyberis avatar Sep 09 '16 21:09 cyberis

I'd've been playing with CK3 for months now, except I didn't think I had time for bug reports. (especially since I haven't had enough time for home development), but I hope it's moving along nicely.

glennpeters avatar Sep 09 '16 21:09 glennpeters

This is not the correct place to discuss version 3.0. Those comments should be directed to the closed 3.0 repo.

bdkjones avatar Sep 09 '16 21:09 bdkjones

Oops, sorry about that.

glennpeters avatar Sep 09 '16 21:09 glennpeters

+1

zhenyulin avatar Sep 13 '16 16:09 zhenyulin