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:
1 parent
68560787e5
commit
e911c6aebf
2 files changed
+7
-5
No files matched your search
@@ -50,7 +50,7 @@ describe("modules loader", () => {
|
|||||||
it("should register the service ", async () => {
|
it("should register the service ", async () => {
|
||||||
const moduleResolutions: Record<string, ModuleResolution> = {
|
const moduleResolutions: Record<string, ModuleResolution> = {
|
||||||
testService: {
|
testService: {
|
||||||
resolutionPath: "@modules/default",
|
resolutionPath: require.resolve("../__mocks__/@modules/default"),
|
||||||
definition: {
|
definition: {
|
||||||
key: "testService",
|
key: "testService",
|
||||||
defaultPackage: "testService",
|
defaultPackage: "testService",
|
||||||
@@ -90,7 +90,7 @@ describe("modules loader", () => {
|
|||||||
it("should run the defined loaders and logs the errors if something fails", async () => {
|
it("should run the defined loaders and logs the errors if something fails", async () => {
|
||||||
const moduleResolutions: Record<string, ModuleResolution> = {
|
const moduleResolutions: Record<string, ModuleResolution> = {
|
||||||
testService: {
|
testService: {
|
||||||
resolutionPath: "@modules/brokenloader",
|
resolutionPath: require.resolve("../__mocks__/@modules/brokenloader"),
|
||||||
definition: {
|
definition: {
|
||||||
key: "testService",
|
key: "testService",
|
||||||
defaultPackage: "testService",
|
defaultPackage: "testService",
|
||||||
@@ -115,7 +115,7 @@ describe("modules loader", () => {
|
|||||||
it("should log the errors if no service is defined", async () => {
|
it("should log the errors if no service is defined", async () => {
|
||||||
const moduleResolutions: Record<string, ModuleResolution> = {
|
const moduleResolutions: Record<string, ModuleResolution> = {
|
||||||
testService: {
|
testService: {
|
||||||
resolutionPath: "@modules/no-service",
|
resolutionPath: require.resolve("../__mocks__/@modules/no-service"),
|
||||||
definition: {
|
definition: {
|
||||||
key: "testService",
|
key: "testService",
|
||||||
defaultPackage: "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 () => {
|
it("should throw an error if no service is defined and the module is required", async () => {
|
||||||
const moduleResolutions: Record<string, ModuleResolution> = {
|
const moduleResolutions: Record<string, ModuleResolution> = {
|
||||||
testService: {
|
testService: {
|
||||||
resolutionPath: "@modules/no-service",
|
resolutionPath: require.resolve("../__mocks__/@modules/no-service"),
|
||||||
definition: {
|
definition: {
|
||||||
key: "testService",
|
key: "testService",
|
||||||
defaultPackage: "testService",
|
defaultPackage: "testService",
|
||||||
|
|||||||
@@ -542,7 +542,9 @@ export async function loadResources({
|
|||||||
loadedModuleLoaders ??= []
|
loadedModuleLoaders ??= []
|
||||||
|
|
||||||
const modulePath = discoveryPath
|
const modulePath = discoveryPath
|
||||||
let normalizedPath = dirname(require.resolve(modulePath))
|
let normalizedPath = dirname(
|
||||||
|
require.resolve(modulePath, { paths: [process.cwd()] })
|
||||||
|
)
|
||||||
normalizedPath = resolve(normalizedPath)
|
normalizedPath = resolve(normalizedPath)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in new issue
Block a user