<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[NFL Engineers - Medium]]></title>
        <description><![CDATA[#NFLengineers - Medium]]></description>
        <link>https://medium.com/nfl-engineers?source=rss----7814fcdf1ad5---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>NFL Engineers - Medium</title>
            <link>https://medium.com/nfl-engineers?source=rss----7814fcdf1ad5---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:06:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/nfl-engineers" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[NFL ♥ Codemods: Migrating a Monolith]]></title>
            <link>https://medium.com/nfl-engineers/nfl-codemods-migrating-a-monolith-1e3363571707?source=rss----7814fcdf1ad5---4</link>
            <guid isPermaLink="false">https://medium.com/p/1e3363571707</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Daniel Howard]]></dc:creator>
            <pubDate>Mon, 14 Mar 2016 13:01:02 GMT</pubDate>
            <atom:updated>2016-03-14T13:01:01.671Z</atom:updated>
            <content:encoded><![CDATA[<p>You <a href="https://medium.com/nfl-engineers/nfl-react-84e9cd11d384#.s569vjz6f">may have heard</a> that we started using React in production over a year ago at the NFL. If you’ve been using it too then you know a <em>lot</em> has changed in that time: React itself went from version 0 to 15 (not really, but really), React Router introduced dynamic routing, inline styles entered our collective good graces after many years in the <a href="http://webdesign.about.com/od/css/a/aa073106.htm">doghouse</a>, and the React ecosystem in general grew by leaps and bounds. To say it’s been an exciting year would be an understatement.</p><p>Of course, that excitement hasn’t come without a few headaches. The NFL web team maintains nine React projects in one monolithic repository. As much as we want to keep them all shiny and up to date, it just isn’t feasible (or sane) to comb through that much code every time there’s a new syntax for refs or a new routing paradigm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*WQyZZz5xWVxLn9YPkanB0w.jpeg" /><figcaption>The hardest part is knowing when to let go (of your code)</figcaption></figure><p>Which means that when we decide to go for it, we do it all at once, like ripping off a band-aid. We recently packaged about six months worth of minor updates into one exhaustive migration. Most of the changes were small and repetitive, like modifying every &lt;Link&gt; tag to support the latest React Router, or massaging all of our styles a bit as we crossed over from <a href="https://github.com/kodyl/stilr">Stilr</a> to <a href="https://github.com/FormidableLabs/radium">Radium</a>. The point is, the updates we had to make weren’t large or complex, but they were <em>everywhere</em>.</p><h3><strong>Enter react-codemod</strong></h3><p>Not long after we started quietly panicking, we came across a project by Facebook called <a href="https://github.com/reactjs/react-codemod">react-codemod</a>. Every so often React comes out with breaking changes in its API, and react-codemod is a series of scripts that go through your code for you and make the necessary updates (the technology behind it is outside the scope of this article, but <a href="https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb#.z1vbd1ygo">it’s pretty awesome</a>).</p><p>Using react-codemod as a guide, we began writing our own scripts to kickstart the migration process. They all follow the same basic structure: parse your code into an <a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree">abstract syntax tree</a>, edit the tree, and print out the new code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61b16bd9661bc032760671d3e2a0875d/href">https://medium.com/media/61b16bd9661bc032760671d3e2a0875d/href</a></iframe><h3>Baby Steps</h3><p>We started off small: take something that could be fixed with a simple find/replace, but handle it via codemod. The first item we chose to tackle was a self-inflicted wound. We had open-sourced one of our libraries <em>(yay!)</em> so all of the imports had to change <em>(boo)</em> from <strong>@nfl/gridiron/addons</strong> to <a href="https://github.com/nfl/react-helmet"><strong>react-helmet</strong></a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/614a46ab645155b41bce676f9c989bff/href">https://medium.com/media/614a46ab645155b41bce676f9c989bff/href</a></iframe><h3>Stepping It Up</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*vge9vSyRyZsdes29B3LxTw.jpeg" /><figcaption>Once we had the basics down, it was time to step our game up</figcaption></figure><p>Once we had the first few scripts in place, it was time to kick things up a notch. <a href="https://github.com/benjamn/ast-types">ast-types</a>, the technology behind react-codemod, gave us control over every aspect of our code, from method calls to ES7 decorators to JSX tags and attributes. Each new discovery came with a sigh of relief, since more automation up front meant less grunt work later.</p><h4><strong>CSS classNames to inline styles</strong></h4><p>As I mentioned, we switched to Radium for styling, which meant moving from CSS to inline styles. When it came to applying those styles, the most common use case involved switching out the <strong>className </strong>attribute for <strong>style</strong> and using the spread operator to create a style object:</p><pre><strong>// before (using the classNames library to combine classes)</strong><br>&lt;input className={classNames(styles.one, styles.two)} /&gt;<br><br><strong>// after</strong><br>&lt;input style={{...styles.one, ...styles.two}} /&gt;</pre><p>And the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d9a11b13964359a26030fcf04d0db57/href">https://medium.com/media/5d9a11b13964359a26030fcf04d0db57/href</a></iframe><h4><strong>Upgrading React Router</strong></h4><p>We also upgraded React Router, which meant getting rid of named routes and switching over to an internal route helper.</p><pre><strong>// before</strong><br>&lt;Link to=”superbowl” params={linkParams}&gt;{game.year}&lt;/Link&gt;</pre><pre><strong>// after: route.for() is the internal helper we created</strong><br>&lt;Link to={route.for(“superbowl”, linkParams)}&gt;{game.year}&lt;/Link&gt;</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95ea1371476656a0376fbaf9bd7f5d96/href">https://medium.com/media/95ea1371476656a0376fbaf9bd7f5d96/href</a></iframe><h3>Taking It Further</h3><p>The last item we had to address stemmed from a central piece of our new architecture: <a href="http://jspm.io/">jspm</a>. When you import something in Node, you aren’t required to be too specific. You can point to a file, a directory, or an external module, and Node will go through <a href="https://nodejs.org/docs/latest/api/modules.html#modules_all_together">a bunch of steps</a> to figure out what you want to import. This is fine if you’re using a javascript bundling tool like <a href="https://webpack.github.io/">Webpack</a>, but jspm loads every file individually via HTTP. For us, this meant changing all of our imports from ambiguous to explicit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6a2ebe6ca26244d25250e5e1fe06fa8/href">https://medium.com/media/a6a2ebe6ca26244d25250e5e1fe06fa8/href</a></iframe><p>It would have taken forever to go through all of the imports in our code by hand, but codemod made it easy. We just grabbed all imports coming from our own /src directory (i.e. not node packages) and then used the <a href="https://www.npmjs.com/package/resolve">resolve</a> module to determine the full path to the file. Problem solved!</p><p>Throughout this process we also found a number of “alias” index files, which did nothing but import and export a sibling. They had been there for the sake of those ambiguous imports, but now we could remove code and computational overhead by getting rid of them. You can think of the imports as a linked list of A → B → C. We needed to remove B, and point straight from A to C.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*5dPWJCpVq2TvSMvlkRqxLw.jpeg" /><figcaption>You NEVER go more than two imports deep</figcaption></figure><p>This involved following our imports down a couple levels. Specifically, any time we came across an imported file named index.js, we then scanned the contents of <em>that</em> file. If it was an alias, we would resolve the file that it was importing, point to that instead, and mark the index file for deletion. Generally a codemod script will treat each individual file in isolation, but this particular task forced us to reach out into the surrounding code for the information we needed. You can check out the <a href="https://github.com/nfl/wildcat-codemod/blob/master/transforms/resolve-relative-imports.js">full script</a> but here is the test for alias files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/94c4db63f4fd59388f7bcea459d5d8f8/href">https://medium.com/media/94c4db63f4fd59388f7bcea459d5d8f8/href</a></iframe><h3>Cleaning Up</h3><p>To get rid of those extra files we brought in a tool called <a href="https://github.com/shelljs/shelljs">shelljs</a> which, as its name would imply, brings all your favorite shell commands into javascript land. This was useful for removing those extra index files and handling a couple other tidying-up tasks, like renaming our .jsx files to .js for the sake of uniformity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eeab85c189bd36be7d3a51a589141f93/href">https://medium.com/media/eeab85c189bd36be7d3a51a589141f93/href</a></iframe><p>And with that, our migration was complete!</p><h3>The Aftermath</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TAEf-1mODNDZGN_vCWurBA.jpeg" /><figcaption>A photo of me after all of this was over</figcaption></figure><p>Migrating our codebase was a long process (even the article about it is long, sorry), and in the end automation only got us so far. Certain complex tasks required human intervention, and other adjustments were so trivial that scripting them didn’t make sense from a pragmatic standpoint.</p><p>Still, the vast majority of the work lay in a sweet spot somewhere in the middle, and with these new automation tools at our disposal we’ll be able to keep our stack more up-to-date than ever. Gone are the days of waiting to deal with all migration issues at once; we can now handle things in a more modular way as each situation arises (if the term wasn’t already taken I would dub this the “continuous integration” approach).</p><p>We’ve just scratched the surface of what can be done with codemod and ast-types. We used them to migrate existing code, but there’s no reason they can’t go through your code and stub out unit tests customized to your preferences, or combine with eslint to clean up your code as you write it. Maybe you just need a script to switch out all your images with pictures of Leonardo DiCaprio <em>(actually that one’s done, DM me if you want it). </em>What I’m getting at is that the list goes on and on, and we’re excited to see where else we can take this newfound toolset.</p><h4>Our codemod project can be viewed <a href="https://github.com/nfl/wildcat-codemod">here</a>, we encourage you to check it out!</h4><p><em>Images property of (in order) Paramount Pictures, New Line Cinema, Warner Bros. Pictures, 20th Century Fox</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IqUuMFl8aLrwLXeCNrHrhQ.png" /><figcaption>I tried to stick Leo in this picture too but they wouldn’t let me</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e3363571707" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nfl-engineers/nfl-codemods-migrating-a-monolith-1e3363571707">NFL ♥ Codemods: Migrating a Monolith</a> was originally published in <a href="https://medium.com/nfl-engineers">NFL Engineers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NFL + React]]></title>
            <link>https://medium.com/nfl-engineers/nfl-react-84e9cd11d384?source=rss----7814fcdf1ad5---4</link>
            <guid isPermaLink="false">https://medium.com/p/84e9cd11d384</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Richard Herrera]]></dc:creator>
            <pubDate>Tue, 23 Feb 2016 22:35:07 GMT</pubDate>
            <atom:updated>2016-02-25T17:21:43.019Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*swo45HGw3tvi-Yi7ni-s8w.png" /></figure><p>The National Football League adopted React in December of 2014. For the past year we have iterated and built on React’s core concepts, various Flux implementations, JSX, Babel, experimental proposals, and functional approaches. You name it and we’ve probably evaluated it and possibly use it in production. Read on for a review of the NFL’s year in React.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6hWppwxDqlpF4yOoxw4DQw.jpeg" /><figcaption>React Los Angeles Meetup at the NFL Studios • March 2014</figcaption></figure><p>We are big believers in React. To that end, the NFL Engineering team is more than eager to help increase visibility and adoption. We spoke at meet-ups and even hosted one ourselves. We also contributed to the open source community with tools like <a href="https://github.com/nfl/react-helmet">React Helmet</a> (a document head manager), and <a href="https://github.com/nfl/react-metrics">React Metrics</a> (an analytics helper).</p><h4>The Path to Wildcat</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*loRddt9RergRBBqvgAWGzQ.jpeg" /><figcaption>A wildcat. He’s quite young, like our framework.</figcaption></figure><p>From the ground up, we wanted to rethink our front-end development stack around React. We started with the traditional (if you can call year-old approaches “traditional”) React + Sass + Webpack bundle approach. We developed an internal React stack we called <em>Gridiron</em> and used it to launch our initial set of applications. Each application lived in a separate repo, had its own deployment pipeline, and ultimately ran its own application server in production. This approach very quickly revealed technical limitations and concerns:</p><ul><li>Dependency management across many repositories proved repetitive, time-consuming, and error prone.</li><li>Updating shared components across many applications became tedious and unsynchronized.</li><li>Webpack compilation negatively impacted the development experience by lengthening build, test, and deploy times as our codebases increased.</li><li>Code-sharing suffered across repositories (especially as various Flux patterns emerged)</li></ul><p>As the evidence grew, we began working on an in-house solution to address the following questions:</p><ul><li>How do we achieve continuous deployment?</li><li>Can we be smarter about loading components on the browser?</li><li>Can we effectively share React components across our properties?</li><li>With HTTP2 on the horizon, can we practically adopt a bundle-free environment?</li><li>Can we pre-render and serve React pages on multiple domains from one web application?</li><li>Can we achieve our goals using a monolithic repository and server application across multiple domains and subdomains?</li></ul><p>Thus began the path to <a href="https://github.com/nfl/react-wildcat">Wildcat</a>, an opinionated React environment we’ve developed and open sourced to address our concerns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OwroIYvgJUcvG4VU54a--A.png" /><figcaption>A graphical mind map of Wildcat. (We know, it’s complicated. We’ll walk through these below.)</figcaption></figure><p>Wildcat runs behind-the-scenes. It is a pre-configured environment that handles server-side rendering and logic, leaving front end engineers to focus strictly on the client. It utilizes pragmatic, peer-reviewed dependencies that cover state management, routing, styling and dev tooling. Backed by Wildcat, work can immediately start on individual projects with no overhead distractions on libraries or frameworks. It consists of the following core packages:</p><ul><li><strong>react-wildcat</strong> is the application server</li><li><strong>react-wildcat-handoff</strong> is the application client / server renderer</li><li><strong>react-wildcat-prefetch</strong> is an agnostic higher order component to prefetch component data</li><li><strong>react-wildcat-hot-reloader</strong> adds hot-reloading capabilities to Wildcat</li><li><strong>react-wildcat-ensure</strong> is a wrapper for <a href="https://github.com/systemjs/systemjs">System.import</a> that behaves like Webpack’s <a href="https://webpack.github.io/docs/code-splitting.html#require-ensure">require.ensure</a></li><li><strong>react-wildcat-test-runners</strong> manages end-to-end and unit testing with Karma, Protractor and Mocha.</li></ul><p>Our framework attempts to solve a litany of architectural concerns, outlined across four core verticals:</p><h4>The Application Server</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*59asRWBot4Md2y4nCJpDAQ.png" /></figure><p>Wildcat uses <a href="http://jspm.io/">jspm</a> and <a href="https://github.com/systemjs/systemjs">SystemJS</a> to universally render React on the server and client. Using host headers, it resolves a user’s current domain and/or subdomain, lazily loading only what is necessary to render a given route. This technique allows us to maintain a <a href="http://danluu.com/monorepo/">monolithic repository</a>, giving us the advantage of developing, running, and deploying multiple projects hosted across multiple domains based on a single application entry point.</p><p>Additionally, the app server handles data dehydration, prepping API data for client ingestion. It’s also responsible for ancillary tasks like request proxying, CORS handling and so forth.</p><p>In development, a WebSocket listens for static asset changes and hot-reloads modules as they change. You may be surprised to learn we also hot-reload in production. Using Kafka, our deploy pipeline publishes a notification of every static file change. The app server uses a Kafka consumer to listen for file invalidations and purges assets as they stream in. This allows us to publish static deploys without the need to bounce our app server. The server simply picks up the invalidation notifications, updates its in-memory module cache, and renders the updated module on the next reload.</p><h4>Static Asset Management</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*uHjdddWBkWZzJK1sGqe_lg.png" /></figure><p>One of our biggest challenges, static asset management was an architectural puzzle we debated for weeks. Prior to Wildcat, our decentralized deploy workflow revolved around minified, concatenated Webpack bundles. For each domain/subdomain, we generated a static asset bundle and served it from the target domain. This resulted in a high probabilty that modules would be duplicated across our domains. That is, if two separate domains depended on an identical module, that module would be downloaded once per domain. To put it in visual terms:</p><pre>www.nfl.com -&gt; moduleA -&gt; www.nfl.com/bundleContainingModuleA.js<br>sso.nfl.com -&gt; moduleA -&gt; sso.nfl.com/bundleContainingModuleA.js</pre><p>To solve this, we aimed to have a single source of truth for each shared dependency. We wanted the flexibility to deploy an individual module to one location and have it propagate across all our web applications. In Wildcat, we achieve this using a custom jspm + SystemJS fork that allows us to fetch modules on both the client and the server from a central destination:</p><pre>www.nfl.com -&gt; moduleA -&gt; static.nfl.com/moduleA.js<br>sso.nfl.com -&gt; moduleA -&gt; static.nfl.com/moduleA.js</pre><p>On the <a href="http://developerexperience.org/">DX</a> front a local static dev server listens for incoming module requests, locates the requested source ES2016 module, transpiles the module and serves an ES5 version back for client/server ingestion. One major advantage of on-the-fly transpilation is a lightning-quick dev mode boot time.</p><p>In production, source modules are transpiled on deploy and served as static ES5 modules through a CDN provider. Third-party modules are gathered, minified and bundled. Third-party modules shared across two or more domains are grouped into a common bundle, while domain-specific bundles are generated and served as needed.</p><h4>The Client</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*vir-L15ZUxhLdjvod_qU6A.png" /></figure><p>The client render stack is a near copy of the app server. Using jspm + SystemJS, we leverage lazy loading techniques to resolve the current domain and route path, hydrate any API data retrieved from the server, and render the result on the client. Here’s a quick glance at our JavaScript stack:</p><ul><li>Route-based lazy component loading with <a href="https://github.com/rackt/react-router">React Router</a> + jspm</li><li><a href="https://github.com/FormidableLabs/radium">Radium</a> for inline styling</li><li><a href="https://github.com/nfl/react-helmet">Helmet</a> for managing your document head</li><li><a href="https://github.com/nfl/react-metrics">React Metrics</a> for tracking analytics</li><li>Store-agnostic <a href="https://github.com/nfl/react-wildcat/tree/master/packages/react-wildcat-prefetch">Prefetching</a> for client data hydration</li></ul><p>In development, a WebSocket listens for static asset changes and hot-reloads modules as they change. Production changes are not hot-reloaded on the client.</p><h4>Dev Tools</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*RAmPRVwO5NrZ1xMNHtx5AQ.png" /></figure><p>As important as static asset management is, we also took the opportunity to improve our dev tooling with Wildcat. To ensure code quality, it is critically important to cover our code with unit tests, integration tests, and code coverage analysis. Our testing stack consists of <a href="http://karma-runner.github.io/">Karma</a> for unit tests and <a href="https://angular.github.io/protractor/">Protractor</a> for e2e testing (turns out it <a href="http://www.joelotter.com/2015/04/18/protractor-reactjs.html">works great</a> for React!). <a href="https://mochajs.org/">Mocha</a>+ <a href="http://chaijs.com/">Chai</a> are used in both. We also use <a href="http://eslint.org/">ESLint</a> for static code analysis to catch potential bugs and to keep a uniform coding style across our web projects.</p><h4>The Road Ahead</h4><p>Wildcat is still in its infancy. It treads new, unexplored ground in many areas. We hope it can be used as a performance yardstick for the near-future of React applications. There are still many questions to answer and many features to refactor. We invite you to <a href="https://github.com/nfl/react-wildcat">take a look at our framework</a> and reach out with questions or concerns. The NFL Engineering team is only getting started with React. We can’t wait to see what’s next.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84e9cd11d384" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nfl-engineers/nfl-react-84e9cd11d384">NFL + React</a> was originally published in <a href="https://medium.com/nfl-engineers">NFL Engineers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>