Skip to content

Commit 7723b4d

Browse files
committed
fix: app dont runs on Windows
1 parent a2f7ab4 commit 7723b4d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-aws-lambda",
3-
"version": "5.0.2",
3+
"version": "5.0.3",
44
"description": "AWS Application Load Balancer and API Gateway - Lambda dev tool for Serverless. Allows Express synthax in handlers. Supports packaging, local invoking and offline ALB, APG, S3, SNS, SQS, DynamoDB Stream server mocking.",
55
"author": "Inqnuam",
66
"license": "MIT",

src/lib/esbuild/buildOptimizer.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import type { Plugin, BuildResult } from "esbuild";
22
import { knownCjs } from "./knownCjs";
33
import path from "path";
4+
import { fileURLToPath } from "url";
45
const awsSdkV2 = "aws-sdk";
56
const awsSdkV3 = "@aws-sdk/*";
6-
const awslambda = `${path
7-
.dirname(import.meta.url)
8-
.replace("file://", "")
9-
.slice(0, -5)}/src/lib/runtime/awslambda.ts`;
7+
const awslambda = `${fileURLToPath(path.dirname(import.meta.url)).slice(0, -5)}/src/lib/runtime/awslambda.ts`;
108
const requirePoly = (nodePrefix: "node:" | "") =>
119
`import { createRequire as __crE_ } from "${nodePrefix}module";import { fileURLToPath as __futP_ } from "${nodePrefix}url";import { dirname as __dN_ } from "${nodePrefix}path";global.__filename = __futP_(import.meta.url);global.__dirname = __dN_(__filename);global.require = __crE_(__filename);\n`;
1210

src/lib/utils/readDefineConfig.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import path from "path";
22
import { log } from "./colorize";
33
import esbuild from "esbuild";
44
import { rm } from "fs/promises";
5+
import { pathToFileURL } from "url";
56

67
const jsExt = ["js", "mjs", "cjs", "ts", "cts", "mts"];
78

89
const readFromPath = async (sourcefile: string) => {
9-
const dir = path.dirname(sourcefile);
10+
const dir = path.dirname(path.toNamespacedPath(sourcefile));
1011
const fname = path.basename(sourcefile, path.extname(sourcefile));
11-
const outfile = `${dir}/__${fname}.mjs`;
12+
const outfile = path.join(dir, `__${fname}.mjs`);
1213

1314
await esbuild.build({
1415
outfile,
@@ -24,7 +25,7 @@ const readFromPath = async (sourcefile: string) => {
2425
});
2526

2627
try {
27-
const config = await import(outfile);
28+
const config = await import(pathToFileURL(outfile).href);
2829
return config;
2930
} catch (error) {
3031
throw error;

0 commit comments

Comments
 (0)