Allow relative import from package root inside of top-level fb folder

Reviewed By: LukeDefeo

Differential Revision: D44415645

fbshipit-source-id: d19c5144f9ee374cde0727f93f583552664bc806
This commit is contained in:
Andrey Goncharov
2023-03-28 02:16:43 -07:00
committed by Facebook GitHub Bot
parent 7f2a0c94f9
commit 4b5357da7e

View File

@@ -18,7 +18,15 @@ function findRootDir(path: string): string {
if (cachedRoot) {
return cachedRoot;
}
if (fs.pathExistsSync(join(path, 'package.json'))) {
// Our public packages have the following structure:
// - package
// - fb
// - package.json
// - pacakage.json
// package.json insode of fb folder is not a real root. It is merely an add-on for the root package.json for internal builds.
// We should ignore package.json inside of "fb" folder and allow relative imports from the root inside of the fb folder.
const fbFolder = path.endsWith('fb') || path.endsWith('fb/');
if (!fbFolder && fs.pathExistsSync(join(path, 'package.json'))) {
rootDirs.set(path, path);
return path;
}