From cff3134d827caac729ebca546c30184511cbaa04 Mon Sep 17 00:00:00 2001 From: Evan Sellers Date: Mon, 22 Apr 2024 10:03:33 -0400 Subject: [PATCH 1/4] Updated to ESM --- package.json | 5 ++++- src/compiler/utilities/tooling/index.ts | 3 ++- src/environment/handler/index.ts | 2 +- tsconfig.json | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 491a4a2..98b4e07 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,14 @@ "author": "Sellers Industries", "version": "0.0.0", "description": "Module and Reusable Microservice Platform. Build and modularize custom API endpoints, inspired by NextJS APIs. Export to Vercel and ExpressJS.", - "main": "./dist/index.js", + "exports": "./dist/index.js", "type": "module", "bin": { "sherpa": "./dist/src/cli/index.js" }, + "engines": { + "node": ">=16" + }, "scripts": { "build": "tsc --build --force tsconfig.json", "prepare": "npm run build", diff --git a/src/compiler/utilities/tooling/index.ts b/src/compiler/utilities/tooling/index.ts index 02148b4..1001857 100644 --- a/src/compiler/utilities/tooling/index.ts +++ b/src/compiler/utilities/tooling/index.ts @@ -24,7 +24,7 @@ import { ExportLoaderModule, getExportedLoader } from "./exported-loader/index.j export type { ExportLoaderModule }; export const DEFAULT_ESBUILD_TARGET:Partial = { - format: "cjs", + format: "esm", target: "es2022", platform: "node", bundle: true, @@ -60,6 +60,7 @@ export class Tooling { static async getDefaultExport(filepath:string):Promise { let result = await build({ ...DEFAULT_ESBUILD_TARGET, + format: "cjs", entryPoints: [filepath], write: false }); diff --git a/src/environment/handler/index.ts b/src/environment/handler/index.ts index 6b96850..35bc3a3 100644 --- a/src/environment/handler/index.ts +++ b/src/environment/handler/index.ts @@ -13,7 +13,7 @@ import { Context, Method } from "../../compiler/models.js"; import { IResponse } from "../io/response/interface.js"; -import { IRequest } from "../io/request/interface"; +import { IRequest } from "../io/request/interface.js"; import { Response } from "../io/response/index.js"; diff --git a/tsconfig.json b/tsconfig.json index f9d74ca..9a6d271 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "es2022", - "module": "es2022", - "moduleResolution": "Node", + "module": "Node16", + "moduleResolution": "Node16", "esModuleInterop": true, "sourceMap": true, "outDir": "dist", From f8a7f6a57bbf713ef9bf3345dcf54122988ccb29 Mon Sep 17 00:00:00 2001 From: Evan Sellers Date: Mon, 22 Apr 2024 10:03:40 -0400 Subject: [PATCH 2/4] Updated Workflow --- .github/workflows/linting.yml | 20 ++++++++++++++++++++ .github/workflows/{tests.yml => testing.yml} | 0 2 files changed, 20 insertions(+) create mode 100644 .github/workflows/linting.yml rename .github/workflows/{tests.yml => testing.yml} (100%) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..ddaa854 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,20 @@ +name: Jest Testing + +on: + pull_request: + branches: ["*"] + +jobs: + test: + name: Run Jest tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: npm install + + - name: Run linting + run: npm run lint diff --git a/.github/workflows/tests.yml b/.github/workflows/testing.yml similarity index 100% rename from .github/workflows/tests.yml rename to .github/workflows/testing.yml From 9fe357833b51cb65ec23770834a3b173961f1411 Mon Sep 17 00:00:00 2001 From: Evan Sellers Date: Mon, 22 Apr 2024 10:05:14 -0400 Subject: [PATCH 3/4] Update linting.yml --- .github/workflows/linting.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index ddaa854..8be81f5 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -1,4 +1,4 @@ -name: Jest Testing +name: Linting on: pull_request: @@ -6,7 +6,7 @@ on: jobs: test: - name: Run Jest tests + name: Run Linting runs-on: ubuntu-latest steps: From 7b5128d03f3b81a97906163eedad13ae0d8667c2 Mon Sep 17 00:00:00 2001 From: Evan Sellers Date: Mon, 22 Apr 2024 10:06:09 -0400 Subject: [PATCH 4/4] Fixed Linting Issues --- src/compiler/bundler/platforms/vercel/index.ts | 1 - .../dynamic-paths/[testID]/[testID]/page/[pageID]/index.ts | 2 +- .../routes/regular/response/redirect/success/index.ts | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compiler/bundler/platforms/vercel/index.ts b/src/compiler/bundler/platforms/vercel/index.ts index d98491a..1ead816 100644 --- a/src/compiler/bundler/platforms/vercel/index.ts +++ b/src/compiler/bundler/platforms/vercel/index.ts @@ -12,7 +12,6 @@ import fs from "fs"; -import path from "path"; import { Bundler } from "../abstract.js"; import { Endpoint, Segment } from "../../../models.js"; import { Path } from "../../../utilities/path/index.js"; diff --git a/tests/servers/pass-primary/routes/regular/dynamic-paths/[testID]/[testID]/page/[pageID]/index.ts b/tests/servers/pass-primary/routes/regular/dynamic-paths/[testID]/[testID]/page/[pageID]/index.ts index 760e5eb..3f0e86f 100644 --- a/tests/servers/pass-primary/routes/regular/dynamic-paths/[testID]/[testID]/page/[pageID]/index.ts +++ b/tests/servers/pass-primary/routes/regular/dynamic-paths/[testID]/[testID]/page/[pageID]/index.ts @@ -1,6 +1,6 @@ import { Request, Response } from "../../../../../../../../../../src/environment/index"; -export function GET(request:Request, context:any) { +export function GET(request:Request, context:unknown) { return Response.JSON({ request: request, context: context diff --git a/tests/servers/pass-primary/routes/regular/response/redirect/success/index.ts b/tests/servers/pass-primary/routes/regular/response/redirect/success/index.ts index 8c3bd01..9713f3c 100644 --- a/tests/servers/pass-primary/routes/regular/response/redirect/success/index.ts +++ b/tests/servers/pass-primary/routes/regular/response/redirect/success/index.ts @@ -1,7 +1,7 @@ import { Response, Request } from "../../../../../../../../src/environment/index"; -export function GET(request:Request, context:any) { +export function GET(request:Request, context:unknown) { return Response.JSON({ request, context