From a9ee1e246dc09530dc3b70b2e86e4705529bdceb Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Mon, 17 Oct 2022 12:58:32 +0100 Subject: [PATCH] feat: support JSX and TSX in edge functions (netlify/edge-bundler#161) * 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> --- packages/edge-bundler/node/finder.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/edge-bundler/node/finder.ts b/packages/edge-bundler/node/finder.ts index 964e7e31c9..1277045e7d 100644 --- a/packages/edge-bundler/node/finder.ts +++ b/packages/edge-bundler/node/finder.ts @@ -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 => { 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