Skip to content

Commit

Permalink
Ignore non-JS files when compiling Pages Functions (#216)
Browse files Browse the repository at this point in the history
* Ignore non-JS files when compiling Pages Functions

* Add support for `jsx` and `tsx` file extensions

Co-authored-by: Sunil Pai <[email protected]>

Co-authored-by: Sunil Pai <[email protected]>
  • Loading branch information
GregBrimble and threepointone authored Jan 7, 2022
1 parent 777f4d5 commit e1c615f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fluffy-insects-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Ignore non-JS files when compiling Pages Functions
2 changes: 1 addition & 1 deletion packages/wrangler/pages/functions/filepath-routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function generateConfigFromFileTree({

await forEachFile(baseDir, async (filepath) => {
const ext = path.extname(filepath);
if (/\.(mjs|js|ts)/.test(ext)) {
if (/^\.(mjs|js|ts|tsx|jsx)$/.test(ext)) {
// transform the code to ensure we're working with vanilla JS + ESM
const { code } = await transform(await fs.readFile(filepath, "utf-8"), {
loader: ext === ".ts" ? "ts" : "js",
Expand Down

0 comments on commit e1c615f

Please sign in to comment.