From b49ae5efae95518a837ddc413a873d159f23123e Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 6 Nov 2017 16:37:42 +0000 Subject: [PATCH] Correctly replace shims using relative requires --- scripts/rollup/modules.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/rollup/modules.js b/scripts/rollup/modules.js index 1a24bef7a0d..a60f8c94ddd 100644 --- a/scripts/rollup/modules.js +++ b/scripts/rollup/modules.js @@ -102,11 +102,20 @@ function getShims(bundleType, entry, featureFlags) { // so we resort to using a shim that re-exports the www module, and then // treating shim's target destinations as external (see getDependencies). forkedFBModules.forEach(srcPath => { - const wwwName = path.parse(srcPath).name; + const fileName = path.parse(srcPath).name; const shimPath = path.resolve( - __dirname + `/shims/rollup/${wwwName}-www.js` + __dirname + `/shims/rollup/${fileName}-www.js` ); shims[srcPath] = shimPath; + // + // Unfortunately the above doesn't work for relative imports, + // and Rollup isn't smart enough to understand they refer to the same file. + // We should come up with a real fix for this, but for now this will do. + // FIXME: this is gross. + shims['./' + fileName] = shimPath; + shims['../' + fileName] = shimPath; + // We don't have deeper relative requires between source files. + // }); break; }