Skip to content

Commit

Permalink
feat: support JSX and TSX in edge functions (#161)
Browse files Browse the repository at this point in the history
* feat: support JSX and TSX in edge functions

* chore: include entrypoints in directories

* chore: changes from review

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
ascorbic and kodiakhq[bot] committed Oct 17, 2022
1 parent 6ba3594 commit f1a9abb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions node/finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { basename, extname, join } from 'path'
import { EdgeFunction } from './edge_function.js'
import { nonNullable } from './utils/non_nullable.js'

const ALLOWED_EXTENSIONS = new Set(['.js', '.ts'])
const ALLOWED_EXTENSIONS = new Set(['.js', '.jsx', '.ts', '.tsx'])

const findFunctionInDirectory = async (directory: string): Promise<EdgeFunction | undefined> => {
const name = basename(directory)
const candidatePaths = [`${name}.js`, `index.js`, `${name}.ts`, `index.ts`].map((filename) =>
join(directory, filename),
)
const candidatePaths = [...ALLOWED_EXTENSIONS]
.flatMap((extension) => [`${name}${extension}`, `index${extension}`])
.map((filename) => join(directory, filename))

let functionPath

Expand Down

0 comments on commit f1a9abb

Please sign in to comment.