Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore non-JS files when compiling Pages Functions #216

Merged
merged 2 commits into from
Jan 7, 2022

Conversation

GregBrimble
Copy link
Member

Fixes #75

More strictly check file extensions when crawling the /functions directory to ensure we're only trying to include JS files.

@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2022

🦋 Changeset detected

Latest commit: cade6c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@GregBrimble GregBrimble merged commit e1c615f into main Jan 7, 2022
@GregBrimble GregBrimble deleted the ignore-non-js-files-pages-functions branch January 7, 2022 23:29
@github-actions github-actions bot mentioned this pull request Jan 7, 2022
@@ -33,7 +33,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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh hmm maybe you should do a check for .tsx here too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wrangler pages dev crashes if tsconfig.json exists in /functions
2 participants