fix(modules-sdk): Add missing paths to require.resolve in load resources (#9608)
FIXES FRMW-2747 **What** Add missing `paths` options
This commit is contained in:
committed by
GitHub
parent
68560787e5
commit
e911c6aebf
@@ -50,7 +50,7 @@ describe("modules loader", () => {
|
||||
it("should register the service ", async () => {
|
||||
const moduleResolutions: Record<string, ModuleResolution> = {
|
||||
testService: {
|
||||
resolutionPath: "@modules/default",
|
||||
resolutionPath: require.resolve("../__mocks__/@modules/default"),
|
||||
definition: {
|
||||
key: "testService",
|
||||
defaultPackage: "testService",
|
||||
@@ -90,7 +90,7 @@ describe("modules loader", () => {
|
||||
it("should run the defined loaders and logs the errors if something fails", async () => {
|
||||
const moduleResolutions: Record<string, ModuleResolution> = {
|
||||
testService: {
|
||||
resolutionPath: "@modules/brokenloader",
|
||||
resolutionPath: require.resolve("../__mocks__/@modules/brokenloader"),
|
||||
definition: {
|
||||
key: "testService",
|
||||
defaultPackage: "testService",
|
||||
@@ -115,7 +115,7 @@ describe("modules loader", () => {
|
||||
it("should log the errors if no service is defined", async () => {
|
||||
const moduleResolutions: Record<string, ModuleResolution> = {
|
||||
testService: {
|
||||
resolutionPath: "@modules/no-service",
|
||||
resolutionPath: require.resolve("../__mocks__/@modules/no-service"),
|
||||
definition: {
|
||||
key: "testService",
|
||||
defaultPackage: "testService",
|
||||
@@ -142,7 +142,7 @@ describe("modules loader", () => {
|
||||
it("should throw an error if no service is defined and the module is required", async () => {
|
||||
const moduleResolutions: Record<string, ModuleResolution> = {
|
||||
testService: {
|
||||
resolutionPath: "@modules/no-service",
|
||||
resolutionPath: require.resolve("../__mocks__/@modules/no-service"),
|
||||
definition: {
|
||||
key: "testService",
|
||||
defaultPackage: "testService",
|
||||
|
||||
@@ -542,7 +542,9 @@ export async function loadResources({
|
||||
loadedModuleLoaders ??= []
|
||||
|
||||
const modulePath = discoveryPath
|
||||
let normalizedPath = dirname(require.resolve(modulePath))
|
||||
let normalizedPath = dirname(
|
||||
require.resolve(modulePath, { paths: [process.cwd()] })
|
||||
)
|
||||
normalizedPath = resolve(normalizedPath)
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user