treycordova / nativejsx

JSX to native DOM API transpilation. :yellow_heart: <div> ⟹ document.createElement('div')!
MIT License
154 stars 14 forks source link

Transpiling JSX file(s) in place #10

Closed cantide5ga closed 8 years ago

cantide5ga commented 8 years ago

Thanks for the fantastic library!

A useful tweak in the CLI would allow for the argument for --output to be inferred, considering this usage to recursively find files with a given root: nativejsx $(find . -name '*.jsx')

Looks like this just would be a small change where outputDirectory could be optional and determined in compile with path.dirname(file);

Any caveats with this? Are you accepting PR's? I've been working with this locally all morning.

As an aside, I'm curious on how you use this in your build flow. My code goes through a transpilation from TypeScript (preserving jsx syntax) and then running through your lib on *.jsx files. The only issue here is that it leaves the old JSX files lying around after JS files are generated. Would it be out of scope to also provide a clean-up (e.g. unlink) of source JSX? I'm thinking yes and might be better suited for an additional build tool or script.

treycordova commented 8 years ago

Glad you're liking the library, and I'm most definitely taking PRs!

I'd like to point out that cleanup does sound out of the scope of this library. That's best suited to your needs specifically.

For me, the Webpack configurations and bundling are how I've been dealing with nativejsx compilation. The nativejsx-loader takes care of the dependency inclusion in a simplified manner, which is a big plus (i.e. instead of including setAttributes and appendChildren per file using the prototypes option, they become modules).

Feel free to improve the CLI with what you've suggested. I'd help, but life's got me at the moment. 😄

cantide5ga commented 8 years ago

Thanks for the info on your workflow. PR sent!