From 31a2a26b45950c564b828de79814d55c28181f9c Mon Sep 17 00:00:00 2001 From: John Resig Date: Wed, 1 Mar 2017 12:52:56 -0500 Subject: [PATCH] Fix bug where `let` doesn't work in runInContext in old Node versions. See: https://github.com/nodejs/node/issues/2245 Test Plan: I switched my Node version back to v4 and confirmed that I was able to run `render_component.js` without error. Auditors: emily, csilvers --- src/render.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/render.js b/src/render.js index 669a249..18651c5 100644 --- a/src/render.js +++ b/src/render.js @@ -323,7 +323,10 @@ const render = function(jsPackages, pathToReactComponent, props, // our work here is easy. return runInContext(context, () => { return new Promise((resolve, reject) => { - let Component = KAdefine.require(global.pathToReactComponent); + // NOTE(jeresig): We should be using `let` here but the current + // version of the Node.js runtime we use in production doesn't + // understand `let` inside runInContext (known bug). + var Component = KAdefine.require(global.pathToReactComponent); // eslint-disable-line no-var // The Component could have been exported using `export default` // We check for that case and use that component here.