From 153c9e0e4c0919aaf1628b610f87d6bf76740b24 Mon Sep 17 00:00:00 2001 From: Daniel Sarlo Date: Sun, 29 Oct 2023 22:41:55 -0400 Subject: [PATCH] Using pathToFileURL to import handler method across OS's (#189) --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index a55f05b..b9e2656 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,6 +15,7 @@ import lodashfp from 'lodash/fp.js'; const { get, has } = lodashfp; import { loadServerlessConfig } from "./sls-config-parser.js"; +import url from 'url'; class ServerlessOfflineSns { private config: any; @@ -509,7 +510,7 @@ class ServerlessOfflineSns { const handlerPath = fn.handler.substring(0, handlerFnNameIndex); const handlerFnName = fn.handler.substring(handlerFnNameIndex + 1); const fullHandlerPath = resolve(location, handlerPath); - const handlers = await import(`${fullHandlerPath}.js`); + const handlers = await import(`${url.pathToFileURL(fullHandlerPath)}.js`); return handlers[handlerFnName]; }