Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/nice-guests-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@web/config-loader': patch
---

Optimizes config loading to not look for `package.json` in file system if the
config extension is already informing whether CommonJS or ESM is used.

Currently config loading did unnecessarily traverse the file system. This could
be unnecessary slowness, or cause issues in sandbox environments (like Bazel)
2 changes: 1 addition & 1 deletion packages/config-loader/src/importOrRequireConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function importConfig(configPath) {
* @param {string} basedir
*/
async function importOrRequireConfig(configPath, basedir) {
const packageType = await getPackageType(basedir);
const ext = path.extname(configPath);

switch (ext) {
Expand All @@ -26,6 +25,7 @@ async function importOrRequireConfig(configPath, basedir) {
case '.cjs':
return requireConfig(configPath);
default:
const packageType = await getPackageType(basedir);
return packageType === 'module' ? importConfig(configPath) : requireConfig(configPath);
}
}
Expand Down