Skip to content

Commit a6897e7

Browse files
Merge pull request #222 from hypermod-io/fix-experimental-loader-module-require
Fixes config resolution for experimental loader
2 parents bafdf57 + 885c4d6 commit a6897e7

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@hypermod/fetcher': patch
3+
'@hypermod/cli': patch
4+
---
5+
6+
Fixes logic to locate configs when bundled in deeply nested directories

packages/cli/src/main.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@ import { getConfigPrompt, getMultiConfigPrompt } from './prompt';
1717

1818
const ExperimentalModuleLoader = () => ({
1919
install: async (packageName: string) =>
20-
await installPackage(packageName, { cwd: __dirname }),
20+
await installPackage(packageName, {
21+
cwd: __dirname,
22+
packageManager: 'npm',
23+
additionalArgs: ['--force'],
24+
}),
2125
require: (packageName: string) => require(packageName),
22-
getInfo: (packageName: string) => ({
23-
location: require.resolve(packageName),
24-
}),
26+
getInfo: (packageName: string) => {
27+
const entryPath = require.resolve(packageName);
28+
return {
29+
location: entryPath.split(packageName)[0] + packageName,
30+
entryPath: entryPath,
31+
};
32+
},
2533
});
2634

2735
export default async function main(

packages/fetcher/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export async function fetchRemotePackage(
150150
if (configExport.transforms || configExport.presets) {
151151
return {
152152
filePath: info.location,
153-
config: resolveConfigExport(pkg),
153+
config: configExport,
154154
};
155155
}
156156
} catch (e) {

0 commit comments

Comments
 (0)