Skip to content

Commit ddfd702

Browse files
committed
refactor(config-loader): do not lookup package.json with explicit extensions
Currently when a config has an explicit extension, the config-loader still tries resolving/traversing for a `package.json` file. This can be slow, and also break in some environments with sandboxing; especially when used in combination with Bazel. It doesn't seem investigating why the calls are stuck, if the logic should not run in general when an explicit extension is provided.
1 parent 93ab3ca commit ddfd702

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/config-loader/src/importOrRequireConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ function importConfig(configPath) {
1717
* @param {string} basedir
1818
*/
1919
async function importOrRequireConfig(configPath, basedir) {
20-
const packageType = await getPackageType(basedir);
2120
const ext = path.extname(configPath);
2221

2322
switch (ext) {
@@ -26,6 +25,7 @@ async function importOrRequireConfig(configPath, basedir) {
2625
case '.cjs':
2726
return requireConfig(configPath);
2827
default:
28+
const packageType = await getPackageType(basedir);
2929
return packageType === 'module' ? importConfig(configPath) : requireConfig(configPath);
3030
}
3131
}

0 commit comments

Comments
 (0)