Skip to content

Add support for loading TypeScript functions using tsx in the Functions Emulator #8663

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

taeold
Copy link
Contributor

@taeold taeold commented May 28, 2025

Emulator will try to detect use of TypeScript by checking existence of tsconfig.json and will prefer using tsx in place of node to start the process for loading and executing functions.

This allows developers to skip running TS compilation on the side - index.ts file will be read directly by the Functions Emulator!

@taeold taeold marked this pull request as ready for review May 29, 2025 00:40
@taeold taeold changed the title Support loading TypeScript functions using tsx in Functions Emulator Add support for loading TypeScript functions using tsx in the Functions Emulator May 29, 2025
@taeold taeold requested a review from Copilot May 29, 2025 00:46
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for loading TypeScript functions using tsx in the Functions Emulator so that developers can run TypeScript files directly without a separate compile step.

  • Added tsx as a dependency in package files.
  • Updated the functions emulator runtime and delegate logic to override the entry point for TypeScript projects.
  • Introduced getTypeScriptEntryPoint to resolve the TypeScript source file and added an isEmulator flag to control TS-specific behavior.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
templates/init/functions/typescript/package.nolint.json Added the "tsx" dependency alongside firebase-functions-test.
templates/init/functions/typescript/package.lint.json Added the "tsx" dependency alongside typescript.
src/emulator/functionsEmulatorRuntime.ts Modified trigger loading to check for a custom entry point for TS files.
src/emulator/functionsEmulator.ts Introduced the isEmulator flag and set FUNCTIONS_SOURCE in the env vars.
src/deploy/functions/runtimes/node/index.ts Added getTypeScriptEntryPoint and updated Delegate to support TS projects.
src/deploy/functions/runtimes/index.ts Extended DelegateContext with isEmulator flag.
CHANGELOG.md Documented support for loading TypeScript functions with tsx.

@taeold taeold requested a review from inlined May 29, 2025 17:16
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.

1 participant