From 28e84f3aed480d1f5a8f9859172d1c6f531696d4 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Wed, 2 Nov 2016 18:20:59 -0700 Subject: [PATCH] Make routes module available to other modules --- lib/intermediate-representation-dir/production-app.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/intermediate-representation-dir/production-app.js b/lib/intermediate-representation-dir/production-app.js index c650556e28af6..d08ab09c59b8e 100644 --- a/lib/intermediate-representation-dir/production-app.js +++ b/lib/intermediate-representation-dir/production-app.js @@ -50,6 +50,15 @@ runtime.install({ const rootElement = document.getElementById(`react-mount`) const rootRoute = require(`./split-child-routes`) +// If you try to load the split-child-routes module in other +// modules, Webpack freezes in some sort of infinite loop when +// you try to build the javascript for production. No idea +// why... so for now we'll pop the routes on window. I hope no +// one feels overly dirty from reading this ;-) +if (typeof window !== 'undefined') { + window.gatsbyRootRoute = rootRoute +} + let currentLocation browserHistory.listen(location => { currentLocation = location