Skip to content

Commit 562470d

Browse files
committed
Allow requireName to be a relative path inside the module
1 parent 06aa342 commit 562470d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/factory/UnnamedComponentFactory.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ export class UnnamedComponentFactory implements IComponentFactory {
188188
} catch (e) {
189189
try {
190190
// Always require relative from main module, because Components.js will in most cases just be dependency.
191-
object = require.main.require(requireName);
191+
object = require.main.require(requireName.charAt(0) === '.'
192+
? Path.join(process.cwd(), requireName)
193+
: requireName);
192194
if (serialize) resultingRequirePath = requireName;
193195
} catch (e) {
194196
if (this._componentRunner._properties.scanGlobal) {
@@ -247,4 +249,4 @@ export class UnnamedComponentFactory implements IComponentFactory {
247249
serialize ? resolve(serialization) : resolve(object);
248250
});
249251
}
250-
}
252+
}

0 commit comments

Comments
 (0)