Skip to content

Is it ok to refer to compiled JSX files in ReactConfig.cs? #90

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

Closed
rdebeasi opened this issue Feb 24, 2015 · 2 comments
Closed

Is it ok to refer to compiled JSX files in ReactConfig.cs? #90

rdebeasi opened this issue Feb 24, 2015 · 2 comments

Comments

@rdebeasi
Copy link

The react config file recommends that developers add references to JSX files:

// If you want to use server-side rendering of React components, 
// add all the necessary JavaScript files here. This includes 
// your components as well as all of their dependencies.
// See http://reactjs.net/ for more information. Example:
//ReactSiteConfiguration.Configuration
//  .AddScript("~/Scripts/First.jsx")
//  .AddScript("~/Scripts/Second.jsx");

Is it okay (or even preferable) to refer to the compiled files here instead? In my case, We're compiling JSX files to JS using grunt as part of our build process.

Do we get any performance benefits by referring to the compiled files instead of the JSX files? I assume that React.NET will compile JSX for use on the server side, but I'm curious whether this happens at runtime or at build time.

Thanks so much for building React.NET - it rocks!

@Daniel15
Copy link
Member

Go ahead and use compiled files there, that's perfectly fine. Just make sure there's no client-specific code in your bundles (eg. definitely don't include jQuery or anything else that touches document in there). I cover this in the Webpack docs on the site and might eventually add docs for Gulp/Grunt too.

Using precompiled files does result in performance benefits. In theory it means JSXTransformer doesn't even need to be loaded at runtime, so you have a lighter footprint. ReactJS.NET isn't quite there yet, using external JS files isn't as performant as it could be at the moment since it will still run your file through JSXTransformer even though it's not needed (since you've already transformed the file yourself). I'll have to think of a smart way to handle this, perhaps a second parameter to AddScript like doNotTransform that just loads the file directly without transformation.

@Daniel15
Copy link
Member

Going to close this since it's just a discussion/question, but please feel free to reply if you have any further questions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants