Skip to content

Commit

Permalink
Skip submodules if they have already been loaded as a part of main mo…
Browse files Browse the repository at this point in the history
…dule

See: metarhia#1938
  • Loading branch information
DmitryScaletta committed Nov 12, 2023
1 parent 52dd114 commit 095c928
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ const loadModule = (name) => {
for (const subName of subNames) {
try {
const sub = appRequire(name + '/' + subName);
if (lib[subName] && lib[subName] === sub[subName]) continue;
lib[subName] = sub;
} catch (e) {
if (e.message.startsWith("Cannot find module '")) {
const moduleName = e.message.substring(20, e.message.indexOf("'\n"));
const optional = pkg.peerDependenciesMeta?.[moduleName].optional;
if (optional) continue; else throw e;
if (optional) continue;
else throw e;
}
}
}
Expand Down

0 comments on commit 095c928

Please sign in to comment.