Skip to content

Commit

Permalink
fixup! Support submodules in autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
tshemsedinov committed Aug 8, 2023
1 parent fd27844 commit ff9bef6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ const loadPlugins = (lib) => {
};

const validSubmodules = (key) => {
if (key === '.') return false;
if (key === './package.json') return false;
return !key.includes('*');
if (key === '') return false;
if (key === 'package.json') return false;
return !key.includes('*') && !key.includes('.');
};

const loadModule = (name) => {
const lib = appRequire(name);
const pkg = require(`${CWD}/node_modules/${name}/package.json`);
if (!pkg.exports) return lib;
const subKeys = Object.keys(pkg.exports).filter(validSubmodules);
const subNames = subKeys.map((key) => key.substring(2));
const subKeys = Object.keys(pkg.exports).map((key) => key.substring(2));
const subNames = subKeys.filter(validSubmodules);
for (const subName of subNames) {
const sub = appRequire(name + '/' + subName);
const key = name + '/' + subName;
Expand Down

0 comments on commit ff9bef6

Please sign in to comment.