Skip to content

Commit

Permalink
Add ts-extension-load-esm test
Browse files Browse the repository at this point in the history
  • Loading branch information
henrist committed Jan 20, 2025
1 parent 071b4f0 commit b68f62f
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ describe("handler module format: module", function desc() {
path: "/dev/top-level-await",
status: 200,
},

{
description: "should return 'bar' for ts-extension-load-esm endpoint",
expected: "bar",
path: "/dev/ts-extension-load-esm",
status: 200,
},
].forEach(({ description, expected, path, status }) => {
it(description, async () => {
const url = new URL(path, BASE_URL)
Expand Down
7 changes: 7 additions & 0 deletions tests/handler-module-formats/module/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ functions:
method: get
path: top-level-await
handler: top-level-await/handler.bar

ts-extension-load-esm:
events:
- http:
method: get
path: ts-extension-load-esm
handler: ts-extension-load-esm/handler.foo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!node_modules/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { bar } from "testpackage"

const { stringify } = JSON

export async function foo() {
return {
body: stringify(bar()),
statusCode: 200,
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { require: tsxRequire } = require(`tsx/cjs/api`)

tsxRequire("./handler.ts", __filename)

0 comments on commit b68f62f

Please sign in to comment.