diff --git a/.changeset/fluffy-insects-clap.md b/.changeset/fluffy-insects-clap.md new file mode 100644 index 000000000000..0d46600b4872 --- /dev/null +++ b/.changeset/fluffy-insects-clap.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +Ignore non-JS files when compiling Pages Functions diff --git a/packages/wrangler/pages/functions/filepath-routing.ts b/packages/wrangler/pages/functions/filepath-routing.ts index 1ecc6e5074de..401893fc5a97 100644 --- a/packages/wrangler/pages/functions/filepath-routing.ts +++ b/packages/wrangler/pages/functions/filepath-routing.ts @@ -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",