Skip to content

Commit 2c228f1

Browse files
authored
Correctly replace shims using relative requires (#11472)
1 parent 4480f75 commit 2c228f1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

scripts/rollup/modules.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,20 @@ function getShims(bundleType, entry, featureFlags) {
102102
// so we resort to using a shim that re-exports the www module, and then
103103
// treating shim's target destinations as external (see getDependencies).
104104
forkedFBModules.forEach(srcPath => {
105-
const wwwName = path.parse(srcPath).name;
105+
const fileName = path.parse(srcPath).name;
106106
const shimPath = path.resolve(
107-
__dirname + `/shims/rollup/${wwwName}-www.js`
107+
__dirname + `/shims/rollup/${fileName}-www.js`
108108
);
109109
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>
110119
});
111120
break;
112121
}

0 commit comments

Comments
 (0)