@samitouri / QOS-React-2 / commits / 2c228f15a0

Correctly replace shims using relative requires (#11472)

Dan Abramov committed Nov 6, 2017 at 16:53 UTC 2c228f15a0aa862ad92876d0f426a8ade45f1576
1 file changed +11 -2
scripts/rollup/modules.js
+11 -2
@@ -102,11 +102,20 @@ function getShims(bundleType, entry, featureFlags) {
102 // so we resort to using a shim that re-exports the www module, and then
103 // treating shim's target destinations as external (see getDependencies).
104 forkedFBModules.forEach(srcPath => {
105 - const wwwName = path.parse(srcPath).name;
105 + const fileName = path.parse(srcPath).name;
106 const shimPath = path.resolve(
107 - __dirname + `/shims/rollup/${wwwName}-www.js`
107 + __dirname + `/shims/rollup/${fileName}-www.js`
108 );
109 shims[srcPath] = shimPath;
110 + // <hack>
111 + // Unfortunately the above doesn't work for relative imports,
112 + // and Rollup isn't smart enough to understand they refer to the same file.
113 + // We should come up with a real fix for this, but for now this will do.
114 + // FIXME: this is gross.
115 + shims['./' + fileName] = shimPath;
116 + shims['../' + fileName] = shimPath;
117 + // We don't have deeper relative requires between source files.
118 + // </hack>
119 });
120 break;
121 }